OSDN Git Service

add JPG and TIFF Support via OpenCV for Image::load and Image::save
[psychlops/cpp.git] / psychlops / platform / win32 / psychlops_io_API_Win32.cpp
1 /*\r
2  *  psychlops_io_API_Win32.cpp\r
3  *  Psychlops Standard Library (Win32)\r
4  *\r
5  *  Last Modified 2006/01/05 by Kenchi HOSOKAWA\r
6  *  (C) 2005 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO\r
7  */\r
8 \r
9 #include <string.h>\r
10 #include <stdio.h>\r
11 \r
12 #include <windows.h>\r
13 \r
14 \r
15 #include "psychlops_io_API_Win32.h"
16 #define PSYCHLOPS_WINDOW_API_PLATFORM
17 #include "../../platform/psychlops_platform_selector.h"\r
18 #include "../../core/devices/psychlops_io_hid.h"\r
19 #include "../../core/devices/psychlops_io_display.h"\r
20 #include "../../core/graphic/psychlops_g_canvas.h"\r
21 #include "../../extension/standard/widgets/psychlops_widgets_event.h"\r
22 #include "../../core/ApplicationInterfaces/psychlops_code_exception.h"\r
23 \r
24 \r
25 namespace Psychlops {\r
26
27         typedef HumanInterfaceDevice HID;
28 \r
29         HANDLE APIHIDProperties::io_thread;\r
30         DWORD APIHIDProperties::io_threadID;\r
31         HDC APIHIDProperties::the_display_;                     //      Handle for dummy Device Context\r
32         WNDCLASSEX APIHIDProperties::wcx;                               //      Handle for dummy WindowClassEx\r
33         HWND APIHIDProperties::hWnd;                                    //      Handle for dummy Window\r
34 \r
35         bool APIHIDProperties::refresh_needed = false;\r
36 \r
37 \r
38         //  Event Based Keyboard-Accept Code\r
39         void APIHIDProperties::initialize() {
40         for(int i=0; i<4; i++) for(int j=0; j<keycnt_; j++) states_[i][j] = 0;
41                 bindKeyCode();\r
42 //              io_thread = CreateThread(NULL, 0, &setupListener, NULL, 0, &io_threadID);\r
43         }
44         void APIHIDProperties::finalize() {
45 //              io_thread = CreateThread(NULL, 0, &setupListener, NULL, 0, &io_threadID);
46         }\r
47 /*      DWORD WINAPI APIHIDProperties::setupListener(LPVOID vdParam) {\r
48                 wcx.cbSize        = sizeof(WNDCLASSEX);\r
49                 wcx.style         = NULL;\r
50                 wcx.lpfnWndProc   = (WNDPROC)&(APIApplicationProperties::proc);\r
51                 wcx.cbClsExtra    = 0;\r
52                 wcx.cbWndExtra    = 0;\r
53                 wcx.hInstance     = APIApplicationProperties::startupinfo.hInstance_;\r
54                 wcx.hIcon         = NULL;\r
55                 wcx.hIconSm       = NULL;\r
56                 wcx.hCursor       = NULL;\r
57                 wcx.hbrBackground = NULL;\r
58                 wcx.lpszMenuName  = "Psychlops Input Listner";\r
59                 wcx.lpszClassName = "PsychlopsInputListner";\r
60                 if (!RegisterClassEx(&wcx)) throw Exception(typeid(APIHIDProperties), "API ERROR", "Failed to regist control message listner.");\r
61 \r
62                 hWnd = CreateWindowEx( NULL, "PsychlopsInputListner", "Psychlops Dummy Window", NULL, 0,0,0,0, HWND_MESSAGE, NULL, wcx.hInstance, NULL);\r
63                 if(hWnd==NULL) throw Exception(typeid(APIHIDProperties), "API ERROR", "Failed to regist control message listner.");\r
64 \r
65                 MSG msg;\r
66                 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);\r
67 \r
68                 Keyboard::initialize();\r
69                 Mouse::initialize();\r
70 \r
71                 SetThreadPriority(io_thread, THREAD_PRIORITY_LOWEST);\r
72 \r
73                 loopListener();\r
74         }*/\r
75         void APIHIDProperties::startListener() {\r
76 //              SetThreadPriority(io_thread, THREAD_PRIORITY_BELOW_NORMAL);\r
77         }\r
78         void APIHIDProperties::stopListener() {\r
79 //              SetThreadPriority(io_thread, THREAD_PRIORITY_LOWEST);\r
80         }\r
81         void APIHIDProperties::listen() {\r
82                 Point pp;\r
83                 Events::MouseLeftDown mouseLeftDown;\r
84                 Events::MouseLeftUp mouseLeftUp;\r
85                 Events::KeyDown keyDown;\r
86                 Events::KeyUp keyUp;\r
87 \r
88                 MSG msg;\r
89                 POINT mouse_global_p;\r
90                 while(0!=PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)){
91                 GetMessage(&msg, NULL, 0 ,0);\r
92                 GetCursorPos(&mouse_global_p);\r
93                 Mouse::uniX.val_ = mouse_global_p.x;\r
94                 Mouse::uniY.val_ = mouse_global_p.y;
95                 switch( msg.message ) {\r
96                         case WM_SYSKEYDOWN:\r
97                                 if ( msg.wParam==VK_F4 ) PostQuitMessage(0);\r
98                                 break;
99                         case WM_MOUSEMOVE:
100                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
101                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);
102                                 break;\r
103                         case WM_LBUTTONDOWN:\r
104                                 HID::state[HID::pushed].button[Mouse::left.code] = true;\r
105                                 HID::state[HID::pressed].button[Mouse::left.code] = true;
106                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
107                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
108                                 if(Display::the_canvas!=0) {\r
109                                         pp = Display::the_canvas->mouse();\r
110                                         mouseLeftDown.place = pp;\r
111                                         mouseLeftDown.time = msg.time;\r
112                                         Display::the_canvas->eventroot.distribute(mouseLeftDown);\r
113                                 }\r
114                                 break;\r
115                         case WM_LBUTTONUP:\r
116                                 HID::state[HID::released].button[Mouse::left.code] = true;\r
117                                 HID::state[HID::pressed].button[Mouse::left.code] = false;
118                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
119                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
120                                 if(Display::the_canvas!=0) {\r
121                                         pp = Display::the_canvas->mouse();\r
122                                         mouseLeftUp.place = pp;\r
123                                         mouseLeftUp.time = msg.time;\r
124                                         Display::the_canvas->eventroot.distribute(mouseLeftUp);\r
125                                 }\r
126                                 break;\r
127                         case WM_RBUTTONDOWN:\r
128                                 HID::state[HID::pushed].button[Mouse::right.code] = true;\r
129                                 HID::state[HID::pressed].button[Mouse::right.code] = true;
130                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
131                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
132                                 break;\r
133                         case WM_RBUTTONUP:\r
134                                 HID::state[HID::released].button[Mouse::right.code] = true;\r
135                                 HID::state[HID::pressed].button[Mouse::right.code] = false;
136                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
137                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
138                                 break;\r
139                         case WM_MBUTTONDOWN:\r
140                                 HID::state[HID::pushed].button[Mouse::middle.code] = true;\r
141                                 HID::state[HID::pressed].button[Mouse::middle.code] = true;
142                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
143                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
144                                 break;\r
145                         case WM_MBUTTONUP:\r
146                                 HID::state[HID::released].button[Mouse::middle.code] = true;\r
147                                 HID::state[HID::pressed].button[Mouse::middle.code] = false;
148                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
149                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
150                                 break;\r
151                         case WM_MOUSEHOVER:\r
152                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);\r
153                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
154                                 break;\r
155                         case WM_MOUSELEAVE:\r
156                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);\r
157                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);\r
158                                 break;\r
159                         case WM_KEYDOWN:
160                                 HID::state[HID::pushed].key[msg.wParam] = true;
161                                 HID::state[HID::pressed].key[msg.wParam] = true;\r
162                                 /*if(Display::the_canvas!=0) {\r
163                                         keyDown.code = 0;\r
164                                         keyDown.time = msg.time;\r
165                                         Display::the_canvas->eventroot.distribute(keyDown);\r
166                                 }*/\r
167                                 break;\r
168                         case WM_KEYUP:
169                                 HID::state[HID::released].key[msg.wParam] = true;
170                                 HID::state[HID::pressed].key[msg.wParam] = false;\r
171                                 /*if(Display::the_canvas!=0) {\r
172                                         keyUp.code = 0;\r
173                                         keyUp.time = msg.time;\r
174                                         Display::the_canvas->eventroot.distribute(keyUp);\r
175                                 }*/\r
176                                 break;
177                         case WM_MOUSEWHEEL:
178                                 Mouse::wheelDelta.y -= (short)HIWORD(msg.wParam);
179                                 //Mouse::uniX.val_ = (SHORT)LOWORD(msg.lParam);
180                                 //Mouse::uniY.val_ = (SHORT)HIWORD(msg.lParam);
181                                 break;\r
182                         case WM_QUIT:\r
183                         case WM_CLOSE:\r
184                         case WM_DESTROY:\r
185                                 ExitProcess(TRUE);\r
186                                 break;\r
187                         default:\r
188                                 TranslateMessage(&msg);\r
189                                 DispatchMessage(&msg);\r
190                                 break;\r
191                 }
192                 }
193                 //update();\r
194         }
195         void APIHIDProperties::update()\r
196         {\r
197                 listen();\r
198         }\r
199         /*\r
200         void updateOld() {
201                 BYTE tmp;
202                 memcpy(reinterpret_cast<void *>(states_[HID::hadpressed]), reinterpret_cast<const void *>(states_[HID::pressed]), keycnt_);
203                 GetKeyboardState(states_[Keyboard::pressed]);
204                 for(int i=0; i<keycnt_; i++) {
205                         tmp = states_[Keyboard::pressed][i] ^ states_[Keyboard::hadpressed][i];
206                         states_[HID::pushed][i] |= tmp & states_[HID::pressed][i];
207                         states_[HID::released][i] |= tmp & states_[HID::hadpressed][i];
208                 }
209
210                 ::POINT point;
211                 GetCursorPos(&point);
212                 Mouse::uniX.val_ = point.x;
213                 Mouse::uniY.val_ = point.y;
214         }\r
215         */\r
216         void APIHIDProperties::updatePointerPosition() {\r
217                 ::POINT point;\r
218                 GetCursorPos(&point);\r
219                 Mouse::uniX.val_ = point.x;\r
220                 Mouse::uniY.val_ = point.y;\r
221         }\r
222 \r
223
224         bool APIHIDProperties::get(Mouse::Button button, Mouse::ButtonState state) {
225                 APIHIDProperties::listen();
226                 bool val = HID::state[state].button[button.code];
227                 if(state!=Mouse::pressed) HID::state[(HID::ButtonState)state].button[button.code] = false;
228                 return val;
229         }
230         bool APIHIDProperties::get(Keyboard::Key key, Keyboard::KeyState state) {
231                 APIHIDProperties::listen();
232                 bool val = HID::state[state].key[keybinder_[key.code]];
233                 if(state!=Keyboard::pressed) HID::state[(HID::ButtonState)state].key[keybinder_[key.code]] = false;
234                 return val;
235                 /*
236                 bool tmp;
237                 if(state==Keyboard::pressed) {
238                         return pressedbit_ & states_[state][keybinder_[key.code]];
239                 }
240                 else {
241                         tmp = pressedbit_ & states_[state][keybinder_[key.code]];
242                         states_[state][keybinder_[key.code]] = 0;
243                         return tmp;
244                 }*/
245         }
246         void APIHIDProperties::setPointerPosition(int x, int y) {
247                 SetCursorPos(x,y);
248         }
249
250         struct Keyboard_ {
251                 enum KeyCode{
252                         one=0,two,three,four,five,six,seven,eight,nine,zero,
253                         a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,
254                         comma,period,slash,
255                         pad0,pad1,pad2,pad3,pad4,pad5,pad6,pad7,pad8,pad9,
256                         rtn,spc,esc,tab,up,down,left,right,
257                         //      key modulator
258                         shift=100, shift_r, ctrl, alt,
259                         //  not recommended
260                         hyphen=59,equal,backslash,caret,
261                         underscore,semicolon,colon,leftbracket,rightbracket,at,   // because these keys laid on different location in differnt keyboard-lacalization.
262                         padcomma,padperiod,padenter,padplus,padminus,padasterisk,padslash,padequal,padclear,    //  because these keys are OS-specific.
263                         nfer,xfer   // because these keys exist only on Japanese keyboard
264                 };
265         };
266         void APIHIDProperties::bindKeyCode() {
267                 keybinder_[Keyboard_::shift] = VK_SHIFT;
268                 keybinder_[Keyboard_::ctrl]  = VK_CONTROL;
269                 keybinder_[Keyboard_::alt]   = VK_MENU;
270
271
272                 keybinder_[Keyboard_::pad0] = 0x60;
273                 keybinder_[Keyboard_::pad1] = 0x61;
274                 keybinder_[Keyboard_::pad2] = 0x62;
275                 keybinder_[Keyboard_::pad3] = 0x63;
276                 keybinder_[Keyboard_::pad4] = 0x64;
277                 keybinder_[Keyboard_::pad5] = 0x65;
278                 keybinder_[Keyboard_::pad6] = 0x66;
279                 keybinder_[Keyboard_::pad7] = 0x67;
280                 keybinder_[Keyboard_::pad8] = 0x68;
281                 keybinder_[Keyboard_::pad9] = 0x69;
282                 keybinder_[Keyboard_::padslash] = 0x6F;
283                 keybinder_[Keyboard_::padplus] = 0x6B;
284                 keybinder_[Keyboard_::padminus] = 0x6D;
285                 keybinder_[Keyboard_::padasterisk] = 0x6A;
286
287                 //keybinder_[Keyboard_::padcomma] = 2;
288                 //keybinder_[Keyboard_::padcomma] = 128;
289                 //keybinder_[Keyboard_::padperiod] = 2;
290                 //keybinder_[Keyboard_::padperiod] = 33554432L;
291                 //keybinder_[Keyboard_::padenter] = 2;
292                 //keybinder_[Keyboard_::padenter] = 1048576L;
293
294                 //keybinder_[Keyboard_::padequal] = 2;
295                 //keybinder_[Keyboard_::padequal] = 512;
296                 //keybinder_[Keyboard_::padclear] = 2;
297                 //keybinder_[Keyboard_::padclear] = 2147483648UL;
298
299                 keybinder_[Keyboard_::one] = 0x31;
300                 keybinder_[Keyboard_::two] = 0x32;
301                 keybinder_[Keyboard_::three] = 0x33;
302                 keybinder_[Keyboard_::four] = 0x34;
303                 keybinder_[Keyboard_::five] = 0x35;
304                 keybinder_[Keyboard_::six] = 0x36;
305                 keybinder_[Keyboard_::seven] = 0x37;
306                 keybinder_[Keyboard_::eight] = 0x38;
307                 keybinder_[Keyboard_::nine] = 0x39;
308                 keybinder_[Keyboard_::zero] = 0x30;
309                 keybinder_[Keyboard_::hyphen] = 0xBD;
310                 keybinder_[Keyboard_::caret] = 1;
311                 keybinder_[Keyboard_::backslash] = 0xDC;
312
313                 keybinder_[Keyboard_::q] = 0x51;
314                 keybinder_[Keyboard_::w] = 0x57;
315                 keybinder_[Keyboard_::e] = 0x45;
316                 keybinder_[Keyboard_::r] = 0x52;
317                 keybinder_[Keyboard_::t] = 0x54;
318                 keybinder_[Keyboard_::y] = 0x59;
319                 keybinder_[Keyboard_::u] = 0x55;
320                 keybinder_[Keyboard_::i] = 0x49;
321                 keybinder_[Keyboard_::o] = 0x4F;
322                 keybinder_[Keyboard_::p] = 0x50;
323                 keybinder_[Keyboard_::at] = 33554432L;
324                 keybinder_[Keyboard_::leftbracket] = 0xDB;
325
326                 keybinder_[Keyboard_::a] = 0x41;
327                 keybinder_[Keyboard_::s] = 0x53;
328                 keybinder_[Keyboard_::d] = 0x44;
329                 keybinder_[Keyboard_::f] = 0x46;
330                 keybinder_[Keyboard_::g] = 0x47;
331                 keybinder_[Keyboard_::h] = 0x48;
332                 keybinder_[Keyboard_::j] = 0x4A;
333                 keybinder_[Keyboard_::k] = 0x4B;
334                 keybinder_[Keyboard_::l] = 0x4C;
335                 keybinder_[Keyboard_::semicolon] = 0xBA;
336                 keybinder_[Keyboard_::colon] = 0xBA;
337                 keybinder_[Keyboard_::rightbracket] = 0xDD;
338
339                 keybinder_[Keyboard_::z] = 0x5A;
340                 keybinder_[Keyboard_::x] = 0x58;
341                 keybinder_[Keyboard_::c] = 0x43;
342                 keybinder_[Keyboard_::v] = 0x56;
343                 keybinder_[Keyboard_::b] = 0x42;
344                 keybinder_[Keyboard_::n] = 0x4E;
345                 keybinder_[Keyboard_::m] = 0x4D;
346                 keybinder_[Keyboard_::comma] = 0xBC;
347                 keybinder_[Keyboard_::period] = 0xBE;
348                 keybinder_[Keyboard_::slash] = 0xBF;
349                 keybinder_[Keyboard_::underscore] = 64;
350
351                 keybinder_[Keyboard_::esc] = VK_ESCAPE;
352                 keybinder_[Keyboard_::rtn] = VK_RETURN;\r
353                 keybinder_[Keyboard_::tab] = VK_TAB;
354                 keybinder_[Keyboard_::spc] = 0x20;
355                 keybinder_[Keyboard_::up] = 0x26;
356                 keybinder_[Keyboard_::down] = 0x28;
357                 keybinder_[Keyboard_::left] = 0x25;
358                 keybinder_[Keyboard_::right] = 0x27;
359         }
360
361         unsigned long APIHIDProperties::keybinder_[keycnt_];
362         BYTE APIHIDProperties::states_[4][keycnt_];
363
364
365 /*\r
366         unsigned long APIKeyboardProperties::keybinder_[keycnt_];\r
367         BYTE APIKeyboardProperties::states_[4][keycnt_];\r
368 \r
369         bool APIKeyboardProperties::get(Keyboard::Key key, Keyboard::KeyState state) {\r
370 APIHIDProperties::listen();\r
371                 bool tmp;\r
372                 if(state==Keyboard::pressed) {\r
373                         return pressedbit_ & states_[state][keybinder_[key.code]];\r
374                 }\r
375                 else {\r
376                         tmp = pressedbit_ & states_[state][keybinder_[key.code]];\r
377                         states_[state][keybinder_[key.code]] = 0;\r
378                         return tmp;\r
379                 }\r
380         }\r
381 \r
382         void APIKeyboardProperties::update() {\r
383                 BYTE tmp;\r
384                 memcpy(reinterpret_cast<void *>(states_[Keyboard::hadpressed]), reinterpret_cast<const void *>(states_[Keyboard::pressed]), keycnt_);\r
385                 GetKeyboardState(states_[Keyboard::pressed]);\r
386                 for(int i=0; i<keycnt_; i++) {\r
387                         tmp = states_[Keyboard::pressed][i] ^ states_[Keyboard::hadpressed][i];\r
388                         states_[Keyboard::pushed][i] |= tmp & states_[Keyboard::pressed][i];\r
389                         states_[Keyboard::released][i] |= tmp & states_[Keyboard::hadpressed][i];\r
390                 }\r
391         }\r
392 \r
393         void APIKeyboardProperties::refresh() {\r
394                 for(int i=0; i<keycnt_; i++) {\r
395                         states_[Keyboard::pushed][i] = 0;\r
396                         states_[Keyboard::released][i] = 0;\r
397                 }\r
398         }\r
399 \r
400 \r
401 \r
402     void APIKeyboardProperties::initialize() {\r
403         //memset(states_, 4*keycnt_, 0);\r
404         for(int i=0; i<4; i++) for(int j=0; j<keycnt_; j++) states_[i][j] = 0;\r
405         bindKeyCode();\r
406     }
407
408 \r
409         struct Keyboard_ {
410                 enum KeyCode{
411                         one,two,three,four,five,six,seven,eight,nine,zero,
412                         a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,
413                         comma,period,slash,
414                         pad0,pad1,pad2,pad3,pad4,pad5,pad6,pad7,pad8,pad9,
415                         rtn,spc,esc,up,down,left,right,
416                         //      key modulator
417                         shift, ctrl, alt,
418                         //  not recommended
419                         hyphen,equal,backslash,caret,
420                         underscore,semicolon,colon,leftbracket,rightbracket,at,   // because these keys laid on different location in differnt keyboard-lacalization.
421                         padcomma,padperiod,padenter,padplus,padminus,padasterisk,padslash,padequal,padclear     //  because these keys are OS-specific.
422                 };
423         };
424         void APIKeyboardProperties::bindKeyCode() {\r
425                 keybinder_[Keyboard_::shift] = VK_SHIFT;\r
426                 keybinder_[Keyboard_::ctrl]  = 0x11;\r
427                 keybinder_[Keyboard_::alt]   = VK_MENU;\r
428 \r
429 \r
430                 keybinder_[Keyboard_::pad0] = 0x60;\r
431                 keybinder_[Keyboard_::pad1] = 0x61;\r
432                 keybinder_[Keyboard_::pad2] = 0x62;\r
433                 keybinder_[Keyboard_::pad3] = 0x63;\r
434                 keybinder_[Keyboard_::pad4] = 0x64;\r
435                 keybinder_[Keyboard_::pad5] = 0x65;\r
436                 keybinder_[Keyboard_::pad6] = 0x66;\r
437                 keybinder_[Keyboard_::pad7] = 0x67;\r
438                 keybinder_[Keyboard_::pad8] = 0x68;\r
439                 keybinder_[Keyboard_::pad9] = 0x69;\r
440                 keybinder_[Keyboard_::padslash] = 0x6F;\r
441                 keybinder_[Keyboard_::padplus] = 0x6B;\r
442                 keybinder_[Keyboard_::padminus] = 0x6D;\r
443                 keybinder_[Keyboard_::padasterisk] = 0x6A;\r
444
445                 //keybinder_[Keyboard_::padcomma] = 2;\r
446                 //keybinder_[Keyboard_::padcomma] = 128;\r
447                 //keybinder_[Keyboard_::padperiod] = 2;\r
448                 //keybinder_[Keyboard_::padperiod] = 33554432L;\r
449                 //keybinder_[Keyboard_::padenter] = 2;\r
450                 //keybinder_[Keyboard_::padenter] = 1048576L;\r
451 \r
452                 //keybinder_[Keyboard_::padequal] = 2;\r
453                 //keybinder_[Keyboard_::padequal] = 512;\r
454                 //keybinder_[Keyboard_::padclear] = 2;\r
455                 //keybinder_[Keyboard_::padclear] = 2147483648UL;\r
456 \r
457                 keybinder_[Keyboard_::one] = 0x31;\r
458                 keybinder_[Keyboard_::two] = 0x32;\r
459                 keybinder_[Keyboard_::three] = 0x33;\r
460                 keybinder_[Keyboard_::four] = 0x34;\r
461                 keybinder_[Keyboard_::five] = 0x35;\r
462                 keybinder_[Keyboard_::six] = 0x36;\r
463                 keybinder_[Keyboard_::seven] = 0x37;\r
464                 keybinder_[Keyboard_::eight] = 0x38;\r
465                 keybinder_[Keyboard_::nine] = 0x39;\r
466                 keybinder_[Keyboard_::zero] = 0x30;\r
467                 keybinder_[Keyboard_::hyphen] = 0xBD;\r
468                 keybinder_[Keyboard_::caret] = 1;\r
469                 keybinder_[Keyboard_::backslash] = 0xDC;\r
470 \r
471                 keybinder_[Keyboard_::q] = 0x51;\r
472                 keybinder_[Keyboard_::w] = 0x57;\r
473                 keybinder_[Keyboard_::e] = 0x45;\r
474                 keybinder_[Keyboard_::r] = 0x52;\r
475                 keybinder_[Keyboard_::t] = 0x54;\r
476                 keybinder_[Keyboard_::y] = 0x59;\r
477                 keybinder_[Keyboard_::u] = 0x55;\r
478                 keybinder_[Keyboard_::i] = 0x49;\r
479                 keybinder_[Keyboard_::o] = 0x4F;\r
480                 keybinder_[Keyboard_::p] = 0x50;\r
481                 keybinder_[Keyboard_::at] = 33554432L;\r
482                 keybinder_[Keyboard_::leftbracket] = 0xDB;\r
483 \r
484                 keybinder_[Keyboard_::a] = 0x41;\r
485                 keybinder_[Keyboard_::s] = 0x53;\r
486                 keybinder_[Keyboard_::d] = 0x44;\r
487                 keybinder_[Keyboard_::f] = 0x46;\r
488                 keybinder_[Keyboard_::g] = 0x47;\r
489                 keybinder_[Keyboard_::h] = 0x48;\r
490                 keybinder_[Keyboard_::j] = 0x4A;\r
491                 keybinder_[Keyboard_::k] = 0x4B;\r
492                 keybinder_[Keyboard_::l] = 0x4C;\r
493                 keybinder_[Keyboard_::semicolon] = 0xBA;\r
494                 keybinder_[Keyboard_::colon] = 0xBA;\r
495                 keybinder_[Keyboard_::rightbracket] = 0xDD;\r
496 \r
497                 keybinder_[Keyboard_::z] = 0x5A;\r
498                 keybinder_[Keyboard_::x] = 0x58;\r
499                 keybinder_[Keyboard_::c] = 0x43;\r
500                 keybinder_[Keyboard_::v] = 0x56;\r
501                 keybinder_[Keyboard_::b] = 0x42;\r
502                 keybinder_[Keyboard_::n] = 0x4E;\r
503                 keybinder_[Keyboard_::m] = 0x4D;\r
504                 keybinder_[Keyboard_::comma] = 0xBC;\r
505                 keybinder_[Keyboard_::period] = 0xBE;\r
506                 keybinder_[Keyboard_::slash] = 0xBF;\r
507                 keybinder_[Keyboard_::underscore] = 64;\r
508 \r
509                 keybinder_[Keyboard_::esc] = 0x1B;\r
510                 keybinder_[Keyboard_::rtn] = 0x0D;\r
511                 keybinder_[Keyboard_::spc] = 0x20;\r
512                 keybinder_[Keyboard_::up] = 0x26;\r
513                 keybinder_[Keyboard_::down] = 0x28;\r
514                 keybinder_[Keyboard_::left] = 0x25;\r
515                 keybinder_[Keyboard_::right] = 0x27;\r
516         }\r
517 \r
518 \r
519 \r
520         bool APIMouseProperties::buttonstate_[4][3];\r
521         POINT APIMouseProperties::position_;\r
522 \r
523 \r
524         void APIMouseProperties::getPosition(int &x, int &y) {\r
525 //APIInputProperties::listen();\r
526                 x = position_.x;\r
527                 y = position_.y;\r
528         }\r
529         void APIMouseProperties::setPosition(int x, int y) {\r
530                 SetCursorPos(x,y);\r
531         }\r
532 \r
533         void APIMouseProperties::initialize() {\r
534                 refresh();\r
535         }\r
536 \r
537         void APIMouseProperties::update() {\r
538                 GetCursorPos(&position_);\r
539         }\r
540         void APIMouseProperties::refresh() {\r
541                 for(int i=0; i<4; i++) for(int j=0; j<3; j++) buttonstate_[i][j] = false;\r
542         }\r
543 \r
544         bool APIMouseProperties::get(Mouse::Button button, Mouse::ButtonState state) {\r
545 APIHIDProperties::listen();\r
546                 bool val = buttonstate_[state][button.code];\r
547                 switch(state) {\r
548                         case Mouse::pushed:\r
549                         case Mouse::released:\r
550                                 buttonstate_[state][button.code] = false;\r
551                                 break;\r
552                 }\r
553                 return val;\r
554         }\r
555 */\r
556 \r
557 }       /*      <- namespace Psycholops         */\r