src/video/directfb/SDL_DirectFB_events.c
author Bob Pendleton <bob@pendleton.com>
Fri, 09 Jan 2009 20:43:30 +0000
changeset 3011 8f4ed5ec2b06
parent 2998 d364ee9b9c15
child 3013 8cc00819c8d6
permissions -rw-r--r--
I ran a global "make indent" it modified the following files.
slouken@167
     1
/*
slouken@1312
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@167
     4
slouken@1312
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1312
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@167
     9
slouken@1312
    10
    This library is distributed in the hope that it will be useful,
slouken@1312
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1312
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@167
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@167
    18
slouken@1312
    19
    Sam Lantinga
slouken@1312
    20
    slouken@libsdl.org
slouken@167
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@167
    23
slouken@167
    24
/* Handle the event stream, converting DirectFB input events into SDL events */
slouken@167
    25
slouken@167
    26
#include <directfb.h>
slouken@167
    27
slouken@1361
    28
#include "../SDL_sysvideo.h"
slouken@1361
    29
#include "../../events/SDL_sysevents.h"
slouken@1361
    30
#include "../../events/SDL_events_c.h"
slouken@2721
    31
#include "../../events/SDL_keyboard_c.h"
slouken@2721
    32
#include "../../events/scancodes_linux.h"
slouken@167
    33
#include "SDL_DirectFB_events.h"
slouken@167
    34
slouken@167
    35
/* The translation tables from a DirectFB keycode to a SDL keysym */
slouken@2860
    36
static SDLKey oskeymap[256];
slouken@2860
    37
static int sys_ids;
slouken@2226
    38
slouken@2721
    39
static SDL_keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
slouken@1895
    40
                                         SDL_keysym * keysym);
slouken@2860
    41
static SDL_keysym *DirectFB_TranslateKeyInputEvent(_THIS, int index,
slouken@2860
    42
                                                   DFBInputEvent * evt,
slouken@2860
    43
                                                   SDL_keysym * keysym);
slouken@167
    44
slouken@2860
    45
static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys);
slouken@2226
    46
static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
slouken@167
    47
slouken@2721
    48
static void
slouken@2721
    49
DirectFB_SetContext(_THIS, SDL_WindowID id)
slouken@2721
    50
{
slouken@2721
    51
#if (DIRECTFB_MAJOR_VERSION >= 1)
slouken@2721
    52
    /* FIXME: does not work on 1.0/1.2 with radeon driver
slouken@2721
    53
     *        the approach did work with the matrox driver
slouken@2737
    54
     *        This has simply no effect.
slouken@2721
    55
     */
slouken@2721
    56
slouken@2737
    57
    SDL_Window *window = SDL_GetWindowFromID(id);
slouken@2737
    58
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
slouken@2737
    59
    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
slouken@2737
    60
    int ret;
slouken@2737
    61
slouken@2737
    62
    if (dispdata->vidIDinuse)
bob@3011
    63
        SDL_DFB_CHECKERR(dispdata->
bob@3011
    64
                         vidlayer->SwitchContext(dispdata->vidlayer,
bob@3011
    65
                                                 DFB_TRUE));
slouken@2737
    66
slouken@2737
    67
  error:
slouken@2737
    68
    return;
slouken@2721
    69
#endif
slouken@2721
    70
slouken@2721
    71
}
slouken@2721
    72
slouken@2860
    73
static void
slouken@2860
    74
FocusAllMice(_THIS, SDL_WindowID id)
slouken@2860
    75
{
slouken@2860
    76
    SDL_DFB_DEVICEDATA(_this);
slouken@2860
    77
    int index;
slouken@2860
    78
slouken@2860
    79
    for (index = 0; index < devdata->num_mice; index++)
slouken@2860
    80
        SDL_SetMouseFocus(devdata->mouse_id[index], id);
slouken@2860
    81
}
slouken@2860
    82
slouken@2860
    83
slouken@2860
    84
static void
slouken@2860
    85
FocusAllKeyboards(_THIS, SDL_WindowID id)
slouken@2860
    86
{
slouken@2860
    87
    SDL_DFB_DEVICEDATA(_this);
slouken@2860
    88
    int index;
slouken@2860
    89
slouken@2860
    90
    for (index = 0; index < devdata->num_keyboard; index++)
slouken@2860
    91
        SDL_SetKeyboardFocus(index, id);
slouken@2860
    92
}
slouken@2860
    93
slouken@2860
    94
static void
slouken@2860
    95
MotionAllMice(_THIS, int x, int y)
slouken@2860
    96
{
slouken@2860
    97
    SDL_DFB_DEVICEDATA(_this);
slouken@2860
    98
    int index;
slouken@2860
    99
slouken@2860
   100
    for (index = 0; index < devdata->num_mice; index++) {
slouken@2860
   101
        SDL_Mouse *mouse = SDL_GetMouse(index);
slouken@2860
   102
        mouse->x = mouse->last_x = x;
slouken@2860
   103
        mouse->y = mouse->last_y = y;
slouken@2860
   104
        //SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0);
slouken@2860
   105
    }
slouken@2860
   106
}
slouken@2860
   107
slouken@2860
   108
static int
slouken@2860
   109
KbdIndex(_THIS, int id)
slouken@2860
   110
{
slouken@2860
   111
    SDL_DFB_DEVICEDATA(_this);
slouken@2860
   112
    int index;
slouken@2860
   113
slouken@2860
   114
    for (index = 0; index < devdata->num_keyboard; index++) {
slouken@2860
   115
        if (devdata->keyboard[index].id == id)
slouken@2860
   116
            return index;
slouken@2860
   117
    }
slouken@2860
   118
    return -1;
slouken@2860
   119
}
slouken@2860
   120
slouken@1895
   121
void
slouken@2226
   122
DirectFB_PumpEventsWindow(_THIS)
slouken@167
   123
{
slouken@2226
   124
    SDL_DFB_DEVICEDATA(_this);
slouken@2226
   125
    DFB_WindowData *p;
slouken@2737
   126
    DFBInputEvent ievt;
slouken@2860
   127
    Sint32 /* SDL_WindowID */ grabbed_window;
slouken@2721
   128
    char text[5];
slouken@2860
   129
    int kbd_idx;
slouken@167
   130
slouken@2737
   131
    grabbed_window = -1;
slouken@2737
   132
slouken@2226
   133
    for (p = devdata->firstwin; p != NULL; p = p->next) {
slouken@2860
   134
        DFBWindowEvent evt;
slouken@2737
   135
        SDL_Window *w = SDL_GetWindowFromID(p->id);
slouken@2737
   136
slouken@2737
   137
        if (w->flags & SDL_WINDOW_INPUT_GRABBED) {
slouken@2737
   138
            grabbed_window = p->id;
slouken@2737
   139
        }
slouken@2737
   140
slouken@2226
   141
        while (p->eventbuffer->GetEvent(p->eventbuffer,
slouken@2226
   142
                                        DFB_EVENT(&evt)) == DFB_OK) {
slouken@2226
   143
            SDL_keysym keysym;
slouken@167
   144
slouken@2737
   145
            if (evt.clazz == DFEC_WINDOW) {
slouken@2226
   146
                switch (evt.type) {
slouken@2226
   147
                case DWET_BUTTONDOWN:
slouken@2998
   148
                    if (!devdata->use_linux_input) {
slouken@2860
   149
                        SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx,
slouken@2860
   150
                                            evt.cy, 0);
slouken@2860
   151
                        SDL_SendMouseButton(devdata->mouse_id[0], SDL_PRESSED,
bob@3011
   152
                                            DirectFB_TranslateButton
bob@3011
   153
                                            (evt.button));
slouken@2860
   154
                    } else {
slouken@2860
   155
                        MotionAllMice(_this, evt.x, evt.y);
slouken@2860
   156
                    }
slouken@2226
   157
                    break;
slouken@2226
   158
                case DWET_BUTTONUP:
slouken@2998
   159
                    if (!devdata->use_linux_input) {
slouken@2860
   160
                        SDL_SendMouseMotion(devdata->mouse_id[0], 0, evt.cx,
slouken@2860
   161
                                            evt.cy, 0);
slouken@2860
   162
                        SDL_SendMouseButton(devdata->mouse_id[0],
slouken@2860
   163
                                            SDL_RELEASED,
bob@3011
   164
                                            DirectFB_TranslateButton
bob@3011
   165
                                            (evt.button));
slouken@2860
   166
                    } else {
slouken@2860
   167
                        MotionAllMice(_this, evt.x, evt.y);
slouken@2860
   168
                    }
slouken@2226
   169
                    break;
slouken@2226
   170
                case DWET_MOTION:
slouken@2998
   171
                    if (!devdata->use_linux_input) {
slouken@2860
   172
                        if (!(w->flags & SDL_WINDOW_INPUT_GRABBED))
slouken@2860
   173
                            SDL_SendMouseMotion(devdata->mouse_id[0], 0,
slouken@2860
   174
                                                evt.cx, evt.cy, 0);
slouken@2860
   175
                    } else {
slouken@2860
   176
                        /* relative movements are not exact! 
slouken@2860
   177
                         * This code should limit the number of events sent.
slouken@2860
   178
                         * However it kills MAME axis recognition ... */
slouken@2860
   179
                        static int cnt = 0;
slouken@2860
   180
                        if (1 && ++cnt > 20) {
slouken@2860
   181
                            MotionAllMice(_this, evt.x, evt.y);
slouken@2860
   182
                            cnt = 0;
slouken@2860
   183
                        }
slouken@2860
   184
                    }
slouken@2226
   185
                    break;
slouken@2226
   186
                case DWET_KEYDOWN:
slouken@2998
   187
                    if (!devdata->use_linux_input) {
slouken@2860
   188
                        DirectFB_TranslateKey(_this, &evt, &keysym);
slouken@2860
   189
                        SDL_SendKeyboardKey(0, SDL_PRESSED, keysym.scancode);
slouken@2860
   190
                        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
slouken@2860
   191
                            SDL_memcpy(text, &keysym.unicode, 4);
slouken@2860
   192
                            text[4] = 0;
slouken@2860
   193
                            if (*text) {
slouken@2860
   194
                                SDL_SendKeyboardText(0, text);
slouken@2860
   195
                            }
slouken@2721
   196
                        }
slouken@2721
   197
                    }
slouken@2226
   198
                    break;
slouken@2226
   199
                case DWET_KEYUP:
slouken@2998
   200
                    if (!devdata->use_linux_input) {
slouken@2860
   201
                        DirectFB_TranslateKey(_this, &evt, &keysym);
slouken@2860
   202
                        SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode);
slouken@2860
   203
                    }
slouken@2226
   204
                    break;
slouken@2226
   205
                case DWET_POSITION_SIZE:
slouken@2737
   206
                    if (evt.x != w->x || evt.y != w->y)
slouken@2737
   207
                        SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_MOVED,
slouken@2737
   208
                                            evt.x, evt.y);
slouken@2737
   209
                    if (evt.w != w->w || evt.h != w->h)
slouken@2737
   210
                        SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_RESIZED,
slouken@2737
   211
                                            evt.w, evt.h);
slouken@2226
   212
                    break;
slouken@2226
   213
                case DWET_POSITION:
slouken@2737
   214
                    if (evt.x != w->x || evt.y != w->y)
slouken@2737
   215
                        SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_MOVED,
slouken@2737
   216
                                            evt.x, evt.y);
slouken@2226
   217
                    break;
slouken@2226
   218
                case DWET_SIZE:
slouken@2737
   219
                    if (evt.w != w->w || evt.h != w->h)
slouken@2737
   220
                        SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_RESIZED,
slouken@2737
   221
                                            evt.w, evt.h);
slouken@2226
   222
                    break;
slouken@2226
   223
                case DWET_CLOSE:
slouken@2226
   224
                    SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_CLOSE, 0, 0);
slouken@2226
   225
                    break;
slouken@2226
   226
                case DWET_GOTFOCUS:
slouken@2721
   227
                    DirectFB_SetContext(_this, p->id);
slouken@2860
   228
                    FocusAllKeyboards(_this, p->id);
slouken@2721
   229
                    SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_FOCUS_GAINED,
slouken@2721
   230
                                        0, 0);
slouken@2226
   231
                    break;
slouken@2226
   232
                case DWET_LOSTFOCUS:
slouken@2721
   233
                    SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_FOCUS_LOST, 0,
slouken@2721
   234
                                        0);
slouken@2860
   235
                    FocusAllKeyboards(_this, 0);
slouken@2226
   236
                    break;
slouken@2226
   237
                case DWET_ENTER:
slouken@2737
   238
                    /* SDL_DirectFB_ReshowCursor(_this, 0); */
slouken@2860
   239
                    FocusAllMice(_this, p->id);
slouken@2860
   240
                    MotionAllMice(_this, evt.x, evt.y);
slouken@2721
   241
                    SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_ENTER, 0, 0);
slouken@2226
   242
                    break;
slouken@2226
   243
                case DWET_LEAVE:
slouken@2721
   244
                    SDL_SendWindowEvent(p->id, SDL_WINDOWEVENT_LEAVE, 0, 0);
slouken@2860
   245
                    FocusAllMice(_this, 0);
slouken@2737
   246
                    /* SDL_DirectFB_ReshowCursor(_this, 1); */
slouken@2226
   247
                    break;
slouken@2226
   248
                default:
slouken@2226
   249
                    ;
slouken@2226
   250
                }
slouken@2737
   251
            } else
slouken@2737
   252
                printf("Event Clazz %d\n", evt.clazz);
slouken@2737
   253
slouken@2737
   254
        }
slouken@2737
   255
    }
slouken@2737
   256
slouken@2737
   257
    /* Now get relative events in case we need them */
slouken@2737
   258
    while (devdata->events->GetEvent(devdata->events,
slouken@2737
   259
                                     DFB_EVENT(&ievt)) == DFB_OK) {
slouken@2860
   260
        SDL_keysym keysym;
slouken@2860
   261
slouken@2860
   262
        switch (ievt.type) {
slouken@2860
   263
        case DIET_AXISMOTION:
slouken@2998
   264
            if (!devdata->use_linux_input) {
slouken@2860
   265
                if ((grabbed_window >= 0) && (ievt.flags & DIEF_AXISREL)) {
slouken@2860
   266
                    printf("rel devid %d\n", ievt.device_id);
slouken@2860
   267
                    if (ievt.axis == DIAI_X)
slouken@2860
   268
                        SDL_SendMouseMotion(ievt.device_id, 1, ievt.axisrel,
slouken@2860
   269
                                            0, 0);
slouken@2860
   270
                    else if (ievt.axis == DIAI_Y)
slouken@2860
   271
                        SDL_SendMouseMotion(ievt.device_id, 1, 0,
slouken@2860
   272
                                            ievt.axisrel, 0);
slouken@2860
   273
                }
slouken@2860
   274
            }
slouken@2860
   275
            break;
slouken@2860
   276
        }
slouken@2998
   277
        if (devdata->use_linux_input) {
slouken@2860
   278
            IDirectFBInputDevice *idev;
slouken@2860
   279
            static int last_x, last_y;
slouken@2860
   280
slouken@2737
   281
            switch (ievt.type) {
slouken@2737
   282
            case DIET_AXISMOTION:
slouken@2860
   283
                if (ievt.flags & DIEF_AXISABS) {
slouken@2737
   284
                    if (ievt.axis == DIAI_X)
slouken@2860
   285
                        last_x = ievt.axisabs;
slouken@2860
   286
                    else if (ievt.axis == DIAI_Y)
slouken@2860
   287
                        last_y = ievt.axisabs;
slouken@2860
   288
                    if (!(ievt.flags & DIEF_FOLLOW))
slouken@2860
   289
                        SDL_SendMouseMotion(ievt.device_id, 0, last_x, last_y,
slouken@2860
   290
                                            0);
slouken@2860
   291
                } else if (ievt.flags & DIEF_AXISREL) {
slouken@2860
   292
                    //printf("rel %d %d\n", ievt.device_id, ievt.axisrel);
slouken@2860
   293
                    if (ievt.axis == DIAI_X)
slouken@2860
   294
                        SDL_SendMouseMotion(ievt.device_id, 1, ievt.axisrel,
slouken@2737
   295
                                            0, 0);
slouken@2737
   296
                    else if (ievt.axis == DIAI_Y)
slouken@2860
   297
                        SDL_SendMouseMotion(ievt.device_id, 1, 0,
slouken@2737
   298
                                            ievt.axisrel, 0);
slouken@2737
   299
                }
slouken@2737
   300
                break;
slouken@2860
   301
            case DIET_KEYPRESS:
slouken@2860
   302
                kbd_idx = KbdIndex(_this, ievt.device_id);
slouken@2860
   303
                DirectFB_TranslateKeyInputEvent(_this, kbd_idx, &ievt,
slouken@2860
   304
                                                &keysym);
slouken@2860
   305
                SDL_SendKeyboardKey(kbd_idx, SDL_PRESSED, keysym.scancode);
slouken@2860
   306
                if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
slouken@2860
   307
                    SDL_memcpy(text, &keysym.unicode, 4);
slouken@2860
   308
                    text[4] = 0;
slouken@2860
   309
                    if (*text) {
slouken@2860
   310
                        SDL_SendKeyboardText(kbd_idx, text);
slouken@2860
   311
                    }
slouken@2860
   312
                }
slouken@2860
   313
                break;
slouken@2860
   314
            case DIET_KEYRELEASE:
slouken@2860
   315
                kbd_idx = KbdIndex(_this, ievt.device_id);
slouken@2860
   316
                DirectFB_TranslateKeyInputEvent(_this, kbd_idx, &ievt,
slouken@2860
   317
                                                &keysym);
slouken@2860
   318
                SDL_SendKeyboardKey(kbd_idx, SDL_RELEASED, keysym.scancode);
slouken@2860
   319
                break;
slouken@2860
   320
            case DIET_BUTTONPRESS:
slouken@2860
   321
                if (ievt.buttons & DIBM_LEFT)
slouken@2860
   322
                    SDL_SendMouseButton(ievt.device_id, SDL_PRESSED, 1);
slouken@2860
   323
                if (ievt.buttons & DIBM_MIDDLE)
slouken@2860
   324
                    SDL_SendMouseButton(ievt.device_id, SDL_PRESSED, 2);
slouken@2860
   325
                if (ievt.buttons & DIBM_RIGHT)
slouken@2860
   326
                    SDL_SendMouseButton(ievt.device_id, SDL_PRESSED, 3);
slouken@2860
   327
                break;
slouken@2860
   328
            case DIET_BUTTONRELEASE:
slouken@2860
   329
                if (!(ievt.buttons & DIBM_LEFT))
slouken@2860
   330
                    SDL_SendMouseButton(ievt.device_id, SDL_RELEASED, 1);
slouken@2860
   331
                if (!(ievt.buttons & DIBM_MIDDLE))
slouken@2860
   332
                    SDL_SendMouseButton(ievt.device_id, SDL_RELEASED, 2);
slouken@2860
   333
                if (!(ievt.buttons & DIBM_RIGHT))
slouken@2860
   334
                    SDL_SendMouseButton(ievt.device_id, SDL_RELEASED, 3);
slouken@2860
   335
                break;
slouken@167
   336
            }
slouken@167
   337
        }
slouken@167
   338
    }
slouken@167
   339
}
slouken@167
   340
slouken@1895
   341
void
slouken@2860
   342
DirectFB_InitOSKeymap(_THIS, SDLKey * keymap, int numkeys)
slouken@167
   343
{
slouken@1895
   344
    int i;
slouken@167
   345
slouken@1895
   346
    /* Initialize the DirectFB key translation table */
slouken@2860
   347
    for (i = 0; i < numkeys; ++i)
slouken@2721
   348
        keymap[i] = SDL_SCANCODE_UNKNOWN;
slouken@1895
   349
slouken@2721
   350
    keymap[DIKI_A - DIKI_UNKNOWN] = SDL_SCANCODE_A;
slouken@2721
   351
    keymap[DIKI_B - DIKI_UNKNOWN] = SDL_SCANCODE_B;
slouken@2721
   352
    keymap[DIKI_C - DIKI_UNKNOWN] = SDL_SCANCODE_C;
slouken@2721
   353
    keymap[DIKI_D - DIKI_UNKNOWN] = SDL_SCANCODE_D;
slouken@2721
   354
    keymap[DIKI_E - DIKI_UNKNOWN] = SDL_SCANCODE_E;
slouken@2721
   355
    keymap[DIKI_F - DIKI_UNKNOWN] = SDL_SCANCODE_F;
slouken@2721
   356
    keymap[DIKI_G - DIKI_UNKNOWN] = SDL_SCANCODE_G;
slouken@2721
   357
    keymap[DIKI_H - DIKI_UNKNOWN] = SDL_SCANCODE_H;
slouken@2721
   358
    keymap[DIKI_I - DIKI_UNKNOWN] = SDL_SCANCODE_I;
slouken@2721
   359
    keymap[DIKI_J - DIKI_UNKNOWN] = SDL_SCANCODE_J;
slouken@2721
   360
    keymap[DIKI_K - DIKI_UNKNOWN] = SDL_SCANCODE_K;
slouken@2721
   361
    keymap[DIKI_L - DIKI_UNKNOWN] = SDL_SCANCODE_L;
slouken@2721
   362
    keymap[DIKI_M - DIKI_UNKNOWN] = SDL_SCANCODE_M;
slouken@2721
   363
    keymap[DIKI_N - DIKI_UNKNOWN] = SDL_SCANCODE_N;
slouken@2721
   364
    keymap[DIKI_O - DIKI_UNKNOWN] = SDL_SCANCODE_O;
slouken@2721
   365
    keymap[DIKI_P - DIKI_UNKNOWN] = SDL_SCANCODE_P;
slouken@2721
   366
    keymap[DIKI_Q - DIKI_UNKNOWN] = SDL_SCANCODE_Q;
slouken@2721
   367
    keymap[DIKI_R - DIKI_UNKNOWN] = SDL_SCANCODE_R;
slouken@2721
   368
    keymap[DIKI_S - DIKI_UNKNOWN] = SDL_SCANCODE_S;
slouken@2721
   369
    keymap[DIKI_T - DIKI_UNKNOWN] = SDL_SCANCODE_T;
slouken@2721
   370
    keymap[DIKI_U - DIKI_UNKNOWN] = SDL_SCANCODE_U;
slouken@2721
   371
    keymap[DIKI_V - DIKI_UNKNOWN] = SDL_SCANCODE_V;
slouken@2721
   372
    keymap[DIKI_W - DIKI_UNKNOWN] = SDL_SCANCODE_W;
slouken@2721
   373
    keymap[DIKI_X - DIKI_UNKNOWN] = SDL_SCANCODE_X;
slouken@2721
   374
    keymap[DIKI_Y - DIKI_UNKNOWN] = SDL_SCANCODE_Y;
slouken@2721
   375
    keymap[DIKI_Z - DIKI_UNKNOWN] = SDL_SCANCODE_Z;
slouken@1895
   376
slouken@2721
   377
    keymap[DIKI_0 - DIKI_UNKNOWN] = SDL_SCANCODE_0;
slouken@2721
   378
    keymap[DIKI_1 - DIKI_UNKNOWN] = SDL_SCANCODE_1;
slouken@2721
   379
    keymap[DIKI_2 - DIKI_UNKNOWN] = SDL_SCANCODE_2;
slouken@2721
   380
    keymap[DIKI_3 - DIKI_UNKNOWN] = SDL_SCANCODE_3;
slouken@2721
   381
    keymap[DIKI_4 - DIKI_UNKNOWN] = SDL_SCANCODE_4;
slouken@2721
   382
    keymap[DIKI_5 - DIKI_UNKNOWN] = SDL_SCANCODE_5;
slouken@2721
   383
    keymap[DIKI_6 - DIKI_UNKNOWN] = SDL_SCANCODE_6;
slouken@2721
   384
    keymap[DIKI_7 - DIKI_UNKNOWN] = SDL_SCANCODE_7;
slouken@2721
   385
    keymap[DIKI_8 - DIKI_UNKNOWN] = SDL_SCANCODE_8;
slouken@2721
   386
    keymap[DIKI_9 - DIKI_UNKNOWN] = SDL_SCANCODE_9;
slouken@1895
   387
slouken@2721
   388
    keymap[DIKI_F1 - DIKI_UNKNOWN] = SDL_SCANCODE_F1;
slouken@2721
   389
    keymap[DIKI_F2 - DIKI_UNKNOWN] = SDL_SCANCODE_F2;
slouken@2721
   390
    keymap[DIKI_F3 - DIKI_UNKNOWN] = SDL_SCANCODE_F3;
slouken@2721
   391
    keymap[DIKI_F4 - DIKI_UNKNOWN] = SDL_SCANCODE_F4;
slouken@2721
   392
    keymap[DIKI_F5 - DIKI_UNKNOWN] = SDL_SCANCODE_F5;
slouken@2721
   393
    keymap[DIKI_F6 - DIKI_UNKNOWN] = SDL_SCANCODE_F6;
slouken@2721
   394
    keymap[DIKI_F7 - DIKI_UNKNOWN] = SDL_SCANCODE_F7;
slouken@2721
   395
    keymap[DIKI_F8 - DIKI_UNKNOWN] = SDL_SCANCODE_F8;
slouken@2721
   396
    keymap[DIKI_F9 - DIKI_UNKNOWN] = SDL_SCANCODE_F9;
slouken@2721
   397
    keymap[DIKI_F10 - DIKI_UNKNOWN] = SDL_SCANCODE_F10;
slouken@2721
   398
    keymap[DIKI_F11 - DIKI_UNKNOWN] = SDL_SCANCODE_F11;
slouken@2721
   399
    keymap[DIKI_F12 - DIKI_UNKNOWN] = SDL_SCANCODE_F12;
slouken@1895
   400
slouken@2721
   401
    keymap[DIKI_ESCAPE - DIKI_UNKNOWN] = SDL_SCANCODE_ESCAPE;
slouken@2721
   402
    keymap[DIKI_LEFT - DIKI_UNKNOWN] = SDL_SCANCODE_LEFT;
slouken@2721
   403
    keymap[DIKI_RIGHT - DIKI_UNKNOWN] = SDL_SCANCODE_RIGHT;
slouken@2721
   404
    keymap[DIKI_UP - DIKI_UNKNOWN] = SDL_SCANCODE_UP;
slouken@2721
   405
    keymap[DIKI_DOWN - DIKI_UNKNOWN] = SDL_SCANCODE_DOWN;
slouken@2721
   406
    keymap[DIKI_CONTROL_L - DIKI_UNKNOWN] = SDL_SCANCODE_LCTRL;
slouken@2721
   407
    keymap[DIKI_CONTROL_R - DIKI_UNKNOWN] = SDL_SCANCODE_RCTRL;
slouken@2721
   408
    keymap[DIKI_SHIFT_L - DIKI_UNKNOWN] = SDL_SCANCODE_LSHIFT;
slouken@2721
   409
    keymap[DIKI_SHIFT_R - DIKI_UNKNOWN] = SDL_SCANCODE_RSHIFT;
slouken@2721
   410
    keymap[DIKI_ALT_L - DIKI_UNKNOWN] = SDL_SCANCODE_LALT;
slouken@2721
   411
    keymap[DIKI_ALT_R - DIKI_UNKNOWN] = SDL_SCANCODE_RALT;
slouken@2721
   412
    keymap[DIKI_META_L - DIKI_UNKNOWN] = SDL_SCANCODE_LGUI;
slouken@2721
   413
    keymap[DIKI_META_R - DIKI_UNKNOWN] = SDL_SCANCODE_RGUI;
slouken@2721
   414
    keymap[DIKI_SUPER_L - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
slouken@2721
   415
    keymap[DIKI_SUPER_R - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
slouken@2737
   416
    /* FIXME:Do we read hyper keys ?
slouken@2737
   417
     * keymap[DIKI_HYPER_L - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
slouken@2737
   418
     * keymap[DIKI_HYPER_R - DIKI_UNKNOWN] = SDL_SCANCODE_APPLICATION;
slouken@2737
   419
     */
slouken@2721
   420
    keymap[DIKI_TAB - DIKI_UNKNOWN] = SDL_SCANCODE_TAB;
slouken@2721
   421
    keymap[DIKI_ENTER - DIKI_UNKNOWN] = SDL_SCANCODE_RETURN;
slouken@2721
   422
    keymap[DIKI_SPACE - DIKI_UNKNOWN] = SDL_SCANCODE_SPACE;
slouken@2721
   423
    keymap[DIKI_BACKSPACE - DIKI_UNKNOWN] = SDL_SCANCODE_BACKSPACE;
slouken@2721
   424
    keymap[DIKI_INSERT - DIKI_UNKNOWN] = SDL_SCANCODE_INSERT;
slouken@2721
   425
    keymap[DIKI_DELETE - DIKI_UNKNOWN] = SDL_SCANCODE_DELETE;
slouken@2721
   426
    keymap[DIKI_HOME - DIKI_UNKNOWN] = SDL_SCANCODE_HOME;
slouken@2721
   427
    keymap[DIKI_END - DIKI_UNKNOWN] = SDL_SCANCODE_END;
slouken@2721
   428
    keymap[DIKI_PAGE_UP - DIKI_UNKNOWN] = SDL_SCANCODE_PAGEUP;
slouken@2721
   429
    keymap[DIKI_PAGE_DOWN - DIKI_UNKNOWN] = SDL_SCANCODE_PAGEDOWN;
slouken@2721
   430
    keymap[DIKI_CAPS_LOCK - DIKI_UNKNOWN] = SDL_SCANCODE_CAPSLOCK;
slouken@2721
   431
    keymap[DIKI_NUM_LOCK - DIKI_UNKNOWN] = SDL_SCANCODE_NUMLOCKCLEAR;
slouken@2721
   432
    keymap[DIKI_SCROLL_LOCK - DIKI_UNKNOWN] = SDL_SCANCODE_SCROLLLOCK;
slouken@2721
   433
    keymap[DIKI_PRINT - DIKI_UNKNOWN] = SDL_SCANCODE_PRINTSCREEN;
slouken@2721
   434
    keymap[DIKI_PAUSE - DIKI_UNKNOWN] = SDL_SCANCODE_PAUSE;
slouken@2226
   435
slouken@2721
   436
    keymap[DIKI_KP_EQUAL - DIKI_UNKNOWN] = SDL_SCANCODE_KP_EQUALS;
slouken@2721
   437
    keymap[DIKI_KP_DECIMAL - DIKI_UNKNOWN] = SDL_SCANCODE_KP_PERIOD;
slouken@2721
   438
    keymap[DIKI_KP_0 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_0;
slouken@2721
   439
    keymap[DIKI_KP_1 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_1;
slouken@2721
   440
    keymap[DIKI_KP_2 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_2;
slouken@2721
   441
    keymap[DIKI_KP_3 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_3;
slouken@2721
   442
    keymap[DIKI_KP_4 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_4;
slouken@2721
   443
    keymap[DIKI_KP_5 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_5;
slouken@2721
   444
    keymap[DIKI_KP_6 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_6;
slouken@2721
   445
    keymap[DIKI_KP_7 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_7;
slouken@2721
   446
    keymap[DIKI_KP_8 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_8;
slouken@2721
   447
    keymap[DIKI_KP_9 - DIKI_UNKNOWN] = SDL_SCANCODE_KP_9;
slouken@2721
   448
    keymap[DIKI_KP_DIV - DIKI_UNKNOWN] = SDL_SCANCODE_KP_DIVIDE;
slouken@2721
   449
    keymap[DIKI_KP_MULT - DIKI_UNKNOWN] = SDL_SCANCODE_KP_MULTIPLY;
slouken@2721
   450
    keymap[DIKI_KP_MINUS - DIKI_UNKNOWN] = SDL_SCANCODE_KP_MINUS;
slouken@2721
   451
    keymap[DIKI_KP_PLUS - DIKI_UNKNOWN] = SDL_SCANCODE_KP_PLUS;
slouken@2721
   452
    keymap[DIKI_KP_ENTER - DIKI_UNKNOWN] = SDL_SCANCODE_KP_ENTER;
slouken@2226
   453
slouken@2721
   454
    keymap[DIKI_QUOTE_LEFT - DIKI_UNKNOWN] = SDL_SCANCODE_GRAVE;        /*  TLDE  */
slouken@2721
   455
    keymap[DIKI_MINUS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_MINUS;        /*  AE11  */
slouken@2721
   456
    keymap[DIKI_EQUALS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_EQUALS;      /*  AE12  */
slouken@2721
   457
    keymap[DIKI_BRACKET_LEFT - DIKI_UNKNOWN] = SDL_SCANCODE_RIGHTBRACKET;       /*  AD11  */
slouken@2721
   458
    keymap[DIKI_BRACKET_RIGHT - DIKI_UNKNOWN] = SDL_SCANCODE_LEFTBRACKET;       /*  AD12  */
slouken@2721
   459
    keymap[DIKI_BACKSLASH - DIKI_UNKNOWN] = SDL_SCANCODE_BACKSLASH;     /*  BKSL  */
slouken@2721
   460
    keymap[DIKI_SEMICOLON - DIKI_UNKNOWN] = SDL_SCANCODE_SEMICOLON;     /*  AC10  */
slouken@2721
   461
    keymap[DIKI_QUOTE_RIGHT - DIKI_UNKNOWN] = SDL_SCANCODE_APOSTROPHE;  /*  AC11  */
slouken@2721
   462
    keymap[DIKI_COMMA - DIKI_UNKNOWN] = SDL_SCANCODE_COMMA;     /*  AB08  */
slouken@2721
   463
    keymap[DIKI_PERIOD - DIKI_UNKNOWN] = SDL_SCANCODE_PERIOD;   /*  AB09  */
slouken@2721
   464
    keymap[DIKI_SLASH - DIKI_UNKNOWN] = SDL_SCANCODE_SLASH;     /*  AB10  */
slouken@2721
   465
    keymap[DIKI_LESS_SIGN - DIKI_UNKNOWN] = SDL_SCANCODE_NONUSBACKSLASH;        /*  103rd  */
slouken@2721
   466
slouken@167
   467
}
slouken@167
   468
slouken@2226
   469
static SDL_keysym *
slouken@2721
   470
DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_keysym * keysym)
slouken@2226
   471
{
slouken@2721
   472
    SDL_DFB_DEVICEDATA(_this);
slouken@167
   473
slouken@2721
   474
    if (evt->key_code >= 0
slouken@2721
   475
        && evt->key_code < SDL_arraysize(linux_scancode_table))
slouken@2737
   476
        keysym->scancode = linux_scancode_table[evt->key_code];
slouken@2721
   477
    else
slouken@2721
   478
        keysym->scancode = SDL_SCANCODE_UNKNOWN;
slouken@2226
   479
slouken@2860
   480
    if (keysym->scancode == SDL_SCANCODE_UNKNOWN
slouken@2860
   481
        || devdata->keyboard[0].is_generic) {
slouken@2860
   482
        if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap))
slouken@2860
   483
            keysym->scancode = oskeymap[evt->key_id - DIKI_UNKNOWN];
slouken@2721
   484
        else
slouken@2721
   485
            keysym->scancode = SDL_SCANCODE_UNKNOWN;
slouken@2721
   486
    }
slouken@2226
   487
slouken@1895
   488
    keysym->unicode =
slouken@2721
   489
        (DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
slouken@2721
   490
    if (keysym->unicode == 0
slouken@2721
   491
        && (evt->key_symbol > 0 && evt->key_symbol < 255))
slouken@2721
   492
        keysym->unicode = evt->key_symbol;
slouken@167
   493
slouken@1895
   494
    return keysym;
slouken@167
   495
}
slouken@167
   496
slouken@2860
   497
static SDL_keysym *
slouken@2860
   498
DirectFB_TranslateKeyInputEvent(_THIS, int index, DFBInputEvent * evt,
slouken@2860
   499
                                SDL_keysym * keysym)
slouken@2860
   500
{
slouken@2860
   501
    SDL_DFB_DEVICEDATA(_this);
slouken@2860
   502
slouken@2860
   503
    if (evt->key_code >= 0
slouken@2860
   504
        && evt->key_code < SDL_arraysize(linux_scancode_table))
slouken@2860
   505
        keysym->scancode = linux_scancode_table[evt->key_code];
slouken@2860
   506
    else
slouken@2860
   507
        keysym->scancode = SDL_SCANCODE_UNKNOWN;
slouken@2860
   508
slouken@2860
   509
    if (keysym->scancode == SDL_SCANCODE_UNKNOWN
slouken@2860
   510
        || devdata->keyboard[index].is_generic) {
slouken@2860
   511
        if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap))
slouken@2860
   512
            keysym->scancode = oskeymap[evt->key_id - DIKI_UNKNOWN];
slouken@2860
   513
        else
slouken@2860
   514
            keysym->scancode = SDL_SCANCODE_UNKNOWN;
slouken@2860
   515
    }
slouken@2860
   516
slouken@2860
   517
    keysym->unicode =
slouken@2860
   518
        (DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
slouken@2860
   519
    if (keysym->unicode == 0
slouken@2860
   520
        && (evt->key_symbol > 0 && evt->key_symbol < 255))
slouken@2860
   521
        keysym->unicode = evt->key_symbol;
slouken@2860
   522
slouken@2860
   523
    return keysym;
slouken@2860
   524
}
bob@3011
   525
slouken@1895
   526
static int
slouken@2226
   527
DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button)
slouken@167
   528
{
slouken@2226
   529
    switch (button) {
slouken@167
   530
    case DIBI_LEFT:
slouken@1895
   531
        return 1;
slouken@167
   532
    case DIBI_MIDDLE:
slouken@1895
   533
        return 2;
slouken@167
   534
    case DIBI_RIGHT:
slouken@1895
   535
        return 3;
slouken@167
   536
    default:
slouken@1895
   537
        return 0;
slouken@167
   538
    }
slouken@167
   539
}
slouken@1895
   540
slouken@2721
   541
static DFBEnumerationResult
slouken@2721
   542
input_device_cb(DFBInputDeviceID device_id, DFBInputDeviceDescription desc,
slouken@2721
   543
                void *callbackdata)
slouken@2721
   544
{
slouken@2721
   545
    DFB_DeviceData *devdata = callbackdata;
slouken@2721
   546
    SDL_Keyboard keyboard;
slouken@2721
   547
    SDLKey keymap[SDL_NUM_SCANCODES];
slouken@2721
   548
slouken@2721
   549
    if ((desc.caps & DIDTF_KEYBOARD) && device_id == DIDID_KEYBOARD) {
slouken@2721
   550
        SDL_zero(keyboard);
slouken@2860
   551
        SDL_AddKeyboard(&keyboard, 0);
slouken@2860
   552
        devdata->keyboard[0].id = device_id;
slouken@2860
   553
        devdata->keyboard[0].is_generic = 0;
slouken@2721
   554
        if (!strncmp("X11", desc.name, 3))
slouken@2860
   555
            devdata->keyboard[0].is_generic = 1;
slouken@2721
   556
slouken@2721
   557
        SDL_GetDefaultKeymap(keymap);
slouken@2860
   558
        SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
slouken@2860
   559
        devdata->num_keyboard++;
slouken@2860
   560
slouken@2860
   561
        return DFENUM_CANCEL;
slouken@2721
   562
    }
slouken@2860
   563
    return DFENUM_OK;
slouken@2860
   564
}
slouken@2860
   565
slouken@2860
   566
static DFBEnumerationResult
slouken@2860
   567
EnumKeyboards(DFBInputDeviceID device_id, DFBInputDeviceDescription desc,
slouken@2860
   568
              void *callbackdata)
slouken@2860
   569
{
slouken@2860
   570
    DFB_DeviceData *devdata = callbackdata;
slouken@2860
   571
    SDL_Keyboard keyboard;
slouken@2860
   572
    SDLKey keymap[SDL_NUM_SCANCODES];
slouken@2860
   573
slouken@2860
   574
    if (sys_ids) {
slouken@2860
   575
        if (device_id >= 0x10)
slouken@2860
   576
            return DFENUM_OK;
slouken@2860
   577
    } else {
slouken@2860
   578
        if (device_id < 0x10)
slouken@2860
   579
            return DFENUM_OK;
slouken@2860
   580
    }
slouken@2860
   581
    if ((desc.caps & DIDTF_KEYBOARD)) {
slouken@2860
   582
        SDL_zero(keyboard);
slouken@2860
   583
        SDL_AddKeyboard(&keyboard, devdata->num_keyboard);
slouken@2860
   584
        devdata->keyboard[devdata->num_keyboard].id = device_id;
slouken@2860
   585
        devdata->keyboard[devdata->num_keyboard].is_generic = 0;
slouken@2860
   586
        if (!strncmp("X11", desc.name, 3))
slouken@2860
   587
            devdata->keyboard[devdata->num_keyboard].is_generic = 1;
slouken@2860
   588
slouken@2860
   589
        SDL_GetDefaultKeymap(keymap);
slouken@2860
   590
        SDL_SetKeymap(devdata->num_keyboard, 0, keymap, SDL_NUM_SCANCODES);
slouken@2860
   591
        devdata->num_keyboard++;
slouken@2860
   592
    }
slouken@2860
   593
    return DFENUM_OK;
slouken@2721
   594
}
slouken@2721
   595
slouken@2721
   596
void
slouken@2721
   597
DirectFB_InitKeyboard(_THIS)
slouken@2721
   598
{
slouken@2721
   599
    SDL_DFB_DEVICEDATA(_this);
slouken@2721
   600
    int ret;
slouken@2721
   601
slouken@2860
   602
    DirectFB_InitOSKeymap(_this, &oskeymap[0], SDL_arraysize(oskeymap));
slouken@2721
   603
slouken@2860
   604
    devdata->num_keyboard = 0;
slouken@2998
   605
    if (devdata->use_linux_input) {
slouken@2860
   606
        sys_ids = 0;
bob@3011
   607
        SDL_DFB_CHECK(devdata->
bob@3011
   608
                      dfb->EnumInputDevices(devdata->dfb, EnumKeyboards,
bob@3011
   609
                                            devdata));
slouken@2860
   610
        if (devdata->num_keyboard == 0) {
slouken@2860
   611
            sys_ids = 1;
bob@3011
   612
            SDL_DFB_CHECK(devdata->
bob@3011
   613
                          dfb->EnumInputDevices(devdata->dfb, EnumKeyboards,
bob@3011
   614
                                                devdata));
slouken@2860
   615
        }
slouken@2860
   616
    } else {
bob@3011
   617
        SDL_DFB_CHECK(devdata->
bob@3011
   618
                      dfb->EnumInputDevices(devdata->dfb, input_device_cb,
bob@3011
   619
                                            devdata));
slouken@2860
   620
    }
slouken@2721
   621
}
slouken@2721
   622
slouken@2737
   623
void
slouken@2737
   624
DirectFB_QuitKeyboard(_THIS)
slouken@2737
   625
{
slouken@2737
   626
    SDL_DFB_DEVICEDATA(_this);
slouken@2737
   627
    int ret;
slouken@2737
   628
slouken@2860
   629
    SDL_KeyboardQuit();
slouken@2737
   630
slouken@2737
   631
}
slouken@2737
   632
slouken@2226
   633
#if 0
slouken@2721
   634
/* FIXME: Remove once determined this is not needed in fullscreen mode */
slouken@2226
   635
void
slouken@2226
   636
DirectFB_PumpEvents(_THIS)
slouken@2226
   637
{
slouken@2226
   638
    SDL_DFB_DEVICEDATA(_this);
slouken@2226
   639
    DFBInputEvent evt;
slouken@2226
   640
    static last_x = 0, last_y = 0;
slouken@2226
   641
slouken@2226
   642
    while (devdata->eventbuffer->GetEvent(devdata->eventbuffer,
slouken@2226
   643
                                          DFB_EVENT(&evt)) == DFB_OK) {
slouken@2226
   644
        SDL_keysym keysym;
slouken@2226
   645
        DFBInputDeviceModifierMask mod;
slouken@2226
   646
slouken@2226
   647
        if (evt.clazz = DFEC_INPUT) {
slouken@2226
   648
            if (evt.flags & DIEF_MODIFIERS)
slouken@2226
   649
                mod = evt.modifiers;
slouken@2226
   650
            else
slouken@2226
   651
                mod = 0;
slouken@2226
   652
slouken@2226
   653
            switch (evt.type) {
slouken@2226
   654
            case DIET_BUTTONPRESS:
slouken@2226
   655
                posted += SDL_PrivateMouseButton(SDL_PRESSED,
bob@3011
   656
                                                 DirectFB_TranslateButton
bob@3011
   657
                                                 (evt.button), 0, 0);
slouken@2226
   658
                break;
slouken@2226
   659
            case DIET_BUTTONRELEASE:
slouken@2226
   660
                posted += SDL_PrivateMouseButton(SDL_RELEASED,
bob@3011
   661
                                                 DirectFB_TranslateButton
bob@3011
   662
                                                 (evt.button), 0, 0);
slouken@2226
   663
                break;
slouken@2226
   664
            case DIET_KEYPRESS:
slouken@2226
   665
                posted += SDL_PrivateKeyboard(SDL_PRESSED,
bob@3011
   666
                                              DirectFB_TranslateKey
bob@3011
   667
                                              (evt.key_id, evt.key_symbol,
bob@3011
   668
                                               mod, &keysym));
slouken@2226
   669
                break;
slouken@2226
   670
            case DIET_KEYRELEASE:
slouken@2226
   671
                posted += SDL_PrivateKeyboard(SDL_RELEASED,
bob@3011
   672
                                              DirectFB_TranslateKey
bob@3011
   673
                                              (evt.key_id, evt.key_symbol,
bob@3011
   674
                                               mod, &keysym));
slouken@2226
   675
                break;
slouken@2226
   676
            case DIET_AXISMOTION:
slouken@2226
   677
                if (evt.flags & DIEF_AXISREL) {
slouken@2226
   678
                    if (evt.axis == DIAI_X)
slouken@2226
   679
                        posted +=
slouken@2226
   680
                            SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0);
slouken@2226
   681
                    else if (evt.axis == DIAI_Y)
slouken@2226
   682
                        posted +=
slouken@2226
   683
                            SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
slouken@2226
   684
                } else if (evt.flags & DIEF_AXISABS) {
slouken@2226
   685
                    if (evt.axis == DIAI_X)
slouken@2226
   686
                        last_x = evt.axisabs;
slouken@2226
   687
                    else if (evt.axis == DIAI_Y)
slouken@2226
   688
                        last_y = evt.axisabs;
slouken@2226
   689
                    posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y);
slouken@2226
   690
                }
slouken@2226
   691
                break;
slouken@2226
   692
            default:
slouken@2226
   693
                ;
slouken@2226
   694
            }
slouken@2226
   695
        }
slouken@2226
   696
    }
slouken@2226
   697
}
slouken@2226
   698
#endif