src/video/kmsdrm/SDL_kmsdrmmouse.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 02 Aug 2017 10:22:48 -0700
changeset 11175 cbc6a8a5b701
child 11342 0b924e560249
permissions -rw-r--r--
Fixed bug 3690 - SDL2 KMS/DRM render context support

Manuel

The attached patch adds support for KMS/DRM context graphics.

It builds with no problem on X86_64 GNU/Linux systems, provided the needed libraries are present, and on ARM GNU/Linux systems that have KMS/DRM support and a GLES2 implementation.
Tested on Raspberry Pi: KMS/DRM is what the Raspberry Pi will use as default in the near future, once the propietary DispmanX API by Broadcom is overtaken by open graphics stack, it's possible to boot current Raspbian system in KMS mode by adding "dtoverlay=vc4-kms-v3d" to config.txt on Raspbian's boot partition.
X86 systems use KMS right away in every current GNU/Linux system.

Simple build instructions:

$./autogen.sh
$./configure --enable-video-kmsdrm
$make
slouken@11175
     1
/*
slouken@11175
     2
  Simple DirectMedia Layer
slouken@11175
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
slouken@11175
     4
slouken@11175
     5
  This software is provided 'as-is', without any express or implied
slouken@11175
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@11175
     7
  arising from the use of this software.
slouken@11175
     8
slouken@11175
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@11175
    10
  including commercial applications, and to alter it and redistribute it
slouken@11175
    11
  freely, subject to the following restrictions:
slouken@11175
    12
slouken@11175
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@11175
    14
     claim that you wrote the original software. If you use this software
slouken@11175
    15
     in a product, an acknowledgment in the product documentation would be
slouken@11175
    16
     appreciated but is not required.
slouken@11175
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@11175
    18
     misrepresented as being the original software.
slouken@11175
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@11175
    20
*/
slouken@11175
    21
#include "../../SDL_internal.h"
slouken@11175
    22
slouken@11175
    23
#if SDL_VIDEO_DRIVER_KMSDRM
slouken@11175
    24
slouken@11175
    25
#include "SDL_assert.h"
slouken@11175
    26
#include "SDL_surface.h"
slouken@11175
    27
slouken@11175
    28
#include "SDL_kmsdrmvideo.h"
slouken@11175
    29
#include "SDL_kmsdrmmouse.h"
slouken@11175
    30
#include "SDL_kmsdrmdyn.h"
slouken@11175
    31
slouken@11175
    32
#include "../SDL_sysvideo.h"
slouken@11175
    33
#include "../../events/SDL_mouse_c.h"
slouken@11175
    34
#include "../../events/default_cursor.h"
slouken@11175
    35
slouken@11175
    36
slouken@11175
    37
static SDL_Cursor *KMSDRM_CreateDefaultCursor(void);
slouken@11175
    38
static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y);
slouken@11175
    39
static int KMSDRM_ShowCursor(SDL_Cursor * cursor);
slouken@11175
    40
static void KMSDRM_MoveCursor(SDL_Cursor * cursor);
slouken@11175
    41
static void KMSDRM_FreeCursor(SDL_Cursor * cursor);
slouken@11175
    42
static void KMSDRM_WarpMouse(SDL_Window * window, int x, int y);
slouken@11175
    43
static int KMSDRM_WarpMouseGlobal(int x, int y);
slouken@11175
    44
slouken@11175
    45
static SDL_Cursor *
slouken@11175
    46
KMSDRM_CreateDefaultCursor(void)
slouken@11175
    47
{
slouken@11175
    48
    return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
slouken@11175
    49
}
slouken@11175
    50
slouken@11175
    51
/* Create a cursor from a surface */
slouken@11175
    52
static SDL_Cursor *
slouken@11175
    53
KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
slouken@11175
    54
{
slouken@11175
    55
    SDL_VideoDevice *dev = SDL_GetVideoDevice();
slouken@11175
    56
    SDL_VideoData *vdata = ((SDL_VideoData *)dev->driverdata);
slouken@11175
    57
    SDL_PixelFormat *pixlfmt = surface->format;
slouken@11175
    58
    KMSDRM_CursorData *curdata;
slouken@11175
    59
    SDL_Cursor *cursor;
slouken@11175
    60
    int i, ret;
slouken@11175
    61
    uint32_t bo_format, bo_stride;
slouken@11175
    62
    char *buffer = NULL;
slouken@11175
    63
    size_t bufsize;
slouken@11175
    64
slouken@11175
    65
    switch(pixlfmt->format) {
slouken@11175
    66
    case SDL_PIXELFORMAT_RGB332:
slouken@11175
    67
        bo_format = GBM_FORMAT_RGB332;
slouken@11175
    68
        break;
slouken@11175
    69
    case SDL_PIXELFORMAT_ARGB4444:
slouken@11175
    70
        bo_format = GBM_FORMAT_ARGB4444;
slouken@11175
    71
        break;
slouken@11175
    72
    case SDL_PIXELFORMAT_RGBA4444:
slouken@11175
    73
        bo_format = GBM_FORMAT_RGBA4444;
slouken@11175
    74
        break;
slouken@11175
    75
    case SDL_PIXELFORMAT_ABGR4444:
slouken@11175
    76
        bo_format = GBM_FORMAT_ABGR4444;
slouken@11175
    77
        break;
slouken@11175
    78
    case SDL_PIXELFORMAT_BGRA4444:
slouken@11175
    79
        bo_format = GBM_FORMAT_BGRA4444;
slouken@11175
    80
        break;
slouken@11175
    81
    case SDL_PIXELFORMAT_ARGB1555:
slouken@11175
    82
        bo_format = GBM_FORMAT_ARGB1555;
slouken@11175
    83
        break;
slouken@11175
    84
    case SDL_PIXELFORMAT_RGBA5551:
slouken@11175
    85
        bo_format = GBM_FORMAT_RGBA5551;
slouken@11175
    86
        break;
slouken@11175
    87
    case SDL_PIXELFORMAT_ABGR1555:
slouken@11175
    88
        bo_format = GBM_FORMAT_ABGR1555;
slouken@11175
    89
        break;
slouken@11175
    90
    case SDL_PIXELFORMAT_BGRA5551:
slouken@11175
    91
        bo_format = GBM_FORMAT_BGRA5551;
slouken@11175
    92
        break;
slouken@11175
    93
    case SDL_PIXELFORMAT_RGB565:
slouken@11175
    94
        bo_format = GBM_FORMAT_RGB565;
slouken@11175
    95
        break;
slouken@11175
    96
    case SDL_PIXELFORMAT_BGR565:
slouken@11175
    97
        bo_format = GBM_FORMAT_BGR565;
slouken@11175
    98
        break;
slouken@11175
    99
    case SDL_PIXELFORMAT_RGB888:
slouken@11175
   100
    case SDL_PIXELFORMAT_RGB24:
slouken@11175
   101
        bo_format = GBM_FORMAT_RGB888;
slouken@11175
   102
        break;
slouken@11175
   103
    case SDL_PIXELFORMAT_BGR888:
slouken@11175
   104
    case SDL_PIXELFORMAT_BGR24:
slouken@11175
   105
        bo_format = GBM_FORMAT_BGR888;
slouken@11175
   106
        break;
slouken@11175
   107
    case SDL_PIXELFORMAT_RGBX8888:
slouken@11175
   108
        bo_format = GBM_FORMAT_RGBX8888;
slouken@11175
   109
        break;
slouken@11175
   110
    case SDL_PIXELFORMAT_BGRX8888:
slouken@11175
   111
        bo_format = GBM_FORMAT_BGRX8888;
slouken@11175
   112
        break;
slouken@11175
   113
    case SDL_PIXELFORMAT_ARGB8888:
slouken@11175
   114
        bo_format = GBM_FORMAT_ARGB8888;
slouken@11175
   115
        break;
slouken@11175
   116
    case SDL_PIXELFORMAT_RGBA8888:
slouken@11175
   117
        bo_format = GBM_FORMAT_RGBA8888;
slouken@11175
   118
        break;
slouken@11175
   119
    case SDL_PIXELFORMAT_ABGR8888:
slouken@11175
   120
        bo_format = GBM_FORMAT_ABGR8888;
slouken@11175
   121
        break;
slouken@11175
   122
    case SDL_PIXELFORMAT_BGRA8888:
slouken@11175
   123
        bo_format = GBM_FORMAT_BGRA8888;
slouken@11175
   124
        break;
slouken@11175
   125
    case SDL_PIXELFORMAT_ARGB2101010:
slouken@11175
   126
        bo_format = GBM_FORMAT_ARGB2101010;
slouken@11175
   127
        break;
slouken@11175
   128
    default:
slouken@11175
   129
        SDL_SetError("Unsupported pixel format for cursor");
slouken@11175
   130
        return NULL;
slouken@11175
   131
    }
slouken@11175
   132
slouken@11175
   133
    if (!KMSDRM_gbm_device_is_format_supported(vdata->gbm, bo_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
slouken@11175
   134
        SDL_SetError("Unsupported pixel format for cursor");
slouken@11175
   135
        return NULL;
slouken@11175
   136
    }
slouken@11175
   137
slouken@11175
   138
    cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
slouken@11175
   139
    if (cursor == NULL) {
slouken@11175
   140
        SDL_OutOfMemory();
slouken@11175
   141
        return NULL;
slouken@11175
   142
    }
slouken@11175
   143
    curdata = (KMSDRM_CursorData *) SDL_calloc(1, sizeof(*curdata));
slouken@11175
   144
    if (curdata == NULL) {
slouken@11175
   145
        SDL_OutOfMemory();
slouken@11175
   146
        SDL_free(cursor);
slouken@11175
   147
        return NULL;
slouken@11175
   148
    }
slouken@11175
   149
slouken@11175
   150
    curdata->hot_x = hot_x;
slouken@11175
   151
    curdata->hot_y = hot_y;
slouken@11175
   152
    curdata->w = surface->w;
slouken@11175
   153
    curdata->h = surface->h;
slouken@11175
   154
slouken@11175
   155
    curdata->bo = KMSDRM_gbm_bo_create(vdata->gbm, surface->w, surface->h, bo_format,
slouken@11175
   156
                                       GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
slouken@11175
   157
    if (curdata->bo == NULL) {
slouken@11175
   158
        SDL_SetError("Could not create GBM cursor BO");
slouken@11175
   159
        goto cleanup;
slouken@11175
   160
    }
slouken@11175
   161
slouken@11175
   162
    bo_stride = KMSDRM_gbm_bo_get_stride(curdata->bo);
slouken@11175
   163
    bufsize = bo_stride * surface->h;
slouken@11175
   164
slouken@11175
   165
    if (surface->pitch != bo_stride) {
slouken@11175
   166
        /* pitch doesn't match stride, must be copied to temp buffer  */
slouken@11175
   167
        buffer = SDL_malloc(bufsize);
slouken@11175
   168
        if (buffer == NULL) {
slouken@11175
   169
            SDL_OutOfMemory();
slouken@11175
   170
            goto cleanup;
slouken@11175
   171
        }
slouken@11175
   172
slouken@11175
   173
        if (SDL_MUSTLOCK(surface)) {
slouken@11175
   174
            if (SDL_LockSurface(surface) < 0) {
slouken@11175
   175
                /* Could not lock surface */
slouken@11175
   176
                goto cleanup;
slouken@11175
   177
            }
slouken@11175
   178
        }
slouken@11175
   179
slouken@11175
   180
        /* Copy to temporary buffer */
slouken@11175
   181
        for (i = 0; i < surface->h; i++) {
slouken@11175
   182
            SDL_memcpy(buffer + (i * bo_stride),
slouken@11175
   183
                       ((char *)surface->pixels) + (i * surface->pitch),
slouken@11175
   184
                       surface->w * pixlfmt->BytesPerPixel);
slouken@11175
   185
        }
slouken@11175
   186
slouken@11175
   187
        if (SDL_MUSTLOCK(surface)) {
slouken@11175
   188
            SDL_UnlockSurface(surface);
slouken@11175
   189
        }
slouken@11175
   190
slouken@11175
   191
        if (KMSDRM_gbm_bo_write(curdata->bo, buffer, bufsize)) {
slouken@11175
   192
            SDL_SetError("Could not write to GBM cursor BO");
slouken@11175
   193
            goto cleanup;
slouken@11175
   194
        }
slouken@11175
   195
slouken@11175
   196
        /* Free temporary buffer */
slouken@11175
   197
        SDL_free(buffer);
slouken@11175
   198
        buffer = NULL;
slouken@11175
   199
    } else {
slouken@11175
   200
        /* surface matches BO format */
slouken@11175
   201
        if (SDL_MUSTLOCK(surface)) {
slouken@11175
   202
            if (SDL_LockSurface(surface) < 0) {
slouken@11175
   203
                /* Could not lock surface */
slouken@11175
   204
                goto cleanup;
slouken@11175
   205
            }
slouken@11175
   206
        }
slouken@11175
   207
slouken@11175
   208
        ret = KMSDRM_gbm_bo_write(curdata->bo, surface->pixels, bufsize);
slouken@11175
   209
slouken@11175
   210
        if (SDL_MUSTLOCK(surface)) {
slouken@11175
   211
            SDL_UnlockSurface(surface);
slouken@11175
   212
        }
slouken@11175
   213
slouken@11175
   214
        if (ret) {
slouken@11175
   215
            SDL_SetError("Could not write to GBM cursor BO");
slouken@11175
   216
            goto cleanup;
slouken@11175
   217
        }
slouken@11175
   218
    }
slouken@11175
   219
slouken@11175
   220
    cursor->driverdata = curdata;
slouken@11175
   221
slouken@11175
   222
    return cursor;
slouken@11175
   223
slouken@11175
   224
cleanup:
slouken@11175
   225
    if (buffer != NULL) {
slouken@11175
   226
        SDL_free(buffer);
slouken@11175
   227
    }
slouken@11175
   228
    if (cursor != NULL) {
slouken@11175
   229
        SDL_free(cursor);
slouken@11175
   230
    }
slouken@11175
   231
    if (curdata != NULL) {
slouken@11175
   232
        if (curdata->bo != NULL) {
slouken@11175
   233
            KMSDRM_gbm_bo_destroy(curdata->bo);
slouken@11175
   234
        }
slouken@11175
   235
        SDL_free(curdata);
slouken@11175
   236
    }
slouken@11175
   237
    return NULL;
slouken@11175
   238
}
slouken@11175
   239
slouken@11175
   240
/* Show the specified cursor, or hide if cursor is NULL */
slouken@11175
   241
static int
slouken@11175
   242
KMSDRM_ShowCursor(SDL_Cursor * cursor)
slouken@11175
   243
{
slouken@11175
   244
    SDL_VideoDevice *dev = SDL_GetVideoDevice();
slouken@11175
   245
    SDL_VideoData *vdata = ((SDL_VideoData *)dev->driverdata);
slouken@11175
   246
    SDL_Mouse *mouse;
slouken@11175
   247
    KMSDRM_CursorData *curdata;
slouken@11175
   248
    SDL_VideoDisplay *display = NULL;
slouken@11175
   249
    SDL_DisplayData *ddata = NULL;
slouken@11175
   250
    int ret;
slouken@11175
   251
    uint32_t bo_handle;
slouken@11175
   252
slouken@11175
   253
    mouse = SDL_GetMouse();
slouken@11175
   254
    if (mouse == NULL) {
slouken@11175
   255
        return SDL_SetError("No mouse.");
slouken@11175
   256
    }
slouken@11175
   257
slouken@11175
   258
    if (mouse->focus != NULL) {
slouken@11175
   259
        display = SDL_GetDisplayForWindow(mouse->focus);
slouken@11175
   260
        if (display != NULL) {
slouken@11175
   261
            ddata = (SDL_DisplayData*) display->driverdata;
slouken@11175
   262
        }
slouken@11175
   263
    }
slouken@11175
   264
slouken@11175
   265
    if (cursor == NULL) {
slouken@11175
   266
        /* Hide current cursor */
slouken@11175
   267
        if ( mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
slouken@11175
   268
            curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
slouken@11175
   269
slouken@11175
   270
            if (curdata->crtc_id != 0) {
slouken@11175
   271
                ret = KMSDRM_drmModeSetCursor(vdata->drm_fd, curdata->crtc_id, 0, 0, 0);
slouken@11175
   272
                if (ret) {
slouken@11175
   273
                    SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
slouken@11175
   274
                    return ret;
slouken@11175
   275
                }
slouken@11175
   276
                /* Mark previous cursor as not-displayed */
slouken@11175
   277
                curdata->crtc_id = 0;
slouken@11175
   278
slouken@11175
   279
                return 0;
slouken@11175
   280
            }
slouken@11175
   281
        }
slouken@11175
   282
        /* otherwise if possible, hide global cursor */
slouken@11175
   283
        if (ddata != NULL && ddata->crtc_id != 0) {
slouken@11175
   284
            ret = KMSDRM_drmModeSetCursor(vdata->drm_fd, ddata->crtc_id, 0, 0, 0);
slouken@11175
   285
            if (ret) {
slouken@11175
   286
                SDL_SetError("Could not hide display's cursor with drmModeSetCursor().");
slouken@11175
   287
                return ret;
slouken@11175
   288
            }
slouken@11175
   289
            return 0;
slouken@11175
   290
        }
slouken@11175
   291
slouken@11175
   292
        return SDL_SetError("Couldn't find cursor to hide.");
slouken@11175
   293
    }
slouken@11175
   294
    /* If cursor != NULL, show new cursor on display */
slouken@11175
   295
    if (display == NULL) {
slouken@11175
   296
        return SDL_SetError("Could not get display for mouse.");
slouken@11175
   297
    }
slouken@11175
   298
    if (ddata == NULL) {
slouken@11175
   299
        return SDL_SetError("Could not get display driverdata.");
slouken@11175
   300
    }
slouken@11175
   301
slouken@11175
   302
    curdata = (KMSDRM_CursorData *) cursor->driverdata;
slouken@11175
   303
    if (curdata == NULL || curdata->bo == NULL) {
slouken@11175
   304
        return SDL_SetError("Cursor not initialized properly.");
slouken@11175
   305
    }
slouken@11175
   306
slouken@11175
   307
    bo_handle = KMSDRM_gbm_bo_get_handle(curdata->bo).u32;
slouken@11175
   308
    if (curdata->hot_x == 0 && curdata->hot_y == 0) {
slouken@11175
   309
        ret = KMSDRM_drmModeSetCursor(vdata->drm_fd, ddata->crtc_id, bo_handle,
slouken@11175
   310
                                      curdata->w, curdata->h);
slouken@11175
   311
    } else {
slouken@11175
   312
        ret = KMSDRM_drmModeSetCursor2(vdata->drm_fd, ddata->crtc_id, bo_handle,
slouken@11175
   313
                                       curdata->w, curdata->h,
slouken@11175
   314
                                       curdata->hot_x, curdata->hot_y);
slouken@11175
   315
    }
slouken@11175
   316
    if (ret) {
slouken@11175
   317
        SDL_SetError("drmModeSetCursor failed.");
slouken@11175
   318
        return ret;
slouken@11175
   319
    }
slouken@11175
   320
slouken@11175
   321
    curdata->crtc_id = ddata->crtc_id;
slouken@11175
   322
slouken@11175
   323
    return 0;
slouken@11175
   324
}
slouken@11175
   325
slouken@11175
   326
/* Free a window manager cursor */
slouken@11175
   327
static void
slouken@11175
   328
KMSDRM_FreeCursor(SDL_Cursor * cursor)
slouken@11175
   329
{
slouken@11175
   330
    KMSDRM_CursorData *curdata;
slouken@11175
   331
    int drm_fd;
slouken@11175
   332
slouken@11175
   333
    if (cursor != NULL) {
slouken@11175
   334
        curdata = (KMSDRM_CursorData *) cursor->driverdata;
slouken@11175
   335
slouken@11175
   336
        if (curdata != NULL) {
slouken@11175
   337
            if (curdata->bo != NULL) {
slouken@11175
   338
                if (curdata->crtc_id != 0) {
slouken@11175
   339
                    drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
slouken@11175
   340
                    /* Hide the cursor if previously shown on a CRTC */
slouken@11175
   341
                    KMSDRM_drmModeSetCursor(drm_fd, curdata->crtc_id, 0, 0, 0);
slouken@11175
   342
                    curdata->crtc_id = 0;
slouken@11175
   343
                }
slouken@11175
   344
                KMSDRM_gbm_bo_destroy(curdata->bo);
slouken@11175
   345
                curdata->bo = NULL;
slouken@11175
   346
            }
slouken@11175
   347
            SDL_free(cursor->driverdata);
slouken@11175
   348
        }
slouken@11175
   349
        SDL_free(cursor);
slouken@11175
   350
    }
slouken@11175
   351
}
slouken@11175
   352
slouken@11175
   353
/* Warp the mouse to (x,y) */
slouken@11175
   354
static void
slouken@11175
   355
KMSDRM_WarpMouse(SDL_Window * window, int x, int y)
slouken@11175
   356
{
slouken@11175
   357
    /* Only one global/fullscreen window is supported */
slouken@11175
   358
    KMSDRM_WarpMouseGlobal(x, y);
slouken@11175
   359
}
slouken@11175
   360
slouken@11175
   361
/* Warp the mouse to (x,y) */
slouken@11175
   362
static int
slouken@11175
   363
KMSDRM_WarpMouseGlobal(int x, int y)
slouken@11175
   364
{
slouken@11175
   365
    KMSDRM_CursorData *curdata;
slouken@11175
   366
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@11175
   367
slouken@11175
   368
    if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
slouken@11175
   369
        curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
slouken@11175
   370
        if (curdata->bo != NULL) {
slouken@11175
   371
            if (curdata->crtc_id != 0) {
slouken@11175
   372
                int ret, drm_fd;
slouken@11175
   373
                drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->bo));
slouken@11175
   374
                ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->crtc_id, x, y);
slouken@11175
   375
slouken@11175
   376
                if (ret) {
slouken@11175
   377
                    SDL_SetError("drmModeMoveCursor() failed.");
slouken@11175
   378
                }
slouken@11175
   379
slouken@11175
   380
                return ret;
slouken@11175
   381
            } else {
slouken@11175
   382
                return SDL_SetError("Cursor is not currently shown.");
slouken@11175
   383
            }
slouken@11175
   384
        } else {
slouken@11175
   385
            return SDL_SetError("Cursor not initialized properly.");
slouken@11175
   386
        }
slouken@11175
   387
    } else {
slouken@11175
   388
        return SDL_SetError("No mouse or current cursor.");
slouken@11175
   389
    }
slouken@11175
   390
}
slouken@11175
   391
slouken@11175
   392
void
slouken@11175
   393
KMSDRM_InitMouse(_THIS)
slouken@11175
   394
{
slouken@11175
   395
    /* FIXME: Using UDEV it should be possible to scan all mice
slouken@11175
   396
     * but there's no point in doing so as there's no multimice support...yet!
slouken@11175
   397
     */
slouken@11175
   398
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@11175
   399
slouken@11175
   400
    mouse->CreateCursor = KMSDRM_CreateCursor;
slouken@11175
   401
    mouse->ShowCursor = KMSDRM_ShowCursor;
slouken@11175
   402
    mouse->MoveCursor = KMSDRM_MoveCursor;
slouken@11175
   403
    mouse->FreeCursor = KMSDRM_FreeCursor;
slouken@11175
   404
    mouse->WarpMouse = KMSDRM_WarpMouse;
slouken@11175
   405
    mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal;
slouken@11175
   406
slouken@11175
   407
    SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor());
slouken@11175
   408
}
slouken@11175
   409
slouken@11175
   410
void
slouken@11175
   411
KMSDRM_QuitMouse(_THIS)
slouken@11175
   412
{
slouken@11175
   413
    /* TODO: ? */
slouken@11175
   414
}
slouken@11175
   415
slouken@11175
   416
/* This is called when a mouse motion event occurs */
slouken@11175
   417
static void
slouken@11175
   418
KMSDRM_MoveCursor(SDL_Cursor * cursor)
slouken@11175
   419
{
slouken@11175
   420
    SDL_Mouse *mouse = SDL_GetMouse();
slouken@11175
   421
    KMSDRM_WarpMouse(mouse->focus, mouse->x, mouse->y);
slouken@11175
   422
}
slouken@11175
   423
slouken@11175
   424
#endif /* SDL_VIDEO_DRIVER_KMSDRM */
slouken@11175
   425
slouken@11175
   426
/* vi: set ts=4 sw=4 expandtab: */