SDL  2.0
SDL_mirmouse.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /*
23  Contributed by Brandon Schaefer, <brandon.schaefer@canonical.com>
24 */
25 
26 #include "../../SDL_internal.h"
27 
28 #if SDL_VIDEO_DRIVER_MIR
29 
30 #include "SDL_mirmouse.h"
31 
32 #include "../../events/SDL_mouse_c.h"
33 #include "SDL_assert.h"
34 
35 #include "SDL_mirdyn.h"
36 
37 static SDL_Cursor*
38 MIR_CreateDefaultCursor()
39 {
41 
42  cursor = SDL_calloc(1, sizeof(SDL_Cursor));
43  if (cursor) {
44  }
45  else {
47  }
48 
49  return cursor;
50 }
51 
52 static SDL_Cursor*
53 MIR_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y)
54 {
55  return MIR_CreateDefaultCursor();
56 }
57 
58 static SDL_Cursor*
59 MIR_CreateSystemCursor(SDL_SystemCursor id)
60 {
61  switch(id) {
63  break;
65  break;
67  break;
69  break;
71  break;
73  break;
75  break;
77  break;
79  break;
81  break;
83  break;
85  break;
86  default:
87  SDL_assert(0);
88  return NULL;
89  }
90 
91  return MIR_CreateDefaultCursor();
92 }
93 
94 static void
95 MIR_FreeCursor(SDL_Cursor* cursor)
96 {
97  if (cursor)
98  SDL_free(cursor);
99 }
100 
101 static int
102 MIR_ShowCursor(SDL_Cursor* cursor)
103 {
104  return 0;
105 }
106 
107 static void
108 MIR_WarpMouse(SDL_Window* window, int x, int y)
109 {
110  SDL_Unsupported();
111 }
112 
113 static int
114 MIR_WarpMouseGlobal(int x, int y)
115 {
116  return SDL_Unsupported();
117 }
118 
119 static int
120 MIR_SetRelativeMouseMode(SDL_bool enabled)
121 {
122  return SDL_Unsupported();
123 }
124 
125 /* TODO Actually implement the cursor, need to wait for mir support */
126 void
128 {
129  SDL_Mouse* mouse = SDL_GetMouse();
130 
131  mouse->CreateCursor = MIR_CreateCursor;
132  mouse->ShowCursor = MIR_ShowCursor;
133  mouse->FreeCursor = MIR_FreeCursor;
134  mouse->WarpMouse = MIR_WarpMouse;
135  mouse->WarpMouseGlobal = MIR_WarpMouseGlobal;
136  mouse->CreateSystemCursor = MIR_CreateSystemCursor;
137  mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode;
138 
139  SDL_SetDefaultCursor(MIR_CreateDefaultCursor());
140 }
141 
142 void
144 {
145  SDL_Mouse* mouse = SDL_GetMouse();
146 
147  MIR_FreeCursor(mouse->def_cursor);
148  mouse->def_cursor = NULL;
149 
150  mouse->CreateCursor = NULL;
151  mouse->ShowCursor = NULL;
152  mouse->FreeCursor = NULL;
153  mouse->WarpMouse = NULL;
154  mouse->CreateSystemCursor = NULL;
155  mouse->SetRelativeMouseMode = NULL;
156 }
157 
158 #endif /* SDL_VIDEO_DRIVER_MIR */
159 
160 /* vi: set ts=4 sw=4 expandtab: */
161 
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:66
int(* ShowCursor)(SDL_Cursor *cursor)
Definition: SDL_mouse_c.h:52
int(* SetRelativeMouseMode)(SDL_bool enabled)
Definition: SDL_mouse_c.h:67
SDL_Window * window
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
void MIR_FiniMouse()
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
SDL_bool
Definition: SDL_stdinc.h:126
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
Definition: SDL_mouse_c.h:46
void * SDL_calloc(size_t nmemb, size_t size)
void SDL_free(void *mem)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor.
Definition: SDL_mouse.h:46
SDL_Cursor * cursor
Definition: testwm2.c:40
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
Definition: SDL_mouse.c:55
int(* WarpMouseGlobal)(int x, int y)
Definition: SDL_mouse_c.h:64
GLenum GLenum GLsizei const GLuint GLboolean enabled
void(* FreeCursor)(SDL_Cursor *cursor)
Definition: SDL_mouse_c.h:58
#define SDL_assert(condition)
Definition: SDL_assert.h:167
#define NULL
Definition: begin_code.h:143
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
The type used to identify a window.
Definition: SDL_sysvideo.h:71
void(* WarpMouse)(SDL_Window *window, int x, int y)
Definition: SDL_mouse_c.h:61
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
Definition: SDL_mouse_c.h:49
#define SDL_Unsupported()
Definition: SDL_error.h:53
void MIR_InitMouse()
SDL_Cursor * def_cursor
Definition: SDL_mouse_c.h:92