blob: 7cbb858e48653880156b5f94eb587d5820fcab04 (
plain)
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
|
#include "../ControllerInterface.h"
#ifdef CIFACE_USE_OSX
#include "OSX.h"
#include "OSXPrivate.h"
namespace ciface
{
namespace OSX
{
void Init( std::vector<ControllerInterface::Device*>& devices, void* hwnd )
{
// mouse will be added to this, Keyboard class will be turned into KeyboardMouse
// single device for combined keyboard/mouse, this will allow combinations like shift+click more easily
//devices.push_back( new Keyboard( hwnd ) );
}
Keyboard::Keyboard( void *View )
{
memset( &m_state, 0, sizeof(m_state) );
OSX_Init(View);
// This is REALLY dumb right here
// Should REALLY cover the entire UTF-8 Range
for (int a = 0; a < 256; ++a)
inputs.push_back( new Key( (char)a ) );
}
Keyboard::~Keyboard()
{
// might not need this func
}
ControlState Keyboard::GetInputState( const ControllerInterface::Device::Input* const input )
{
return ((Input*)input)->GetState( &m_state );
}
void Keyboard::SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state )
{
}
bool Keyboard::UpdateInput()
{
memset(m_state.keyboard, 0, 256);
OSX_UpdateKeys(256, m_state.keyboard );
// mouse stuff in here too
return true;
}
bool Keyboard::UpdateOutput()
{
return true;
}
std::string Keyboard::GetName() const
{
return "Keyboard";
//return "Keyboard Mouse"; // change to this later
}
std::string Keyboard::GetSource() const
{
return "OSX";
}
int Keyboard::GetId() const
{
return 0;
}
ControlState Keyboard::Key::GetState( State* const state )
{
for(unsigned int a = 0; a < 256; ++a)
if(state->keyboard[a] == m_index)
return true;
return false;
}
std::string Keyboard::Key::GetName() const
{
char temp[16];
sprintf(temp, "Key:%c", m_index);
return std::string(temp);
}
}
}
#endif
|