23 #if SDL_VIDEO_DRIVER_DIRECTFB
33 #include "../../events/SDL_mouse_c.h"
34 #include "../../events/SDL_keyboard_c.h"
35 #include "../../events/SDL_windowevents_c.h"
36 #include "../../events/SDL_events_c.h"
37 #include "../../events/scancodes_linux.h"
38 #include "../../events/scancodes_xfree86.h"
43 #define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, id, relative, x, y, p)
44 #define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(w, id, state, button)
45 #define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(id, state, scancode)
46 #define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(id, text)
48 #define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, id, relative, x, y)
49 #define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(w, id, state, button)
50 #define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(state, scancode)
51 #define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(text)
54 typedef struct _cb_data cb_data;
68 static SDL_Keysym *DirectFB_TranslateKeyInputEvent(
_THIS, DFBInputEvent * evt,
72 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
74 static void UnicodeToUtf8(
Uint16 w ,
char *utf8buf)
76 unsigned char *utf8s = (
unsigned char *) utf8buf;
79 utf8s[0] = (
unsigned char ) w;
82 else if ( w < 0x0800 ) {
83 utf8s[0] = 0xc0 | ((
w ) >> 6 );
84 utf8s[1] = 0x80 | ((
w ) & 0x3f );
88 utf8s[0] = 0xe0 | ((
w ) >> 12 );
89 utf8s[1] = 0x80 | (( (
w ) >> 6 ) & 0x3f );
90 utf8s[2] = 0x80 | ((
w ) & 0x3f );
102 for (index = 0; index < devdata->num_mice; index++)
117 for (index = 0; index < devdata->num_keyboard; index++)
125 MotionAllMice(
_THIS,
int x,
int y)
131 for (index = 0; index < devdata->num_mice; index++) {
141 KbdIndex(
_THIS,
int id)
146 for (index = 0; index < devdata->num_keyboard; index++) {
147 if (devdata->keyboard[index].id ==
id)
164 if (cx < 0 || cy < 0)
182 if (evt->clazz == DFEC_WINDOW) {
184 case DWET_BUTTONDOWN:
185 if (ClientXY(windata, &evt->x, &evt->y)) {
186 if (!devdata->use_linux_input) {
187 SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->
x,
189 SDL_SendMouseButton_ex(sdlwin, devdata->mouse_id[0],
191 DirectFB_TranslateButton
194 MotionAllMice(
_this, evt->x, evt->y);
199 if (ClientXY(windata, &evt->x, &evt->y)) {
200 if (!devdata->use_linux_input) {
201 SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->
x,
203 SDL_SendMouseButton_ex(sdlwin, devdata->mouse_id[0],
205 DirectFB_TranslateButton
208 MotionAllMice(
_this, evt->x, evt->y);
213 if (ClientXY(windata, &evt->x, &evt->y)) {
214 if (!devdata->use_linux_input) {
216 SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0,
223 if (1 && ++cnt > 20) {
224 MotionAllMice(
_this, evt->x, evt->y);
234 if (!devdata->use_linux_input) {
235 DirectFB_TranslateKey(
_this, evt, &keysym, &unicode);
240 UnicodeToUtf8(unicode, text);
242 SDL_SendKeyboardText_ex(0, text);
248 if (!devdata->use_linux_input) {
249 DirectFB_TranslateKey(
_this, evt, &keysym, &unicode);
254 if (ClientXY(windata, &evt->x, &evt->y)) {
259 case DWET_POSITION_SIZE:
260 if (ClientXY(windata, &evt->x, &evt->y)) {
267 evt->w -= (windata->theme.right_size + windata->theme.left_size);
269 (windata->theme.top_size + windata->theme.bottom_size +
270 windata->theme.caption_size);
279 FocusAllKeyboards(
_this, sdlwin);
285 FocusAllKeyboards(
_this, 0);
289 FocusAllMice(
_this, sdlwin);
291 if (ClientXY(windata, &evt->x, &evt->y))
292 MotionAllMice(
_this, evt->x, evt->y);
297 FocusAllMice(
_this, 0);
304 printf(
"Event Clazz %d\n", evt->clazz);
308 ProcessInputEvent(
_THIS, DFBInputEvent * ievt)
316 if (!devdata->use_linux_input) {
317 if (ievt->type == DIET_AXISMOTION) {
318 if ((devdata->grabbed_window !=
NULL) && (ievt->flags & DIEF_AXISREL)) {
319 if (ievt->axis == DIAI_X)
320 SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1,
321 ievt->axisrel, 0, 0);
322 else if (ievt->axis == DIAI_Y)
323 SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0,
328 static int last_x, last_y;
330 switch (ievt->type) {
331 case DIET_AXISMOTION:
332 if (ievt->flags & DIEF_AXISABS) {
333 if (ievt->axis == DIAI_X)
334 last_x = ievt->axisabs;
335 else if (ievt->axis == DIAI_Y)
336 last_y = ievt->axisabs;
337 if (!(ievt->flags & DIEF_FOLLOW)) {
350 SDL_SendMouseMotion_ex(window, ievt->device_id, 0,
356 SDL_SendMouseMotion_ex(window, ievt->device_id, 0, last_x,
360 }
else if (ievt->flags & DIEF_AXISREL) {
361 if (ievt->axis == DIAI_X)
362 SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1,
363 ievt->axisrel, 0, 0);
364 else if (ievt->axis == DIAI_Y)
365 SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0,
370 kbd_idx = KbdIndex(
_this, ievt->device_id);
371 DirectFB_TranslateKeyInputEvent(
_this, ievt, &keysym, &unicode);
376 UnicodeToUtf8(unicode, text);
378 SDL_SendKeyboardText_ex(kbd_idx, text);
382 case DIET_KEYRELEASE:
383 kbd_idx = KbdIndex(
_this, ievt->device_id);
384 DirectFB_TranslateKeyInputEvent(
_this, ievt, &keysym, &unicode);
387 case DIET_BUTTONPRESS:
388 if (ievt->buttons & DIBM_LEFT)
389 SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id,
SDL_PRESSED, 1);
390 if (ievt->buttons & DIBM_MIDDLE)
391 SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id,
SDL_PRESSED, 2);
392 if (ievt->buttons & DIBM_RIGHT)
393 SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id,
SDL_PRESSED, 3);
395 case DIET_BUTTONRELEASE:
396 if (!(ievt->buttons & DIBM_LEFT))
397 SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id,
SDL_RELEASED, 1);
398 if (!(ievt->buttons & DIBM_MIDDLE))
399 SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id,
SDL_RELEASED, 2);
400 if (!(ievt->buttons & DIBM_RIGHT))
401 SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id,
SDL_RELEASED, 3);
416 for (w = devdata->firstwin; w !=
NULL; w = w->
next) {
420 while (windata->eventbuffer->GetEvent(windata->eventbuffer,
421 DFB_EVENT(&evt)) == DFB_OK) {
428 wmmsg.
msg.dfb.event.window = evt;
431 ProcessWindowEvent(
_this, w, &evt);
437 while (devdata->events->GetEvent(devdata->events,
438 DFB_EVENT(&ievt)) == DFB_OK) {
444 wmmsg.
msg.dfb.event.input = ievt;
447 ProcessInputEvent(
_this, &ievt);
457 for (i = 0; i < numkeys; ++
i)
593 devdata->keyboard[kbd_idx].is_generic) {
595 keysym->
scancode = oskeymap[evt->key_id - DIKI_UNKNOWN];
601 (DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
603 (evt->key_symbol > 0 && evt->key_symbol < 255))
604 *unicode = evt->key_symbol;
610 DirectFB_TranslateKeyInputEvent(
_THIS, DFBInputEvent * evt,
614 int kbd_idx = KbdIndex(
_this, evt->device_id);
625 keysym->
scancode = oskeymap[evt->key_id - DIKI_UNKNOWN];
631 (DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
633 (evt->key_symbol > 0 && evt->key_symbol < 255))
634 *unicode = evt->key_symbol;
640 DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button)
654 static DFBEnumerationResult
655 EnumKeyboards(DFBInputDeviceID device_id,
656 DFBInputDeviceDescription desc,
void *callbackdata)
658 cb_data *cb = callbackdata;
667 if (device_id >= 0x10)
670 if (device_id < 0x10)
674 if (device_id != DIDID_KEYBOARD)
678 if ((desc.caps & DIDTF_KEYBOARD)) {
685 if (!strncmp(
"X11", desc.name, 3))
696 SDL_DFB_LOG(
"Keyboard %d - %s\n", device_id, desc.name);
707 return DFENUM_CANCEL;
721 cb.devdata = devdata;
727 EnumInputDevices(devdata->
dfb, EnumKeyboards, &cb));
void SDL_GetDefaultKeymap(SDL_Keycode *keymap)
SDL_Mouse * SDL_GetMouse(void)
#define SDL_DFB_LOG(x...)
void SDL_SetKeyboardFocus(SDL_Window *window)
int DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent *evt)
struct SDL_Keyboard SDL_Keyboard
void DirectFB_SetContext(_THIS, SDL_Window *window)
static const SDL_Scancode xfree86_scancode_table2[]
The SDL keysym structure, used in key events.
DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state)
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
void SDL_SetMouseFocus(SDL_Window *window)
Sint32 SDL_Keycode
The SDL virtual key representation.
int SDL_SendSysWMEvent(SDL_SysWMmsg *message)
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
static SDL_VideoDevice * _this
uint32_t Uint32
An unsigned 32-bit integer type.
void SDL_SetKeymap(int start, SDL_Keycode *keys, int length)
#define SDL_DFB_DEVICEDATA(dev)
#define SDL_GetEventState(type)
DFB_KeyboardData keyboard[10]
void DirectFB_QuitKeyboard(_THIS)
DECLSPEC SDL_Window *SDLCALL SDL_GetWindowFromID(Uint32 id)
Get a window from a stored ID, or NULL if it doesn't exist.
void DirectFB_InitKeyboard(_THIS)
union SDL_SysWMmsg::@77 msg
void SDL_KeyboardQuit(void)
void DirectFB_PumpEventsWindow(_THIS)
EGLSurface EGLint EGLint y
#define SDL_arraysize(array)
static SDL_Scancode const linux_scancode_table[]
#define SDL_DFB_WINDOWDATA(win)
#define SDL_DFB_CHECK(x...)
GLint GLint GLint GLint GLint w
uint16_t Uint16
An unsigned 16-bit integer type.
#define SDL_TEXTINPUTEVENT_TEXT_SIZE
SDL_Scancode
The SDL keyboard scancode representation.