mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-02-02 00:32:22 +00:00
Corrected mouse co-ordinate processing after full screen resizing,
simplified mouse movement processing for full screen, added a few comments.
This commit is contained in:
parent
a69dcbb18f
commit
ef73063528
@ -50,7 +50,8 @@
|
|||||||
fullScreen; // Is this Emulator using the whole screen?
|
fullScreen; // Is this Emulator using the whole screen?
|
||||||
|
|
||||||
NSRect displayBox; // Cached dimensions of the screen
|
NSRect displayBox; // Cached dimensions of the screen
|
||||||
int screen_height;
|
|
||||||
|
int screen_height; // Height of the screen with the key window
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) benchmark;
|
- (void) benchmark;
|
||||||
@ -88,6 +89,7 @@
|
|||||||
- (BOOL) isFullScreen;
|
- (BOOL) isFullScreen;
|
||||||
- (BOOL) mouseInView: (NSEvent *) event;
|
- (BOOL) mouseInView: (NSEvent *) event;
|
||||||
- (BOOL) mouseInView;
|
- (BOOL) mouseInView;
|
||||||
|
- (void) fullscreenMouseMove;
|
||||||
- (BOOL) processMouseMove: (NSEvent *) event;
|
- (BOOL) processMouseMove: (NSEvent *) event;
|
||||||
|
|
||||||
#ifdef CGDRAWBITMAP
|
#ifdef CGDRAWBITMAP
|
||||||
|
@ -52,6 +52,14 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) awakeFromNib
|
||||||
|
{
|
||||||
|
// Here we store the height of the screen which the app was opened on.
|
||||||
|
// NSApplication's sendEvent: always uses that screen for its mouse co-ords
|
||||||
|
screen_height = (int) [[NSScreen mainScreen] frame].size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Mouse click in this window. If window is not active,
|
// Mouse click in this window. If window is not active,
|
||||||
// should the click be passed to this view?
|
// should the click be passed to this view?
|
||||||
- (BOOL) acceptsFirstMouse: (NSEvent *) event
|
- (BOOL) acceptsFirstMouse: (NSEvent *) event
|
||||||
@ -60,6 +68,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Key event processing.
|
||||||
|
// OS X doesn't send us separate events for the modifier keys
|
||||||
|
// (shift/control/command), so we need to monitor them separately
|
||||||
|
//
|
||||||
|
|
||||||
#include <adb.h>
|
#include <adb.h>
|
||||||
|
|
||||||
static int prevFlags;
|
static int prevFlags;
|
||||||
@ -101,6 +115,10 @@ static int prevFlags;
|
|||||||
prevFlags = flags;
|
prevFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Windowed mode. We only send mouse/key events
|
||||||
|
// if the OS X mouse is within the little screen
|
||||||
|
//
|
||||||
- (BOOL) mouseInView: (NSEvent *) event
|
- (BOOL) mouseInView: (NSEvent *) event
|
||||||
{
|
{
|
||||||
NSRect box;
|
NSRect box;
|
||||||
@ -183,6 +201,8 @@ static int prevFlags;
|
|||||||
imageWidth: (short) width
|
imageWidth: (short) width
|
||||||
imageHeight: (short) height
|
imageHeight: (short) height
|
||||||
{
|
{
|
||||||
|
D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
|
||||||
|
|
||||||
bitmap = theBitmap;
|
bitmap = theBitmap;
|
||||||
numBytes = [theBitmap bytesPerRow] * height;
|
numBytes = [theBitmap bytesPerRow] * height;
|
||||||
#endif
|
#endif
|
||||||
@ -191,8 +211,10 @@ static int prevFlags;
|
|||||||
imageWidth: (short) width
|
imageWidth: (short) width
|
||||||
imageHeight: (short) height
|
imageHeight: (short) height
|
||||||
{
|
{
|
||||||
|
D(NSLog(@"readyToDraw: theBitmap=%lx\n", [cgImgRef bitmap]));
|
||||||
|
|
||||||
cgImgRep = image;
|
cgImgRep = image;
|
||||||
numBytes = CGImageGetBytesPerRow(image);
|
numBytes = CGImageGetBytesPerRow(image) * height;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CGDRAWBITMAP
|
#ifdef CGDRAWBITMAP
|
||||||
- (void) readyToDraw: (void *) theBitmap
|
- (void) readyToDraw: (void *) theBitmap
|
||||||
@ -205,6 +227,8 @@ static int prevFlags;
|
|||||||
isPlanar: (BOOL) planar
|
isPlanar: (BOOL) planar
|
||||||
hasAlpha: (BOOL) alpha
|
hasAlpha: (BOOL) alpha
|
||||||
{
|
{
|
||||||
|
D(NSLog(@"readyToDraw: theBitmap=%lx\n", theBitmap));
|
||||||
|
|
||||||
bitmap = theBitmap;
|
bitmap = theBitmap;
|
||||||
bps = bitsPerSample;
|
bps = bitsPerSample;
|
||||||
spp = samplesPerPixel;
|
spp = samplesPerPixel;
|
||||||
@ -216,7 +240,6 @@ static int prevFlags;
|
|||||||
#endif
|
#endif
|
||||||
x = width, y = height;
|
x = width, y = height;
|
||||||
drawView = YES;
|
drawView = YES;
|
||||||
|
|
||||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||||
// [[self window] setInitialFirstResponder: self];
|
// [[self window] setInitialFirstResponder: self];
|
||||||
[[self window] makeFirstResponder: self];
|
[[self window] makeFirstResponder: self];
|
||||||
@ -233,7 +256,6 @@ static int prevFlags;
|
|||||||
|
|
||||||
fullScreen = YES;
|
fullScreen = YES;
|
||||||
memcpy(&displayBox, &displayBounds, sizeof(displayBox));
|
memcpy(&displayBox, &displayBounds, sizeof(displayBox));
|
||||||
screen_height = (int)displayBounds.size.height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (short) width
|
- (short) width
|
||||||
@ -298,6 +320,19 @@ static int prevFlags;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) fullscreenMouseMove
|
||||||
|
{
|
||||||
|
NSPoint location = [NSEvent mouseLocation];
|
||||||
|
|
||||||
|
D(NSLog (@"%s - loc.x=%f, loc.y=%f",
|
||||||
|
__PRETTY_FUNCTION__, location.x, location.y));
|
||||||
|
D(NSLog (@"%s - Sending ADBMouseMoved(%d,%d). (%d-%d)",
|
||||||
|
__PRETTY_FUNCTION__, (int)location.x,
|
||||||
|
screen_height - (int)location.y, screen_height, (int)location.y));
|
||||||
|
ADBMouseMoved((int)location.x, screen_height - (int)location.y);
|
||||||
|
}
|
||||||
|
|
||||||
static NSPoint mouse; // Previous/current mouse location
|
static NSPoint mouse; // Previous/current mouse location
|
||||||
|
|
||||||
- (BOOL) processMouseMove: (NSEvent *) event
|
- (BOOL) processMouseMove: (NSEvent *) event
|
||||||
@ -305,21 +340,21 @@ static NSPoint mouse; // Previous/current mouse location
|
|||||||
NSPoint location;
|
NSPoint location;
|
||||||
|
|
||||||
if ( fullScreen )
|
if ( fullScreen )
|
||||||
location = [NSEvent mouseLocation];
|
{
|
||||||
else
|
[self fullscreenMouseMove];
|
||||||
location = [self convertPoint: [event locationInWindow] fromView:nil];
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = [self convertPoint: [event locationInWindow] fromView:nil];
|
||||||
|
|
||||||
|
D(NSLog (@"%s - loc.x=%f, loc.y=%f",
|
||||||
|
__PRETTY_FUNCTION__, location.x, location.y));
|
||||||
|
|
||||||
if ( NSEqualPoints(location, mouse) )
|
if ( NSEqualPoints(location, mouse) )
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
mouse = location;
|
mouse = location;
|
||||||
|
|
||||||
if ( fullScreen )
|
|
||||||
{
|
|
||||||
ADBMouseMoved((int)mouse.x, screen_height - (int)mouse.y);
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CAN_RESIZE_VIEW
|
#ifdef CAN_RESIZE_VIEW
|
||||||
int mouseY = y - y * mouse.y / [self height];
|
int mouseY = y - y * mouse.y / [self height];
|
||||||
int mouseX = x * mouse.x / [self width];
|
int mouseX = x * mouse.x / [self width];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user