Mercurial > sdl-ios-xcode
comparison src/video/gem/SDL_gemmouse.c @ 2189:f54670a477bb
Update GEM driver to new API, will have to fill the void later :)
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 13 Jul 2007 22:55:15 +0000 |
parents | 7312feb88dad |
children | 99210400e8b9 |
comparison
equal
deleted
inserted
replaced
2188:0e751c1f83f5 | 2189:f54670a477bb |
---|---|
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 #include "SDL_config.h" | 22 #include "SDL_config.h" |
23 | 23 |
24 /* | 24 #include "SDL_gemvideo.h" |
25 * GEM Mouse manager | |
26 * | |
27 * Patrice Mandin | |
28 */ | |
29 | 25 |
30 #include <gem.h> | 26 #include "../../events/SDL_mouse_c.h" |
31 | |
32 #include "SDL_mouse.h" | |
33 #include "../../events/SDL_events_c.h" | |
34 #include "../SDL_cursor_c.h" | |
35 #include "SDL_gemmouse_c.h" | |
36 | |
37 /* Defines */ | |
38 | |
39 /*#define DEBUG_VIDEO_GEM 1*/ | |
40 | |
41 #define MAXCURWIDTH 16 | |
42 #define MAXCURHEIGHT 16 | |
43 | |
44 /* The implementation dependent data for the window manager cursor */ | |
45 struct WMcursor | |
46 { | |
47 MFORM *mform_p; | |
48 }; | |
49 | |
50 | 27 |
51 void | 28 void |
52 GEM_FreeWMCursor(_THIS, WMcursor * cursor) | 29 GEM_InitMouse(_THIS) |
53 { | 30 { |
54 if (cursor == NULL) | 31 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
55 return; | 32 SDL_Mouse mouse; |
56 | 33 |
57 graf_mouse(ARROW, NULL); | 34 SDL_zero(mouse); |
58 | 35 data->mouse = SDL_AddMouse(&mouse, -1); |
59 if (cursor->mform_p != NULL) | |
60 SDL_free(cursor->mform_p); | |
61 | |
62 SDL_free(cursor); | |
63 } | 36 } |
64 | 37 |
65 WMcursor * | 38 void |
66 GEM_CreateWMCursor(_THIS, | 39 GEM_QuitMouse(_THIS) |
67 Uint8 * data, Uint8 * mask, int w, int h, int hot_x, | |
68 int hot_y) | |
69 { | 40 { |
70 WMcursor *cursor; | 41 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
71 MFORM *new_mform; | |
72 int i; | |
73 | 42 |
74 /* Check the size */ | 43 SDL_DelMouse(data->mouse); |
75 if ((w > MAXCURWIDTH) || (h > MAXCURHEIGHT)) { | |
76 SDL_SetError("Only cursors of dimension (%dx%d) are allowed", | |
77 MAXCURWIDTH, MAXCURHEIGHT); | |
78 return (NULL); | |
79 } | |
80 | |
81 /* Allocate the cursor memory */ | |
82 cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); | |
83 if (cursor == NULL) { | |
84 SDL_OutOfMemory(); | |
85 return (NULL); | |
86 } | |
87 | |
88 /* Allocate mform */ | |
89 new_mform = (MFORM *) SDL_malloc(sizeof(MFORM)); | |
90 if (new_mform == NULL) { | |
91 SDL_free(cursor); | |
92 SDL_OutOfMemory(); | |
93 return (NULL); | |
94 } | |
95 | |
96 cursor->mform_p = new_mform; | |
97 | |
98 new_mform->mf_xhot = hot_x; | |
99 new_mform->mf_yhot = hot_y; | |
100 new_mform->mf_nplanes = 1; | |
101 new_mform->mf_fg = 0; | |
102 new_mform->mf_bg = 1; | |
103 | |
104 for (i = 0; i < MAXCURHEIGHT; i++) { | |
105 new_mform->mf_mask[i] = 0; | |
106 new_mform->mf_data[i] = 0; | |
107 } | |
108 | |
109 if (w <= 8) { | |
110 for (i = 0; i < h; i++) { | |
111 new_mform->mf_mask[i] = mask[i] << 8; | |
112 new_mform->mf_data[i] = data[i] << 8; | |
113 } | |
114 } else { | |
115 for (i = 0; i < h; i++) { | |
116 new_mform->mf_mask[i] = mask[i << 1] << 8 | mask[(i << 1) + 1]; | |
117 new_mform->mf_data[i] = data[i << 1] << 8 | data[(i << 1) + 1]; | |
118 } | |
119 } | |
120 | |
121 #ifdef DEBUG_VIDEO_GEM | |
122 for (i = 0; i < h; i++) { | |
123 printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, | |
124 new_mform->mf_mask[i]); | |
125 } | |
126 | |
127 printf("sdl:video:gem: CreateWMCursor(): done\n"); | |
128 #endif | |
129 | |
130 return cursor; | |
131 } | |
132 | |
133 int | |
134 GEM_ShowWMCursor(_THIS, WMcursor * cursor) | |
135 { | |
136 /* | |
137 if (cursor == NULL) { | |
138 graf_mouse(M_OFF, NULL); | |
139 } else if (cursor->mform_p) { | |
140 graf_mouse(USER_DEF, cursor->mform_p); | |
141 } | |
142 */ | |
143 #ifdef DEBUG_VIDEO_GEM | |
144 printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); | |
145 #endif | |
146 | |
147 return 1; | |
148 } | |
149 | |
150 #if 0 | |
151 void | |
152 GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | |
153 { | |
154 /* This seems to work only on AES 3.4 (Falcon) */ | |
155 | |
156 EVNTREC warpevent; | |
157 | |
158 warpevent.ap_event = APPEVNT_MOUSE; | |
159 warpevent.ap_value = (x << 16) | y; | |
160 | |
161 appl_tplay(&warpevent, 1, 1000); | |
162 } | |
163 #endif | |
164 | |
165 void | |
166 GEM_CheckMouseMode(_THIS) | |
167 { | |
168 /* If the mouse is hidden and input is grabbed, we use relative mode */ | |
169 if ((!(SDL_cursorstate & CURSOR_VISIBLE)) && | |
170 (this->input_grab != SDL_GRAB_OFF) && | |
171 (SDL_GetAppState() & SDL_APPACTIVE)) { | |
172 SDL_AtariXbios_LockMousePosition(SDL_TRUE); | |
173 GEM_mouse_relative = SDL_TRUE; | |
174 } else { | |
175 SDL_AtariXbios_LockMousePosition(SDL_FALSE); | |
176 GEM_mouse_relative = SDL_FALSE; | |
177 graf_mouse(M_ON, NULL); | |
178 } | |
179 } | 44 } |
180 | 45 |
181 /* vi: set ts=4 sw=4 expandtab: */ | 46 /* vi: set ts=4 sw=4 expandtab: */ |