1 #include "mof/private/DirectInput.hpp"
2 #include "mof/private/DeviceInputReceiver.hpp"
3 #include "mof/InputDevice.hpp"
4 #include "mof/ConsoleIO.hpp"
5 #include "mof/InputEventCondition.hpp"
8 mof::DeviceInputReceiver::DeviceInputReceiver()
9 : mof::InputReceiver(){
10 m_pKeyStates = new bool[mof::DeviceInputReceiver::END];
11 for(int i = 0 ; i < mof::DeviceInputReceiver::END ; i++)m_pKeyStates[i] = false;
14 mof::DeviceInputReceiver::~DeviceInputReceiver(){
15 delete[] m_pKeyStates;
19 bool mof::DeviceInputReceiver::testKeyState(mof::InputReceiver::Key key){
21 return m_pKeyStates[key];
25 void mof::DeviceInputReceiver::update(){
26 mof::InputDevice::update();
30 void mof::DeviceInputReceiver::notifyInputEvent(mof::InputEvent& inputEvent){
31 mof::DeviceInputReceiver::Key key;
34 switch(inputEvent.dwOfs){
36 key = mof::DeviceInputReceiver::UP;
39 key = mof::DeviceInputReceiver::DOWN;
42 key = mof::DeviceInputReceiver::LEFT;
45 key = mof::DeviceInputReceiver::RIGHT;
48 key = mof::DeviceInputReceiver::A;
51 key = mof::DeviceInputReceiver::B;
54 key = mof::DeviceInputReceiver::C;
57 key = mof::DeviceInputReceiver::D;
60 key = mof::DeviceInputReceiver::E;
63 key = mof::DeviceInputReceiver::F;
66 key = mof::DeviceInputReceiver::G;
69 key = mof::DeviceInputReceiver::H;
72 key = mof::DeviceInputReceiver::I;
75 key = mof::DeviceInputReceiver::J;
78 key = mof::DeviceInputReceiver::K;
81 key = mof::DeviceInputReceiver::L;
84 key = mof::DeviceInputReceiver::M;
87 key = mof::DeviceInputReceiver::N;
90 key = mof::DeviceInputReceiver::O;
93 key = mof::DeviceInputReceiver::P;
96 key = mof::DeviceInputReceiver::Q;
99 key = mof::DeviceInputReceiver::R;
102 key = mof::DeviceInputReceiver::S;
105 key = mof::DeviceInputReceiver::T;
108 key = mof::DeviceInputReceiver::U;
111 key = mof::DeviceInputReceiver::V;
114 key = mof::DeviceInputReceiver::W;
117 key = mof::DeviceInputReceiver::X;
120 key = mof::DeviceInputReceiver::Y;
123 key = mof::DeviceInputReceiver::Z;
126 key = mof::DeviceInputReceiver::ESCAPE;
131 m_pKeyStates[key] = (inputEvent.dwData & 0x80) != 0;
132 m_pKeyStates[mof::DeviceInputReceiver::ANY] = (inputEvent.dwData & 0x80) != 0;