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 850:28782ebbd01d
prev839:51f1c4195790
next854:130928a3cdcb
author nkeynes
date Mon Sep 08 07:56:33 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Add lightgun support
file annotate diff log raw
1.1 --- a/src/drivers/video_osx.c Tue Sep 02 03:34:00 2008 +0000
1.2 +++ b/src/drivers/video_osx.c Mon Sep 08 07:56:33 2008 +0000
1.3 @@ -60,7 +60,6 @@
1.4
1.5 @interface LxdreamOSXView : LxdreamVideoView
1.6 {
1.7 - int buttonMask;
1.8 int flagsMask[MAX_MASK_KEYCODE];
1.9 }
1.10 @end
1.11 @@ -87,7 +86,6 @@
1.12 if( [super initWithFrame: contentRect] != nil ) {
1.13 int i;
1.14 isGrabbed = NO;
1.15 - buttonMask = 0;
1.16 for( i=0; i<MAX_MASK_KEYCODE; i++ ) {
1.17 flagsMask[i] = 0;
1.18 }
1.19 @@ -155,74 +153,87 @@
1.20 flagsMask[keycode] = 0;
1.21 }
1.22 }
1.23 -- (void)emitButtonEvent: (NSEvent *)event buttons: (int)buttons
1.24 +- (void)emitMouseDownEvent: (NSEvent *)event button: (int)button
1.25 {
1.26 if( isGrabbed ) {
1.27 - input_event_mouse( buttons, 0, 0, FALSE );
1.28 + input_event_mousedown( button, 0, 0, FALSE );
1.29 } else {
1.30 NSPoint pt = [event locationInWindow];
1.31 - input_event_mouse( buttonMask, (int)pt.x, (int)pt.y, TRUE );
1.32 + input_event_mousedown( button, (int)(pt.x * DISPLAY_WIDTH) / video_width,
1.33 + DISPLAY_HEIGHT - ((int)(pt.y * DISPLAY_HEIGHT) / video_height), TRUE );
1.34 + }
1.35 +}
1.36 +- (void)emitMouseUpEvent: (NSEvent *)event button: (int)button
1.37 +{
1.38 + if( isGrabbed ) {
1.39 + input_event_mouseup( button, 0, 0, FALSE );
1.40 + } else {
1.41 + NSPoint pt = [event locationInWindow];
1.42 + input_event_mouseup( button, (int)(pt.x * DISPLAY_WIDTH) / video_width,
1.43 + DISPLAY_HEIGHT - ((int)(pt.y * DISPLAY_HEIGHT) / video_height), TRUE );
1.44 + }
1.45 +}
1.46 +- (void)emitMouseMoveEvent: (NSEvent *)event
1.47 +{
1.48 + if( isGrabbed ) {
1.49 + input_event_mousemove( [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.50 + } else {
1.51 + NSPoint pt = [event locationInWindow];
1.52 + input_event_mousemove( (int)(pt.x * DISPLAY_WIDTH) / video_width,
1.53 + DISPLAY_HEIGHT - ((int)(pt.y * DISPLAY_HEIGHT) / video_height), TRUE );
1.54 + }
1.55 +}
1.56 +- (void)mouseExited: (NSEvent *)event
1.57 +{
1.58 + if( !isGrabbed ) {
1.59 + input_event_mousemove( -1, -1, TRUE );
1.60 }
1.61 }
1.62
1.63 - (void)mouseDown: (NSEvent *) event
1.64 {
1.65 - buttonMask |= 1;
1.66 // If using grab but not grabbed yet, the first click should be consumed
1.67 // by the grabber. In all other circumstances we process normally.
1.68 if( isGrabbed || ![self requestGrab] ) {
1.69 - [self emitButtonEvent: event buttons: buttonMask];
1.70 + [self emitMouseDownEvent: event button: 0];
1.71 }
1.72 }
1.73 - (void)mouseUp: (NSEvent *)event
1.74 {
1.75 - buttonMask &= ~1;
1.76 - [self emitButtonEvent: event buttons: buttonMask];
1.77 + [self emitMouseUpEvent: event button: 0];
1.78 }
1.79
1.80 - (void)rightMouseDown: (NSEvent *) event
1.81 {
1.82 - buttonMask |= 2;
1.83 - [self emitButtonEvent: event buttons: buttonMask];
1.84 + [self emitMouseDownEvent: event button: 1];
1.85 }
1.86 - (void)rightMouseUp: (NSEvent *)event
1.87 {
1.88 - buttonMask &= ~2;
1.89 - [self emitButtonEvent: event buttons: buttonMask];
1.90 + [self emitMouseUpEvent: event button: 1];
1.91 }
1.92 - (void)otherMouseDown: (NSEvent *) event
1.93 {
1.94 - buttonMask |= (1<< [event buttonNumber] );
1.95 - [self emitButtonEvent: event buttons: buttonMask];
1.96 + [self emitMouseDownEvent: event button: [event buttonNumber]];
1.97 }
1.98 - (void)otherMouseUp: (NSEvent *) event
1.99 {
1.100 - buttonMask &= ~(1<< [event buttonNumber] );
1.101 - [self emitButtonEvent: event buttons: buttonMask];
1.102 + [self emitMouseUpEvent: event button: [event buttonNumber]];
1.103 }
1.104 - (void)mouseMoved: (NSEvent *) event
1.105 {
1.106 - if( isGrabbed ) {
1.107 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.108 - }
1.109 + [self emitMouseMoveEvent: event];
1.110 }
1.111 - (void)mouseDragged: (NSEvent *) event
1.112 {
1.113 - if( isGrabbed ) {
1.114 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.115 - }
1.116 + [self emitMouseMoveEvent: event];
1.117 }
1.118 - (void)rightMouseDragged: (NSEvent *) event
1.119 {
1.120 - if( isGrabbed ) {
1.121 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.122 - }
1.123 + [self emitMouseMoveEvent: event];
1.124 }
1.125 - (void)otherMouseDragged: (NSEvent *) event
1.126 {
1.127 - if( isGrabbed ) {
1.128 - input_event_mouse( buttonMask, [event deltaX] * MOUSE_X_SCALE, [event deltaY] * MOUSE_Y_SCALE, FALSE );
1.129 - }
1.130 + [self emitMouseMoveEvent: event];
1.131 }
1.132
1.133 @end
.