comparison src/video/directfb/SDL_DirectFB_events.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
38 #include "SDL_DirectFB_video.h" 38 #include "SDL_DirectFB_video.h"
39 #include "SDL_DirectFB_events.h" 39 #include "SDL_DirectFB_events.h"
40 40
41 /* The translation tables from a DirectFB keycode to a SDL keysym */ 41 /* The translation tables from a DirectFB keycode to a SDL keysym */
42 static SDLKey keymap[256]; 42 static SDLKey keymap[256];
43 static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent * ev, 43 static SDL_keysym *DirectFB_TranslateKey(DFBInputEvent * ev,
44 SDL_keysym * keysym); 44 SDL_keysym * keysym);
45 static int DirectFB_TranslateButton (DFBInputEvent * ev); 45 static int DirectFB_TranslateButton(DFBInputEvent * ev);
46 46
47 static int posted = 0; 47 static int posted = 0;
48 48
49 49
50 void 50 void
51 DirectFB_PumpEvents (_THIS) 51 DirectFB_PumpEvents(_THIS)
52 { 52 {
53 DFBInputEvent evt; 53 DFBInputEvent evt;
54 54
55 while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer, 55 while (HIDDEN->eventbuffer->GetEvent(HIDDEN->eventbuffer,
56 DFB_EVENT (&evt)) == DFB_OK) { 56 DFB_EVENT(&evt)) == DFB_OK) {
57 SDL_keysym keysym; 57 SDL_keysym keysym;
58 58
59 switch (evt.type) { 59 switch (evt.type) {
60 case DIET_BUTTONPRESS: 60 case DIET_BUTTONPRESS:
61 posted += SDL_PrivateMouseButton (SDL_PRESSED, 61 posted += SDL_PrivateMouseButton(SDL_PRESSED,
62 DirectFB_TranslateButton 62 DirectFB_TranslateButton
63 (&evt), 0, 0); 63 (&evt), 0, 0);
64 break; 64 break;
65 case DIET_BUTTONRELEASE: 65 case DIET_BUTTONRELEASE:
66 posted += SDL_PrivateMouseButton (SDL_RELEASED, 66 posted += SDL_PrivateMouseButton(SDL_RELEASED,
67 DirectFB_TranslateButton 67 DirectFB_TranslateButton
68 (&evt), 0, 0); 68 (&evt), 0, 0);
69 break; 69 break;
70 case DIET_KEYPRESS: 70 case DIET_KEYPRESS:
71 posted += 71 posted +=
72 SDL_PrivateKeyboard (SDL_PRESSED, 72 SDL_PrivateKeyboard(SDL_PRESSED,
73 DirectFB_TranslateKey (&evt, &keysym)); 73 DirectFB_TranslateKey(&evt, &keysym));
74 break; 74 break;
75 case DIET_KEYRELEASE: 75 case DIET_KEYRELEASE:
76 posted += 76 posted +=
77 SDL_PrivateKeyboard (SDL_RELEASED, 77 SDL_PrivateKeyboard(SDL_RELEASED,
78 DirectFB_TranslateKey (&evt, &keysym)); 78 DirectFB_TranslateKey(&evt, &keysym));
79 break; 79 break;
80 case DIET_AXISMOTION: 80 case DIET_AXISMOTION:
81 if (evt.flags & DIEF_AXISREL) { 81 if (evt.flags & DIEF_AXISREL) {
82 if (evt.axis == DIAI_X) 82 if (evt.axis == DIAI_X)
83 posted += SDL_PrivateMouseMotion (0, 1, evt.axisrel, 0); 83 posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0);
84 else if (evt.axis == DIAI_Y) 84 else if (evt.axis == DIAI_Y)
85 posted += SDL_PrivateMouseMotion (0, 1, 0, evt.axisrel); 85 posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
86 } 86 }
87 break; 87 break;
88 default: 88 default:
89 ; 89 ;
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 void 94 void
95 DirectFB_InitOSKeymap (_THIS) 95 DirectFB_InitOSKeymap(_THIS)
96 { 96 {
97 int i; 97 int i;
98 98
99 /* Initialize the DirectFB key translation table */ 99 /* Initialize the DirectFB key translation table */
100 for (i = 0; i < SDL_arraysize (keymap); ++i) 100 for (i = 0; i < SDL_arraysize(keymap); ++i)
101 keymap[i] = SDLK_UNKNOWN; 101 keymap[i] = SDLK_UNKNOWN;
102 102
103 keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a; 103 keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a;
104 keymap[DIKI_B - DIKI_UNKNOWN] = SDLK_b; 104 keymap[DIKI_B - DIKI_UNKNOWN] = SDLK_b;
105 keymap[DIKI_C - DIKI_UNKNOWN] = SDLK_c; 105 keymap[DIKI_C - DIKI_UNKNOWN] = SDLK_c;
184 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDLK_KP_ENTER; 184 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDLK_KP_ENTER;
185 } 185 }
186 186
187 187
188 static SDL_keysym * 188 static SDL_keysym *
189 DirectFB_TranslateKey (DFBInputEvent * ev, SDL_keysym * keysym) 189 DirectFB_TranslateKey(DFBInputEvent * ev, SDL_keysym * keysym)
190 { 190 {
191 /* Set the keysym information */ 191 /* Set the keysym information */
192 keysym->scancode = ev->key_id; 192 keysym->scancode = ev->key_id;
193 keysym->mod = KMOD_NONE; /* FIXME */ 193 keysym->mod = KMOD_NONE; /* FIXME */
194 keysym->unicode = 194 keysym->unicode =
195 (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0; 195 (DFB_KEY_TYPE(ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0;
196 196
197 if (ev->key_symbol > 0 && ev->key_symbol < 128) 197 if (ev->key_symbol > 0 && ev->key_symbol < 128)
198 keysym->sym = ev->key_symbol; 198 keysym->sym = ev->key_symbol;
199 else 199 else
200 keysym->sym = keymap[ev->key_id - DIKI_UNKNOWN]; 200 keysym->sym = keymap[ev->key_id - DIKI_UNKNOWN];
201 201
202 return keysym; 202 return keysym;
203 } 203 }
204 204
205 static int 205 static int
206 DirectFB_TranslateButton (DFBInputEvent * ev) 206 DirectFB_TranslateButton(DFBInputEvent * ev)
207 { 207 {
208 switch (ev->button) { 208 switch (ev->button) {
209 case DIBI_LEFT: 209 case DIBI_LEFT:
210 return 1; 210 return 1;
211 case DIBI_MIDDLE: 211 case DIBI_MIDDLE: