comparison src/video/directfb/SDL_DirectFB_events.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 14717b52abc0
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
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, SDL_keysym *keysym); 43 static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent * ev,
44 static int DirectFB_TranslateButton (DFBInputEvent *ev); 44 SDL_keysym * keysym);
45 static int DirectFB_TranslateButton (DFBInputEvent * ev);
45 46
46 static int posted = 0; 47 static int posted = 0;
47 48
48 49
49 void DirectFB_PumpEvents (_THIS) 50 void
50 { 51 DirectFB_PumpEvents (_THIS)
51 DFBInputEvent evt; 52 {
52 53 DFBInputEvent evt;
53 while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer, 54
54 DFB_EVENT (&evt)) == DFB_OK) 55 while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer,
55 { 56 DFB_EVENT (&evt)) == DFB_OK) {
56 SDL_keysym keysym; 57 SDL_keysym keysym;
57 58
58 switch (evt.type) 59 switch (evt.type) {
59 {
60 case DIET_BUTTONPRESS: 60 case DIET_BUTTONPRESS:
61 posted += SDL_PrivateMouseButton(SDL_PRESSED, 61 posted += SDL_PrivateMouseButton (SDL_PRESSED,
62 DirectFB_TranslateButton (&evt), 0, 0); 62 DirectFB_TranslateButton
63 break; 63 (&evt), 0, 0);
64 break;
64 case DIET_BUTTONRELEASE: 65 case DIET_BUTTONRELEASE:
65 posted += SDL_PrivateMouseButton(SDL_RELEASED, 66 posted += SDL_PrivateMouseButton (SDL_RELEASED,
66 DirectFB_TranslateButton (&evt), 0, 0); 67 DirectFB_TranslateButton
67 break; 68 (&evt), 0, 0);
69 break;
68 case DIET_KEYPRESS: 70 case DIET_KEYPRESS:
69 posted += SDL_PrivateKeyboard(SDL_PRESSED, DirectFB_TranslateKey(&evt, &keysym)); 71 posted +=
70 break; 72 SDL_PrivateKeyboard (SDL_PRESSED,
73 DirectFB_TranslateKey (&evt, &keysym));
74 break;
71 case DIET_KEYRELEASE: 75 case DIET_KEYRELEASE:
72 posted += SDL_PrivateKeyboard(SDL_RELEASED, DirectFB_TranslateKey(&evt, &keysym)); 76 posted +=
73 break; 77 SDL_PrivateKeyboard (SDL_RELEASED,
78 DirectFB_TranslateKey (&evt, &keysym));
79 break;
74 case DIET_AXISMOTION: 80 case DIET_AXISMOTION:
75 if (evt.flags & DIEF_AXISREL) 81 if (evt.flags & DIEF_AXISREL) {
76 { 82 if (evt.axis == DIAI_X)
77 if (evt.axis == DIAI_X) 83 posted += SDL_PrivateMouseMotion (0, 1, evt.axisrel, 0);
78 posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0); 84 else if (evt.axis == DIAI_Y)
79 else if (evt.axis == DIAI_Y) 85 posted += SDL_PrivateMouseMotion (0, 1, 0, evt.axisrel);
80 posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
81 } 86 }
82 break; 87 break;
83 default: 88 default:
84 ; 89 ;
85 } 90 }
86 } 91 }
87 } 92 }
88 93
89 void DirectFB_InitOSKeymap (_THIS) 94 void
90 { 95 DirectFB_InitOSKeymap (_THIS)
91 int i; 96 {
92 97 int i;
93 /* Initialize the DirectFB key translation table */ 98
94 for (i=0; i<SDL_arraysize(keymap); ++i) 99 /* Initialize the DirectFB key translation table */
95 keymap[i] = SDLK_UNKNOWN; 100 for (i = 0; i < SDL_arraysize (keymap); ++i)
96 101 keymap[i] = SDLK_UNKNOWN;
97 keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a; 102
98 keymap[DIKI_B - DIKI_UNKNOWN] = SDLK_b; 103 keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a;
99 keymap[DIKI_C - DIKI_UNKNOWN] = SDLK_c; 104 keymap[DIKI_B - DIKI_UNKNOWN] = SDLK_b;
100 keymap[DIKI_D - DIKI_UNKNOWN] = SDLK_d; 105 keymap[DIKI_C - DIKI_UNKNOWN] = SDLK_c;
101 keymap[DIKI_E - DIKI_UNKNOWN] = SDLK_e; 106 keymap[DIKI_D - DIKI_UNKNOWN] = SDLK_d;
102 keymap[DIKI_F - DIKI_UNKNOWN] = SDLK_f; 107 keymap[DIKI_E - DIKI_UNKNOWN] = SDLK_e;
103 keymap[DIKI_G - DIKI_UNKNOWN] = SDLK_g; 108 keymap[DIKI_F - DIKI_UNKNOWN] = SDLK_f;
104 keymap[DIKI_H - DIKI_UNKNOWN] = SDLK_h; 109 keymap[DIKI_G - DIKI_UNKNOWN] = SDLK_g;
105 keymap[DIKI_I - DIKI_UNKNOWN] = SDLK_i; 110 keymap[DIKI_H - DIKI_UNKNOWN] = SDLK_h;
106 keymap[DIKI_J - DIKI_UNKNOWN] = SDLK_j; 111 keymap[DIKI_I - DIKI_UNKNOWN] = SDLK_i;
107 keymap[DIKI_K - DIKI_UNKNOWN] = SDLK_k; 112 keymap[DIKI_J - DIKI_UNKNOWN] = SDLK_j;
108 keymap[DIKI_L - DIKI_UNKNOWN] = SDLK_l; 113 keymap[DIKI_K - DIKI_UNKNOWN] = SDLK_k;
109 keymap[DIKI_M - DIKI_UNKNOWN] = SDLK_m; 114 keymap[DIKI_L - DIKI_UNKNOWN] = SDLK_l;
110 keymap[DIKI_N - DIKI_UNKNOWN] = SDLK_n; 115 keymap[DIKI_M - DIKI_UNKNOWN] = SDLK_m;
111 keymap[DIKI_O - DIKI_UNKNOWN] = SDLK_o; 116 keymap[DIKI_N - DIKI_UNKNOWN] = SDLK_n;
112 keymap[DIKI_P - DIKI_UNKNOWN] = SDLK_p; 117 keymap[DIKI_O - DIKI_UNKNOWN] = SDLK_o;
113 keymap[DIKI_Q - DIKI_UNKNOWN] = SDLK_q; 118 keymap[DIKI_P - DIKI_UNKNOWN] = SDLK_p;
114 keymap[DIKI_R - DIKI_UNKNOWN] = SDLK_r; 119 keymap[DIKI_Q - DIKI_UNKNOWN] = SDLK_q;
115 keymap[DIKI_S - DIKI_UNKNOWN] = SDLK_s; 120 keymap[DIKI_R - DIKI_UNKNOWN] = SDLK_r;
116 keymap[DIKI_T - DIKI_UNKNOWN] = SDLK_t; 121 keymap[DIKI_S - DIKI_UNKNOWN] = SDLK_s;
117 keymap[DIKI_U - DIKI_UNKNOWN] = SDLK_u; 122 keymap[DIKI_T - DIKI_UNKNOWN] = SDLK_t;
118 keymap[DIKI_V - DIKI_UNKNOWN] = SDLK_v; 123 keymap[DIKI_U - DIKI_UNKNOWN] = SDLK_u;
119 keymap[DIKI_W - DIKI_UNKNOWN] = SDLK_w; 124 keymap[DIKI_V - DIKI_UNKNOWN] = SDLK_v;
120 keymap[DIKI_X - DIKI_UNKNOWN] = SDLK_x; 125 keymap[DIKI_W - DIKI_UNKNOWN] = SDLK_w;
121 keymap[DIKI_Y - DIKI_UNKNOWN] = SDLK_y; 126 keymap[DIKI_X - DIKI_UNKNOWN] = SDLK_x;
122 keymap[DIKI_Z - DIKI_UNKNOWN] = SDLK_z; 127 keymap[DIKI_Y - DIKI_UNKNOWN] = SDLK_y;
123 128 keymap[DIKI_Z - DIKI_UNKNOWN] = SDLK_z;
124 keymap[DIKI_0 - DIKI_UNKNOWN] = SDLK_0; 129
125 keymap[DIKI_1 - DIKI_UNKNOWN] = SDLK_1; 130 keymap[DIKI_0 - DIKI_UNKNOWN] = SDLK_0;
126 keymap[DIKI_2 - DIKI_UNKNOWN] = SDLK_2; 131 keymap[DIKI_1 - DIKI_UNKNOWN] = SDLK_1;
127 keymap[DIKI_3 - DIKI_UNKNOWN] = SDLK_3; 132 keymap[DIKI_2 - DIKI_UNKNOWN] = SDLK_2;
128 keymap[DIKI_4 - DIKI_UNKNOWN] = SDLK_4; 133 keymap[DIKI_3 - DIKI_UNKNOWN] = SDLK_3;
129 keymap[DIKI_5 - DIKI_UNKNOWN] = SDLK_5; 134 keymap[DIKI_4 - DIKI_UNKNOWN] = SDLK_4;
130 keymap[DIKI_6 - DIKI_UNKNOWN] = SDLK_6; 135 keymap[DIKI_5 - DIKI_UNKNOWN] = SDLK_5;
131 keymap[DIKI_7 - DIKI_UNKNOWN] = SDLK_7; 136 keymap[DIKI_6 - DIKI_UNKNOWN] = SDLK_6;
132 keymap[DIKI_8 - DIKI_UNKNOWN] = SDLK_8; 137 keymap[DIKI_7 - DIKI_UNKNOWN] = SDLK_7;
133 keymap[DIKI_9 - DIKI_UNKNOWN] = SDLK_9; 138 keymap[DIKI_8 - DIKI_UNKNOWN] = SDLK_8;
134 139 keymap[DIKI_9 - DIKI_UNKNOWN] = SDLK_9;
135 keymap[DIKI_F1 - DIKI_UNKNOWN] = SDLK_F1; 140
136 keymap[DIKI_F2 - DIKI_UNKNOWN] = SDLK_F2; 141 keymap[DIKI_F1 - DIKI_UNKNOWN] = SDLK_F1;
137 keymap[DIKI_F3 - DIKI_UNKNOWN] = SDLK_F3; 142 keymap[DIKI_F2 - DIKI_UNKNOWN] = SDLK_F2;
138 keymap[DIKI_F4 - DIKI_UNKNOWN] = SDLK_F4; 143 keymap[DIKI_F3 - DIKI_UNKNOWN] = SDLK_F3;
139 keymap[DIKI_F5 - DIKI_UNKNOWN] = SDLK_F5; 144 keymap[DIKI_F4 - DIKI_UNKNOWN] = SDLK_F4;
140 keymap[DIKI_F6 - DIKI_UNKNOWN] = SDLK_F6; 145 keymap[DIKI_F5 - DIKI_UNKNOWN] = SDLK_F5;
141 keymap[DIKI_F7 - DIKI_UNKNOWN] = SDLK_F7; 146 keymap[DIKI_F6 - DIKI_UNKNOWN] = SDLK_F6;
142 keymap[DIKI_F8 - DIKI_UNKNOWN] = SDLK_F8; 147 keymap[DIKI_F7 - DIKI_UNKNOWN] = SDLK_F7;
143 keymap[DIKI_F9 - DIKI_UNKNOWN] = SDLK_F9; 148 keymap[DIKI_F8 - DIKI_UNKNOWN] = SDLK_F8;
144 keymap[DIKI_F10 - DIKI_UNKNOWN] = SDLK_F10; 149 keymap[DIKI_F9 - DIKI_UNKNOWN] = SDLK_F9;
145 keymap[DIKI_F11 - DIKI_UNKNOWN] = SDLK_F11; 150 keymap[DIKI_F10 - DIKI_UNKNOWN] = SDLK_F10;
146 keymap[DIKI_F12 - DIKI_UNKNOWN] = SDLK_F12; 151 keymap[DIKI_F11 - DIKI_UNKNOWN] = SDLK_F11;
147 152 keymap[DIKI_F12 - DIKI_UNKNOWN] = SDLK_F12;
148 keymap[DIKI_ESCAPE - DIKI_UNKNOWN] = SDLK_ESCAPE; 153
149 keymap[DIKI_LEFT - DIKI_UNKNOWN] = SDLK_LEFT; 154 keymap[DIKI_ESCAPE - DIKI_UNKNOWN] = SDLK_ESCAPE;
150 keymap[DIKI_RIGHT - DIKI_UNKNOWN] = SDLK_RIGHT; 155 keymap[DIKI_LEFT - DIKI_UNKNOWN] = SDLK_LEFT;
151 keymap[DIKI_UP - DIKI_UNKNOWN] = SDLK_UP; 156 keymap[DIKI_RIGHT - DIKI_UNKNOWN] = SDLK_RIGHT;
152 keymap[DIKI_DOWN - DIKI_UNKNOWN] = SDLK_DOWN; 157 keymap[DIKI_UP - DIKI_UNKNOWN] = SDLK_UP;
153 keymap[DIKI_CONTROL_L - DIKI_UNKNOWN] = SDLK_LCTRL; 158 keymap[DIKI_DOWN - DIKI_UNKNOWN] = SDLK_DOWN;
154 keymap[DIKI_CONTROL_R - DIKI_UNKNOWN] = SDLK_RCTRL; 159 keymap[DIKI_CONTROL_L - DIKI_UNKNOWN] = SDLK_LCTRL;
155 keymap[DIKI_SHIFT_L - DIKI_UNKNOWN] = SDLK_LSHIFT; 160 keymap[DIKI_CONTROL_R - DIKI_UNKNOWN] = SDLK_RCTRL;
156 keymap[DIKI_SHIFT_R - DIKI_UNKNOWN] = SDLK_RSHIFT; 161 keymap[DIKI_SHIFT_L - DIKI_UNKNOWN] = SDLK_LSHIFT;
157 keymap[DIKI_ALT_L - DIKI_UNKNOWN] = SDLK_LALT; 162 keymap[DIKI_SHIFT_R - DIKI_UNKNOWN] = SDLK_RSHIFT;
158 keymap[DIKI_ALT_R - DIKI_UNKNOWN] = SDLK_RALT; 163 keymap[DIKI_ALT_L - DIKI_UNKNOWN] = SDLK_LALT;
159 keymap[DIKI_TAB - DIKI_UNKNOWN] = SDLK_TAB; 164 keymap[DIKI_ALT_R - DIKI_UNKNOWN] = SDLK_RALT;
160 keymap[DIKI_ENTER - DIKI_UNKNOWN] = SDLK_RETURN; 165 keymap[DIKI_TAB - DIKI_UNKNOWN] = SDLK_TAB;
161 keymap[DIKI_SPACE - DIKI_UNKNOWN] = SDLK_SPACE; 166 keymap[DIKI_ENTER - DIKI_UNKNOWN] = SDLK_RETURN;
162 keymap[DIKI_BACKSPACE - DIKI_UNKNOWN] = SDLK_BACKSPACE; 167 keymap[DIKI_SPACE - DIKI_UNKNOWN] = SDLK_SPACE;
163 keymap[DIKI_INSERT - DIKI_UNKNOWN] = SDLK_INSERT; 168 keymap[DIKI_BACKSPACE - DIKI_UNKNOWN] = SDLK_BACKSPACE;
164 keymap[DIKI_DELETE - DIKI_UNKNOWN] = SDLK_DELETE; 169 keymap[DIKI_INSERT - DIKI_UNKNOWN] = SDLK_INSERT;
165 keymap[DIKI_HOME - DIKI_UNKNOWN] = SDLK_HOME; 170 keymap[DIKI_DELETE - DIKI_UNKNOWN] = SDLK_DELETE;
166 keymap[DIKI_END - DIKI_UNKNOWN] = SDLK_END; 171 keymap[DIKI_HOME - DIKI_UNKNOWN] = SDLK_HOME;
167 keymap[DIKI_PAGE_UP - DIKI_UNKNOWN] = SDLK_PAGEUP; 172 keymap[DIKI_END - DIKI_UNKNOWN] = SDLK_END;
168 keymap[DIKI_PAGE_DOWN - DIKI_UNKNOWN] = SDLK_PAGEDOWN; 173 keymap[DIKI_PAGE_UP - DIKI_UNKNOWN] = SDLK_PAGEUP;
169 keymap[DIKI_CAPS_LOCK - DIKI_UNKNOWN] = SDLK_CAPSLOCK; 174 keymap[DIKI_PAGE_DOWN - DIKI_UNKNOWN] = SDLK_PAGEDOWN;
170 keymap[DIKI_NUM_LOCK - DIKI_UNKNOWN] = SDLK_NUMLOCK; 175 keymap[DIKI_CAPS_LOCK - DIKI_UNKNOWN] = SDLK_CAPSLOCK;
171 keymap[DIKI_SCROLL_LOCK - DIKI_UNKNOWN] = SDLK_SCROLLOCK; 176 keymap[DIKI_NUM_LOCK - DIKI_UNKNOWN] = SDLK_NUMLOCK;
172 keymap[DIKI_PRINT - DIKI_UNKNOWN] = SDLK_PRINT; 177 keymap[DIKI_SCROLL_LOCK - DIKI_UNKNOWN] = SDLK_SCROLLOCK;
173 keymap[DIKI_PAUSE - DIKI_UNKNOWN] = SDLK_PAUSE; 178 keymap[DIKI_PRINT - DIKI_UNKNOWN] = SDLK_PRINT;
174 keymap[DIKI_KP_DIV - DIKI_UNKNOWN] = SDLK_KP_DIVIDE; 179 keymap[DIKI_PAUSE - DIKI_UNKNOWN] = SDLK_PAUSE;
175 keymap[DIKI_KP_MULT - DIKI_UNKNOWN] = SDLK_KP_MULTIPLY; 180 keymap[DIKI_KP_DIV - DIKI_UNKNOWN] = SDLK_KP_DIVIDE;
176 keymap[DIKI_KP_MINUS - DIKI_UNKNOWN] = SDLK_KP_MINUS; 181 keymap[DIKI_KP_MULT - DIKI_UNKNOWN] = SDLK_KP_MULTIPLY;
177 keymap[DIKI_KP_PLUS - DIKI_UNKNOWN] = SDLK_KP_PLUS; 182 keymap[DIKI_KP_MINUS - DIKI_UNKNOWN] = SDLK_KP_MINUS;
178 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDLK_KP_ENTER; 183 keymap[DIKI_KP_PLUS - DIKI_UNKNOWN] = SDLK_KP_PLUS;
179 } 184 keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDLK_KP_ENTER;
180 185 }
181 186
182 static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent *ev, SDL_keysym *keysym) 187
183 { 188 static SDL_keysym *
184 /* Set the keysym information */ 189 DirectFB_TranslateKey (DFBInputEvent * ev, SDL_keysym * keysym)
185 keysym->scancode = ev->key_id; 190 {
186 keysym->mod = KMOD_NONE; /* FIXME */ 191 /* Set the keysym information */
187 keysym->unicode = (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0; 192 keysym->scancode = ev->key_id;
188 193 keysym->mod = KMOD_NONE; /* FIXME */
189 if (ev->key_symbol > 0 && ev->key_symbol < 128) 194 keysym->unicode =
190 keysym->sym = ev->key_symbol; 195 (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0;
191 else 196
192 keysym->sym = keymap[ev->key_id - DIKI_UNKNOWN]; 197 if (ev->key_symbol > 0 && ev->key_symbol < 128)
193 198 keysym->sym = ev->key_symbol;
194 return keysym; 199 else
195 } 200 keysym->sym = keymap[ev->key_id - DIKI_UNKNOWN];
196 201
197 static int DirectFB_TranslateButton (DFBInputEvent *ev) 202 return keysym;
198 { 203 }
199 switch (ev->button) 204
200 { 205 static int
206 DirectFB_TranslateButton (DFBInputEvent * ev)
207 {
208 switch (ev->button) {
201 case DIBI_LEFT: 209 case DIBI_LEFT:
202 return 1; 210 return 1;
203 case DIBI_MIDDLE: 211 case DIBI_MIDDLE:
204 return 2; 212 return 2;
205 case DIBI_RIGHT: 213 case DIBI_RIGHT:
206 return 3; 214 return 3;
207 default: 215 default:
208 return 0; 216 return 0;
209 } 217 }
210 } 218 }
219
220 /* vi: set ts=4 sw=4 expandtab: */