comparison src/video/directfb/SDL_DirectFB_events.c @ 5281:15a71bec4a55

merged
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 12 Feb 2011 19:16:09 -0800
parents b530ef003506
children
comparison
equal deleted inserted replaced
5219:adfcdd311ae0 5281:15a71bec4a55
1 /* 1 /*
2 SDL - Simple DirectMedia Layer 2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga 3 Copyright (C) 1997-2011 Sam Lantinga
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
59 int sys_ids; 59 int sys_ids;
60 int sys_kbd; 60 int sys_kbd;
61 }; 61 };
62 62
63 /* The translation tables from a DirectFB keycode to a SDL keysym */ 63 /* The translation tables from a DirectFB keycode to a SDL keysym */
64 static SDL_ScanCode oskeymap[256]; 64 static SDL_Scancode oskeymap[256];
65 65
66 66
67 static SDL_KeySym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, 67 static SDL_Keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
68 SDL_KeySym * keysym); 68 SDL_Keysym * keysym);
69 static SDL_KeySym *DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt, 69 static SDL_Keysym *DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
70 SDL_KeySym * keysym); 70 SDL_Keysym * keysym);
71 71
72 static void DirectFB_InitOSKeymap(_THIS, SDL_ScanCode * keypmap, int numkeys); 72 static void DirectFB_InitOSKeymap(_THIS, SDL_Scancode * keypmap, int numkeys);
73 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); 73 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
74 74
75 static void UnicodeToUtf8( Uint16 w , char *utf8buf) 75 static void UnicodeToUtf8( Uint16 w , char *utf8buf)
76 { 76 {
77 unsigned char *utf8s = (unsigned char *) utf8buf; 77 unsigned char *utf8s = (unsigned char *) utf8buf;
174 static void 174 static void
175 ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) 175 ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt)
176 { 176 {
177 SDL_DFB_DEVICEDATA(_this); 177 SDL_DFB_DEVICEDATA(_this);
178 SDL_DFB_WINDOWDATA(sdlwin); 178 SDL_DFB_WINDOWDATA(sdlwin);
179 SDL_KeySym keysym; 179 SDL_Keysym keysym;
180 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; 180 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
181 181
182 if (evt->clazz == DFEC_WINDOW) { 182 if (evt->clazz == DFEC_WINDOW) {
183 switch (evt->type) { 183 switch (evt->type) {
184 case DWET_BUTTONDOWN: 184 case DWET_BUTTONDOWN:
306 306
307 static void 307 static void
308 ProcessInputEvent(_THIS, DFBInputEvent * ievt) 308 ProcessInputEvent(_THIS, DFBInputEvent * ievt)
309 { 309 {
310 SDL_DFB_DEVICEDATA(_this); 310 SDL_DFB_DEVICEDATA(_this);
311 SDL_KeySym keysym; 311 SDL_Keysym keysym;
312 int kbd_idx; 312 int kbd_idx;
313 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; 313 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
314 314
315 if (!devdata->use_linux_input) { 315 if (!devdata->use_linux_input) {
316 if (ievt->type == DIET_AXISMOTION) { 316 if (ievt->type == DIET_AXISMOTION) {
446 ProcessInputEvent(_this, &ievt); 446 ProcessInputEvent(_this, &ievt);
447 } 447 }
448 } 448 }
449 449
450 void 450 void
451 DirectFB_InitOSKeymap(_THIS, SDL_ScanCode * keymap, int numkeys) 451 DirectFB_InitOSKeymap(_THIS, SDL_Scancode * keymap, int numkeys)
452 { 452 {
453 int i; 453 int i;
454 454
455 /* Initialize the DirectFB key translation table */ 455 /* Initialize the DirectFB key translation table */
456 for (i = 0; i < numkeys; ++i) 456 for (i = 0; i < numkeys; ++i)
573 keymap[DIKI_SLASH - DIKI_UNKNOWN] = SDL_SCANCODE_SLASH; /* AB10 */ 573 keymap[DIKI_SLASH - DIKI_UNKNOWN] = SDL_SCANCODE_SLASH; /* AB10 */
574 keymap[DIKI_LESS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_NONUSBACKSLASH; /* 103rd */ 574 keymap[DIKI_LESS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_NONUSBACKSLASH; /* 103rd */
575 575
576 } 576 }
577 577
578 static SDL_KeySym * 578 static SDL_Keysym *
579 DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_KeySym * keysym) 579 DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_Keysym * keysym)
580 { 580 {
581 SDL_DFB_DEVICEDATA(_this); 581 SDL_DFB_DEVICEDATA(_this);
582 int kbd_idx = 0; /* Window events lag the device source KbdIndex(_this, evt->device_id); */ 582 int kbd_idx = 0; /* Window events lag the device source KbdIndex(_this, evt->device_id); */
583 DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx]; 583 DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx];
584 584
603 keysym->unicode = evt->key_symbol; 603 keysym->unicode = evt->key_symbol;
604 604
605 return keysym; 605 return keysym;
606 } 606 }
607 607
608 static SDL_KeySym * 608 static SDL_Keysym *
609 DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt, 609 DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
610 SDL_KeySym * keysym) 610 SDL_Keysym * keysym)
611 { 611 {
612 SDL_DFB_DEVICEDATA(_this); 612 SDL_DFB_DEVICEDATA(_this);
613 int kbd_idx = KbdIndex(_this, evt->device_id); 613 int kbd_idx = KbdIndex(_this, evt->device_id);
614 DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx]; 614 DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx];
615 615
657 cb_data *cb = callbackdata; 657 cb_data *cb = callbackdata;
658 DFB_DeviceData *devdata = cb->devdata; 658 DFB_DeviceData *devdata = cb->devdata;
659 #if USE_MULTI_API 659 #if USE_MULTI_API
660 SDL_Keyboard keyboard; 660 SDL_Keyboard keyboard;
661 #endif 661 #endif
662 SDLKey keymap[SDL_NUM_SCANCODES]; 662 SDL_Keycode keymap[SDL_NUM_SCANCODES];
663 663
664 if (!cb->sys_kbd) { 664 if (!cb->sys_kbd) {
665 if (cb->sys_ids) { 665 if (cb->sys_ids) {
666 if (device_id >= 0x10) 666 if (device_id >= 0x10)
667 return DFENUM_OK; 667 return DFENUM_OK;