src/video/mir/SDL_mirmouse.c
author Ryan C. Gordon <icculus@icculus.org>
Mon, 06 Apr 2015 00:10:54 -0400
changeset 9458 543298b36b28
parent 8815 c6d0a457f3b2
child 9619 b94b6d0bff0f
permissions -rw-r--r--
This function can be static.
icculus@8153
     1
/*
icculus@8153
     2
  Simple DirectMedia Layer
icculus@8157
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
icculus@8153
     4
icculus@8153
     5
  This software is provided 'as-is', without any express or implied
icculus@8153
     6
  warranty.  In no event will the authors be held liable for any damages
icculus@8153
     7
  arising from the use of this software.
icculus@8153
     8
icculus@8153
     9
  Permission is granted to anyone to use this software for any purpose,
icculus@8153
    10
  including commercial applications, and to alter it and redistribute it
icculus@8153
    11
  freely, subject to the following restrictions:
icculus@8153
    12
icculus@8153
    13
  1. The origin of this software must not be misrepresented; you must not
icculus@8153
    14
     claim that you wrote the original software. If you use this software
icculus@8153
    15
     in a product, an acknowledgment in the product documentation would be
icculus@8153
    16
     appreciated but is not required.
icculus@8153
    17
  2. Altered source versions must be plainly marked as such, and must not be
icculus@8153
    18
     misrepresented as being the original software.
icculus@8153
    19
  3. This notice may not be removed or altered from any source distribution.
icculus@8153
    20
*/
icculus@8153
    21
icculus@8153
    22
/*
icculus@8153
    23
  Contributed by Brandon Schaefer, <brandon.schaefer@canonical.com>
icculus@8153
    24
*/
icculus@8153
    25
icculus@8154
    26
#include "../../SDL_internal.h"
icculus@8154
    27
icculus@8154
    28
#if SDL_VIDEO_DRIVER_MIR
icculus@8153
    29
icculus@8153
    30
#include "SDL_mirmouse.h"
icculus@8153
    31
icculus@8153
    32
#include "../../events/SDL_mouse_c.h"
icculus@8153
    33
#include "SDL_assert.h"
icculus@8153
    34
icculus@8159
    35
#include "SDL_mirdyn.h"
icculus@8159
    36
icculus@8153
    37
static SDL_Cursor*
icculus@8153
    38
MIR_CreateDefaultCursor()
icculus@8153
    39
{
icculus@8153
    40
    SDL_Cursor* cursor;
icculus@8153
    41
icculus@8153
    42
    cursor = SDL_calloc(1, sizeof(SDL_Cursor));
icculus@8153
    43
    if (cursor) {
icculus@8153
    44
    }
icculus@8153
    45
    else {
icculus@8153
    46
        SDL_OutOfMemory();
icculus@8153
    47
    }
icculus@8153
    48
icculus@8153
    49
    return cursor;
icculus@8153
    50
}
icculus@8153
    51
icculus@8153
    52
static SDL_Cursor*
icculus@8153
    53
MIR_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y)
icculus@8153
    54
{
icculus@8153
    55
    return MIR_CreateDefaultCursor();
icculus@8153
    56
}
icculus@8153
    57
icculus@8153
    58
static SDL_Cursor*
icculus@8153
    59
MIR_CreateSystemCursor(SDL_SystemCursor id)
icculus@8153
    60
{
icculus@8153
    61
    switch(id) {
icculus@8153
    62
        case SDL_SYSTEM_CURSOR_ARROW:
icculus@8153
    63
            break;
icculus@8153
    64
        case SDL_SYSTEM_CURSOR_IBEAM:
icculus@8153
    65
            break;
icculus@8153
    66
        case SDL_SYSTEM_CURSOR_WAIT:
icculus@8153
    67
            break;
icculus@8153
    68
        case SDL_SYSTEM_CURSOR_CROSSHAIR:
icculus@8153
    69
            break;
icculus@8153
    70
        case SDL_SYSTEM_CURSOR_WAITARROW:
icculus@8153
    71
            break;
icculus@8153
    72
        case SDL_SYSTEM_CURSOR_SIZENWSE:
icculus@8153
    73
            break;
icculus@8153
    74
        case SDL_SYSTEM_CURSOR_SIZENESW:
icculus@8153
    75
            break;
icculus@8153
    76
        case SDL_SYSTEM_CURSOR_SIZEWE:
icculus@8153
    77
            break;
icculus@8153
    78
        case SDL_SYSTEM_CURSOR_SIZENS:
icculus@8153
    79
            break;
icculus@8153
    80
        case SDL_SYSTEM_CURSOR_SIZEALL:
icculus@8153
    81
            break;
icculus@8153
    82
        case SDL_SYSTEM_CURSOR_NO:
icculus@8153
    83
            break;
icculus@8153
    84
        case SDL_SYSTEM_CURSOR_HAND:
icculus@8153
    85
            break;
icculus@8153
    86
        default:
icculus@8153
    87
            SDL_assert(0);
icculus@8153
    88
            return NULL;
icculus@8153
    89
    }
icculus@8153
    90
icculus@8153
    91
    return MIR_CreateDefaultCursor();
icculus@8153
    92
}
icculus@8153
    93
icculus@8153
    94
static void
icculus@8153
    95
MIR_FreeCursor(SDL_Cursor* cursor)
icculus@8153
    96
{
icculus@8153
    97
    if (cursor)
icculus@8153
    98
      SDL_free(cursor);
icculus@8153
    99
}
icculus@8153
   100
icculus@8153
   101
static int
icculus@8153
   102
MIR_ShowCursor(SDL_Cursor* cursor)
icculus@8153
   103
{
icculus@8153
   104
    return 0;
icculus@8153
   105
}
icculus@8153
   106
icculus@8153
   107
static void
icculus@8153
   108
MIR_WarpMouse(SDL_Window* window, int x, int y)
icculus@8153
   109
{
icculus@8153
   110
    SDL_Unsupported();
icculus@8153
   111
}
icculus@8153
   112
slouken@8815
   113
static void
slouken@8815
   114
MIR_WarpMouseGlobal(int x, int y)
slouken@8815
   115
{
slouken@8815
   116
    SDL_Unsupported();
slouken@8815
   117
}
slouken@8815
   118
icculus@8153
   119
static int
icculus@8153
   120
MIR_SetRelativeMouseMode(SDL_bool enabled)
icculus@8153
   121
{
icculus@8153
   122
    return SDL_Unsupported();
icculus@8153
   123
}
icculus@8153
   124
icculus@8153
   125
/* TODO Actually implement the cursor, need to wait for mir support */
icculus@8153
   126
void
icculus@8153
   127
MIR_InitMouse()
icculus@8153
   128
{
icculus@8153
   129
    SDL_Mouse* mouse = SDL_GetMouse();
icculus@8153
   130
icculus@8153
   131
    mouse->CreateCursor         = MIR_CreateCursor;
icculus@8153
   132
    mouse->ShowCursor           = MIR_ShowCursor;
icculus@8153
   133
    mouse->FreeCursor           = MIR_FreeCursor;
icculus@8153
   134
    mouse->WarpMouse            = MIR_WarpMouse;
slouken@8815
   135
    mouse->WarpMouseGlobal      = MIR_WarpMouseGlobal;
icculus@8153
   136
    mouse->CreateSystemCursor   = MIR_CreateSystemCursor;
icculus@8153
   137
    mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode;
icculus@8153
   138
icculus@8153
   139
    SDL_SetDefaultCursor(MIR_CreateDefaultCursor());
icculus@8153
   140
}
icculus@8153
   141
icculus@8153
   142
void
icculus@8153
   143
MIR_FiniMouse()
icculus@8153
   144
{
icculus@8153
   145
    SDL_Mouse* mouse = SDL_GetMouse();
icculus@8153
   146
icculus@8153
   147
    MIR_FreeCursor(mouse->def_cursor);
icculus@8153
   148
    mouse->def_cursor = NULL;
icculus@8153
   149
icculus@8153
   150
    mouse->CreateCursor         = NULL;
icculus@8153
   151
    mouse->ShowCursor           = NULL;
icculus@8153
   152
    mouse->FreeCursor           = NULL;
icculus@8153
   153
    mouse->WarpMouse            = NULL;
icculus@8153
   154
    mouse->CreateSystemCursor   = NULL;
icculus@8153
   155
    mouse->SetRelativeMouseMode = NULL;
icculus@8153
   156
}
icculus@8154
   157
icculus@8154
   158
#endif /* SDL_VIDEO_DRIVER_MIR */
icculus@8154
   159
icculus@8154
   160
/* vi: set ts=4 sw=4 expandtab: */
icculus@8154
   161