23 #if SDL_VIDEO_DRIVER_COCOA
30 #include "../../events/SDL_mouse_c.h"
38 static unsigned char cursorBytes[] = {
39 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xF9, 0x04,
41 0x01, 0x00, 0x00, 0x01, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x10,
42 0x00, 0x10, 0x00, 0x00, 0x02, 0x0E, 0x8C, 0x8F, 0xA9, 0xCB, 0xED,
43 0x0F, 0xA3, 0x9C, 0xB4, 0xDA, 0x8B, 0xB3, 0x3E, 0x05, 0x00, 0x3B
46 NSData *cursorData = [NSData dataWithBytesNoCopy:&cursorBytes[0]
47 length:sizeof(cursorBytes)
49 NSImage *cursorImage = [[[NSImage alloc] initWithData:cursorData] autorelease];
60 Cocoa_CreateDefaultCursor()
62 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
66 nscursor = [NSCursor arrowCursor];
84 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
86 NSCursor *nscursor =
NULL;
91 nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)];
111 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
112 NSCursor *nscursor =
NULL;
118 nscursor = [NSCursor arrowCursor];
121 nscursor = [NSCursor IBeamCursor];
124 nscursor = [NSCursor arrowCursor];
127 nscursor = [NSCursor crosshairCursor];
130 nscursor = [NSCursor arrowCursor];
134 nscursor = [NSCursor closedHandCursor];
137 nscursor = [NSCursor resizeLeftRightCursor];
140 nscursor = [NSCursor resizeUpDownCursor];
143 nscursor = [NSCursor closedHandCursor];
146 nscursor = [NSCursor operationNotAllowedCursor];
149 nscursor = [NSCursor pointingHandCursor];
173 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
174 NSCursor *nscursor = (NSCursor *)cursor->
driverdata;
185 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
189 for (; window !=
NULL; window = window->
next) {
192 [driverdata->nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
193 withObject:[driverdata->nswindow contentView]
207 CGPoint point = CGPointMake(x, y);
211 point.x += window->x;
212 point.
y += window->y;
220 NSPoint
location = [NSEvent mouseLocation];
229 CGSetLocalEventsSuppressionInterval(0.0);
230 CGWarpMouseCursorPosition(point);
231 CGSetLocalEventsSuppressionInterval(0.25);
247 result = CGAssociateMouseAndMouseCursorPosition(NO);
249 result = CGAssociateMouseAndMouseCursorPosition(YES);
251 if (result != kCGErrorSuccess) {
252 return SDL_SetError(
"CGAssociateMouseAndMouseCursorPosition() failed");
282 ([event
type] == NSMouseMoved ||
283 [event
type] == NSLeftMouseDragged ||
284 [event
type] == NSRightMouseDragged ||
285 [event
type] == NSOtherMouseDragged)) {
300 float x = [event deltaX];
301 float y = [event deltaY];
void Cocoa_InitMouse(_THIS)
SDL_Mouse * SDL_GetMouse(void)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
GLenum GLsizei const GLuint GLboolean enabled
A collection of pixels used in software blitting.
DECLSPEC void SDLCALL SDL_free(void *mem)
void(* FreeCursor)(SDL_Cursor *cursor)
void Cocoa_QuitMouseEventTap(SDL_MouseData *driverdata)
NSImage * Cocoa_CreateImage(SDL_Surface *surface)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
void Cocoa_QuitMouse(_THIS)
int(* ShowCursor)(SDL_Cursor *cursor)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor.
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
NSCursor * invisibleCursor()
int(* SetRelativeMouseMode)(SDL_bool enabled)
void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
void Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
#define SDL_assert(condition)
EGLSurface EGLint EGLint y
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, int x, int y)
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
void Cocoa_InitMouseEventTap(SDL_MouseData *driverdata)
void(* WarpMouse)(SDL_Window *window, int x, int y)