Mercurial > sdl-ios-xcode
comparison src/video/gem/SDL_gemmouse.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
40 | 40 |
41 #define MAXCURWIDTH 16 | 41 #define MAXCURWIDTH 16 |
42 #define MAXCURHEIGHT 16 | 42 #define MAXCURHEIGHT 16 |
43 | 43 |
44 /* The implementation dependent data for the window manager cursor */ | 44 /* The implementation dependent data for the window manager cursor */ |
45 struct WMcursor { | 45 struct WMcursor |
46 MFORM *mform_p; | 46 { |
47 MFORM *mform_p; | |
47 }; | 48 }; |
48 | 49 |
49 | 50 |
50 void GEM_FreeWMCursor(_THIS, WMcursor *cursor) | 51 void |
52 GEM_FreeWMCursor (_THIS, WMcursor * cursor) | |
51 { | 53 { |
52 if (cursor == NULL) | 54 if (cursor == NULL) |
53 return; | 55 return; |
54 | |
55 graf_mouse(ARROW, NULL); | |
56 | 56 |
57 if (cursor->mform_p != NULL) | 57 graf_mouse (ARROW, NULL); |
58 SDL_free(cursor->mform_p); | |
59 | 58 |
60 SDL_free(cursor); | 59 if (cursor->mform_p != NULL) |
60 SDL_free (cursor->mform_p); | |
61 | |
62 SDL_free (cursor); | |
61 } | 63 } |
62 | 64 |
63 WMcursor *GEM_CreateWMCursor(_THIS, | 65 WMcursor * |
64 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | 66 GEM_CreateWMCursor (_THIS, |
67 Uint8 * data, Uint8 * mask, int w, int h, int hot_x, | |
68 int hot_y) | |
65 { | 69 { |
66 WMcursor *cursor; | 70 WMcursor *cursor; |
67 MFORM *new_mform; | 71 MFORM *new_mform; |
68 int i; | 72 int i; |
69 | 73 |
70 /* Check the size */ | 74 /* Check the size */ |
71 if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) { | 75 if ((w > MAXCURWIDTH) || (h > MAXCURHEIGHT)) { |
72 SDL_SetError("Only cursors of dimension (%dx%d) are allowed", | 76 SDL_SetError ("Only cursors of dimension (%dx%d) are allowed", |
73 MAXCURWIDTH, MAXCURHEIGHT); | 77 MAXCURWIDTH, MAXCURHEIGHT); |
74 return(NULL); | 78 return (NULL); |
75 } | 79 } |
76 | 80 |
77 /* Allocate the cursor memory */ | 81 /* Allocate the cursor memory */ |
78 cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); | 82 cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); |
79 if ( cursor == NULL ) { | 83 if (cursor == NULL) { |
80 SDL_OutOfMemory(); | 84 SDL_OutOfMemory (); |
81 return(NULL); | 85 return (NULL); |
82 } | 86 } |
83 | 87 |
84 /* Allocate mform */ | 88 /* Allocate mform */ |
85 new_mform = (MFORM *)SDL_malloc(sizeof(MFORM)); | 89 new_mform = (MFORM *) SDL_malloc (sizeof (MFORM)); |
86 if (new_mform == NULL) { | 90 if (new_mform == NULL) { |
87 SDL_free(cursor); | 91 SDL_free (cursor); |
88 SDL_OutOfMemory(); | 92 SDL_OutOfMemory (); |
89 return(NULL); | 93 return (NULL); |
90 } | 94 } |
91 | 95 |
92 cursor->mform_p = new_mform; | 96 cursor->mform_p = new_mform; |
93 | 97 |
94 new_mform->mf_xhot = hot_x; | 98 new_mform->mf_xhot = hot_x; |
95 new_mform->mf_yhot = hot_y; | 99 new_mform->mf_yhot = hot_y; |
96 new_mform->mf_nplanes = 1; | 100 new_mform->mf_nplanes = 1; |
97 new_mform->mf_fg = 0; | 101 new_mform->mf_fg = 0; |
98 new_mform->mf_bg = 1; | 102 new_mform->mf_bg = 1; |
99 | 103 |
100 for (i=0;i<MAXCURHEIGHT;i++) { | 104 for (i = 0; i < MAXCURHEIGHT; i++) { |
101 new_mform->mf_mask[i]=0; | 105 new_mform->mf_mask[i] = 0; |
102 new_mform->mf_data[i]=0; | 106 new_mform->mf_data[i] = 0; |
103 } | 107 } |
104 | 108 |
105 if (w<=8) { | 109 if (w <= 8) { |
106 for (i=0;i<h;i++) { | 110 for (i = 0; i < h; i++) { |
107 new_mform->mf_mask[i]= mask[i]<<8; | 111 new_mform->mf_mask[i] = mask[i] << 8; |
108 new_mform->mf_data[i]= data[i]<<8; | 112 new_mform->mf_data[i] = data[i] << 8; |
109 } | 113 } |
110 } else { | 114 } else { |
111 for (i=0;i<h;i++) { | 115 for (i = 0; i < h; i++) { |
112 new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1]; | 116 new_mform->mf_mask[i] = mask[i << 1] << 8 | mask[(i << 1) + 1]; |
113 new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1]; | 117 new_mform->mf_data[i] = data[i << 1] << 8 | data[(i << 1) + 1]; |
114 } | 118 } |
115 } | 119 } |
116 | 120 |
117 #ifdef DEBUG_VIDEO_GEM | 121 #ifdef DEBUG_VIDEO_GEM |
118 for (i=0; i<h ;i++) { | 122 for (i = 0; i < h; i++) { |
119 printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, new_mform->mf_mask[i]); | 123 printf ("sdl:video:gem: cursor, line %d = 0x%04x\n", i, |
120 } | 124 new_mform->mf_mask[i]); |
125 } | |
121 | 126 |
122 printf("sdl:video:gem: CreateWMCursor(): done\n"); | 127 printf ("sdl:video:gem: CreateWMCursor(): done\n"); |
123 #endif | 128 #endif |
124 | 129 |
125 return cursor; | 130 return cursor; |
126 } | 131 } |
127 | 132 |
128 int GEM_ShowWMCursor(_THIS, WMcursor *cursor) | 133 int |
134 GEM_ShowWMCursor (_THIS, WMcursor * cursor) | |
129 { | 135 { |
130 /* | 136 /* |
131 if (cursor == NULL) { | 137 if (cursor == NULL) { |
132 graf_mouse(M_OFF, NULL); | 138 graf_mouse(M_OFF, NULL); |
133 } else if (cursor->mform_p) { | 139 } else if (cursor->mform_p) { |
134 graf_mouse(USER_DEF, cursor->mform_p); | 140 graf_mouse(USER_DEF, cursor->mform_p); |
135 } | 141 } |
136 */ | 142 */ |
137 #ifdef DEBUG_VIDEO_GEM | 143 #ifdef DEBUG_VIDEO_GEM |
138 printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); | 144 printf ("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); |
139 #endif | 145 #endif |
140 | 146 |
141 return 1; | 147 return 1; |
142 } | 148 } |
143 | 149 |
144 #if 0 | 150 #if 0 |
145 void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | 151 void |
152 GEM_WarpWMCursor (_THIS, Uint16 x, Uint16 y) | |
146 { | 153 { |
147 /* This seems to work only on AES 3.4 (Falcon) */ | 154 /* This seems to work only on AES 3.4 (Falcon) */ |
148 | 155 |
149 EVNTREC warpevent; | 156 EVNTREC warpevent; |
150 | |
151 warpevent.ap_event = APPEVNT_MOUSE; | |
152 warpevent.ap_value = (x << 16) | y; | |
153 | 157 |
154 appl_tplay(&warpevent, 1, 1000); | 158 warpevent.ap_event = APPEVNT_MOUSE; |
159 warpevent.ap_value = (x << 16) | y; | |
160 | |
161 appl_tplay (&warpevent, 1, 1000); | |
155 } | 162 } |
156 #endif | 163 #endif |
157 | 164 |
158 void GEM_CheckMouseMode(_THIS) | 165 void |
166 GEM_CheckMouseMode (_THIS) | |
159 { | 167 { |
160 /* If the mouse is hidden and input is grabbed, we use relative mode */ | 168 /* If the mouse is hidden and input is grabbed, we use relative mode */ |
161 if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) && | 169 if ((!(SDL_cursorstate & CURSOR_VISIBLE)) && |
162 /*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */ | 170 /*(this->input_grab != SDL_GRAB_OFF) && *//* Damn GEM can not grab */ |
163 (SDL_GetAppState() & SDL_APPACTIVE) ) { | 171 (SDL_GetAppState () & SDL_APPACTIVE)) { |
164 GEM_mouse_relative = SDL_TRUE; | 172 GEM_mouse_relative = SDL_TRUE; |
165 } else { | 173 } else { |
166 GEM_mouse_relative = SDL_FALSE; | 174 GEM_mouse_relative = SDL_FALSE; |
167 } | 175 } |
168 } | 176 } |
177 | |
178 /* vi: set ts=4 sw=4 expandtab: */ |