Search
lxdream.org :: lxdream/src/drivers/video_osx.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_osx.c
changeset 839:51f1c4195790
prev805:b355f7b3ff2e
next850:28782ebbd01d
author nkeynes
date Tue Sep 02 03:34:00 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Implement absolute positioning mouse mode when not grabbed
enable/disable grab on dreamcast start/stop where it's requested
by the controllers
file annotate diff log raw
1.1 --- a/src/drivers/video_osx.c Thu Aug 07 23:53:17 2008 +0000
1.2 +++ b/src/drivers/video_osx.c Tue Sep 02 03:34:00 2008 +0000
1.3 @@ -95,15 +95,17 @@
1.4 }
1.5 return nil;
1.6 }
1.7 -- (void)requestGrab
1.8 +- (BOOL)requestGrab
1.9 {
1.10 if( delegate && [delegate respondsToSelector: @selector(viewRequestedGrab:)] )
1.11 - [delegate performSelector: @selector(viewRequestedGrab:) withObject: self];
1.12 + return [delegate performSelector: @selector(viewRequestedGrab:) withObject: self] != nil;
1.13 + return NO;
1.14 }
1.15 -- (void)requestUngrab
1.16 +- (BOOL)requestUngrab
1.17 {
1.18 if( delegate && [delegate respondsToSelector: @selector(viewRequestedUngrab:)] )
1.19 - [delegate performSelector: @selector(viewRequestedUngrab:) withObject: self];
1.20 + return [delegate performSelector: @selector(viewRequestedUngrab:) withObject: self] != nil;
1.21 + return NO;
1.22 }
1.23 - (BOOL)isOpaque
1.24 {
1.25 @@ -153,63 +155,73 @@
1.26 flagsMask[keycode] = 0;
1.27 }
1.28 }
1.29 +- (void)emitButtonEvent: (NSEvent *)event buttons: (int)buttons
1.30 +{
1.31 + if( isGrabbed ) {
1.32 + input_event_mouse( buttons, 0, 0, FALSE );
1.33 + } else {
1.34 + NSPoint pt = [event locationInWindow];
1.35 + input_event_mouse( buttonMask, (int)pt.x, (int)pt.y, TRUE );
1.36 + }
1.37 +}
1.38 +
1.39 - (void)mouseDown: (NSEvent *) event
1.40 {
1.41 - if( isGrabbed ) {
1.42 - buttonMask |= 1;
1.43 - input_event_mouse( buttonMask, 0, 0 );
1.44 - } else {
1.45 - [self requestGrab];
1.46 + buttonMask |= 1;
1.47 + // If using grab but not grabbed yet, the first click should be consumed
1.48 + // by the grabber. In all other circumstances we process normally.
1.49 + if( isGrabbed || ![self requestGrab] ) {
1.50 + [self emitButtonEvent: event buttons: buttonMask];
1.51 }
1.52 }
1.53 - (void)mouseUp: (NSEvent *)event
1.54 {
1.55 buttonMask &= ~1;
1.56 - input_event_mouse( buttonMask, 0, 0 );
1.57 + [self emitButtonEvent: event buttons: buttonMask];
1.58 }
1.59
1.60 - (void)rightMouseDown: (NSEvent *) event
1.61 {
1.62 buttonMask |= 2;
1.63 - input_event_mouse( buttonMask, 0, 0 );
1.64 + [self emitButtonEvent: event buttons: buttonMask];
1.65 }
1.66 - (void)rightMouseUp: (NSEvent *)event
1.67 {
1.68 buttonMask &= ~2;
1.69 - input_event_mouse( buttonMask, 0, 0 );
1.70 + [self emitButtonEvent: event buttons: buttonMask];
1.71 }
1.72 - (void)otherMouseDown: (NSEvent *) event
1.73 {
1.74 buttonMask |= (1<< [event buttonNumber] );
1.75 - input_event_mouse( buttonMask, 0, 0 );
1.76 + [self emitButtonEvent: event buttons: buttonMask];
1.77 }
1.78 - (void)otherMouseUp: (NSEvent *) event
1.79 {
1.80 buttonMask &= ~(1<< [event buttonNumber] );
1.81 - input_event_mouse( buttonMask, 0, 0 );
1.82 + [self emitButtonEvent: event buttons: buttonMask];
1.83 }
1.84 - (void)mouseMoved: (NSEvent *) event
1.85 {
1.86 if( isGrabbed ) {
1.87 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE );
1.88 + input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.89 }
1.90 }
1.91 - (void)mouseDragged: (NSEvent *) event
1.92 {
1.93 if( isGrabbed ) {
1.94 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE );
1.95 + input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.96 }
1.97 }
1.98 - (void)rightMouseDragged: (NSEvent *) event
1.99 {
1.100 if( isGrabbed ) {
1.101 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE );
1.102 + input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.103 }
1.104 }
1.105 - (void)otherMouseDragged: (NSEvent *) event
1.106 {
1.107 if( isGrabbed ) {
1.108 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE );
1.109 + input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.110 }
1.111 }
1.112
.