1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2020 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 #include "../../SDL_internal.h"
22
23 #if SDL_VIDEO_DRIVER_ALIOS
24 /*We don't use it anymore since our driver doesn't not support cursor*/
25
26 #include "SDL_assert.h"
27
28 #include "SDL_AliOS_video.h"
29 #include "SDL_AliOS_mouse.h"
30 #include "SDL_touch.h"
31 #include "../SDL_sysvideo.h"
32 #include "../../events/SDL_mouse_c.h"
33 #include "../../events/default_cursor.h"
34
35 static SDL_Cursor *AliOS_CreateDefaultCursor(void);
36 static SDL_Cursor *AliOS_CreateCursor(SDL_Surface * surface,
37 int hot_x, int hot_y);
38 static int AliOS_ShowCursor(SDL_Cursor * cursor);
39 static void AliOS_FreeCursor(SDL_Cursor * cursor);
40 static void AliOS_WarpMouse(SDL_Window * window, int x, int y);
41
42 static SDL_Cursor *
AliOS_CreateDefaultCursor(void)43 AliOS_CreateDefaultCursor(void)
44 {
45 return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY);
46 }
47
48 /* Create a cursor from a surface */
49 static SDL_Cursor *
AliOS_CreateCursor(SDL_Surface * surface,int hot_x,int hot_y)50 AliOS_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
51 {
52 AliOS_CursorData *curdata;
53 SDL_Cursor *cursor;
54 int pitch, i;
55
56 cursor = SDL_malloc(sizeof(SDL_Cursor));
57 curdata = SDL_malloc(sizeof(AliOS_CursorData));
58
59 curdata->hotx = hot_x;
60 curdata->hoty = hot_y;
61 curdata->surface = surface;
62 cursor->driverdata = curdata;
63
64 printf("AliOS_CreateCursor done\n");
65 return cursor;
66 }
67
68 static SDL_Cursor *
AliOS_CreateSystemCursor(SDL_Surface * surface,int hot_x,int hot_y)69 AliOS_CreateSystemCursor(SDL_Surface * surface, int hot_x, int hot_y)
70 {
71 return NULL;
72 }
73
74 /* Show the specified cursor, or hide if cursor is NULL */
75 static int
AliOS_ShowCursor(SDL_Cursor * cursor)76 AliOS_ShowCursor(SDL_Cursor * cursor)
77 {
78 SDL_Mouse *mouse;
79 SDL_VideoDisplay *display;
80 SDL_Window *window;
81 SDL_Surface *surface;
82
83 if (cursor) {
84 surface = ((AliOS_CursorData *)cursor->driverdata)->surface;
85
86 window = SDL_GetFocusWindow();
87 if (!window)
88 return -1;
89 else {
90 SDL_Surface *w_surface;
91 w_surface = SDL_GetWindowSurface(window);
92 SDL_BlitSurface(surface, NULL, w_surface, NULL);
93 SDL_UpdateWindowSurface(window);
94 printf("show cursor done\n");
95 }
96 printf("ShowCursor done\n");
97 }
98
99 return 0;
100 }
101
102 /* Free a window manager cursor */
103 static void
AliOS_FreeCursor(SDL_Cursor * cursor)104 AliOS_FreeCursor(SDL_Cursor * cursor)
105 {
106
107 }
108
109 /* Warp the mouse to (x,y) */
110 static void
AliOS_WarpMouse(SDL_Window * window,int x,int y)111 AliOS_WarpMouse(SDL_Window * window, int x, int y)
112 {
113 printf("AliOS_WarpMouse done\n");
114 return;
115 }
116
117 /* move cursor to (x,y) */
118 static void
AliOS_MoveCursor(SDL_Cursor * cursor)119 AliOS_MoveCursor(SDL_Cursor *cursor)
120 {
121 printf("AliOS_WarpMouse done\n");
122 return;
123 }
124
125 void
AliOS_InitMouse(_THIS)126 AliOS_InitMouse(_THIS)
127 {
128 SDL_Mouse *mouse = SDL_GetMouse();
129
130 mouse->CreateCursor = NULL;
131 mouse->CreateSystemCursor = NULL;
132 mouse->ShowCursor = NULL;
133 mouse->WarpMouse = NULL;
134 mouse->FreeCursor = NULL;
135 mouse->MoveCursor = NULL;
136
137 SDL_SetDefaultCursor(AliOS_CreateDefaultCursor());
138 //SDL_AddTouch(1, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "alios_touch");
139 printf("AliOS_InitMouse done\n");
140 }
141
142 void
AliOS_QuitMouse(_THIS)143 AliOS_QuitMouse(_THIS)
144 {
145 return;
146 }
147
148 #endif /* SDL_VIDEO_DRIVER_ALIOS */
149
150 /* vi: set ts=4 sw=4 expandtab: */
151