Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "Headers/EventHandler.h"
#include "Headers/InputInterface.h"
#include "Core/Headers/Kernel.h"

namespace Divide {
    namespace Input {

EventHandler::EventHandler(InputInterface* pApp, Kernel* const kernel) : _kernel(kernel),
                                                                         _pApplication(pApp),
                                                                         _pJoystickInterface(nullptr),
                                                                         _pEffectMgr(nullptr)
{
    DIVIDE_ASSERT(kernel != nullptr, "EventHandler error: INVALID KERNEL PASSED ON HANDLER CREATION");
}

void EventHandler::initialize(JoystickInterface* pJoystickInterface, EffectManager* pEffectMgr){
  _pJoystickInterface = pJoystickInterface;
  _pEffectMgr = pEffectMgr;
}

/// Input events are either handled by the kernel
bool EventHandler::onKeyDown( const KeyEvent &arg ) {
    return _kernel->onKeyDown(arg); 
}

bool EventHandler::onKeyUp( const KeyEvent &arg ) {
    return _kernel->onKeyUp(arg); 
}

bool EventHandler::joystickButtonPressed( const JoystickEvent &arg, I8 button ) {
    return _kernel->joystickButtonPressed(arg,button); 
}

bool EventHandler::joystickButtonReleased( const JoystickEvent &arg, I8 button ) {
    return _kernel->joystickButtonReleased(arg,button); 
}

bool EventHandler::joystickAxisMoved( const JoystickEvent &arg, I8 axis) {
    return _kernel->joystickAxisMoved(arg,axis); 
}

bool EventHandler::joystickPovMoved( const JoystickEvent &arg, I8 pov ) {
    return _kernel->joystickPovMoved(arg,pov); 
}

bool EventHandler::joystickSliderMoved( const JoystickEvent &arg, I8 index) {
    return _kernel->joystickSliderMoved(arg,index); 
}

bool EventHandler::joystickVector3DMoved( const JoystickEvent &arg, I8 index) {
    return _kernel->joystickVector3DMoved(arg,index); 
}

bool EventHandler::mouseMoved( const MouseEvent &arg ) {
    return _kernel->mouseMoved(arg);
}

bool EventHandler::mouseButtonPressed( const MouseEvent &arg, MouseButton id ) {
    return _kernel->mouseButtonPressed(arg,id); 
}

bool EventHandler::mouseButtonReleased( const MouseEvent &arg, MouseButton id ) {
    return _kernel->mouseButtonReleased(arg,id); 
}

bool EventHandler::keyPressed( const OIS::KeyEvent &arg ) {
    KeyEvent& key = InputInterface::getInstance().getKeyRef(static_cast<U32>(arg.key));
    key._text = arg.text;
    key._pressed = true;
    return onKeyDown(key);
}

bool EventHandler::keyReleased( const OIS::KeyEvent &arg ) {
    KeyEvent& key = InputInterface::getInstance().getKeyRef(static_cast<U32>(arg.key));
    key._text = arg.text;
    key._pressed = false;
    return onKeyUp(key);
}

//////////// Effect variables applier functions /////////////////////////////////////////////
// These functions apply the given Variables to the given OIS::Effect

// Variable force "Force" + optional "AttackFactor" constant, on a OIS::ConstantEffect
void forceVariableApplier(MapVariables& mapVars, OIS::Effect* pEffect){
  D32 dForce = mapVars["Force"]->getValue();
  D32 dAttackFactor = 1.0;
  if (mapVars.find("AttackFactor") != mapVars.end())
    dAttackFactor = mapVars["AttackFactor"]->getValue();

  OIS::ConstantEffect* pConstForce = dynamic_cast<OIS::ConstantEffect*>(pEffect->getForceEffect());
  pConstForce->level = (I16)dForce;
  pConstForce->envelope.attackLevel = (U16)std::fabs(dForce*dAttackFactor);
  pConstForce->envelope.fadeLevel = (U16)std::fabs(dForce); // Fade never reached, in fact.
}

// Variable "Period" on an OIS::PeriodicEffect
void periodVariableApplier(MapVariables& mapVars, OIS::Effect* pEffect){
  D32 dPeriod = mapVars["Period"]->getValue();

  OIS::PeriodicEffect* pPeriodForce = dynamic_cast<OIS::PeriodicEffect*>(pEffect->getForceEffect());
  pPeriodForce->period = (U32)dPeriod;
}

LRESULT DlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){    return FALSE; }

    }; //namespace Input
}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Input/EventHandler.cpp

Diff revisions: vs.
Revision Author Commited Message
337 Diff Diff IonutCava picture IonutCava Wed 17 Dec, 2014 17:25:16 +0000

[Ionut]
- Replaced all tabs with 4 spaces (some spacing may be off now. no way to check all the files.)
- Moved implementation details for ParamHandler, BoundingBox, BoundingSphere and ProfileTimer to proper .inl and .cpp files. (more to follow)
- Update all forward declared enums with the required storage type (as requested by the C++11 standard)

334 IonutCava picture IonutCava Wed 10 Dec, 2014 17:21:22 +0000

[Ionut]
- Reorganized the Hardware project and renamed to "Platform"
- Reorganized the Server project