From 57979ea033bc09314499ff4a23179129e25d5190 Mon Sep 17 00:00:00 2001 From: markgrebe Date: Sat, 28 May 2005 21:50:07 +0000 Subject: [PATCH] Added handling of Cmd-h, Cmd-m, and Cmd-? back into Macintosh version, as these are standard Mac OS Key shortcuts git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@451 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/EventHandler.cxx | 16 +- stella/src/macosx/Menus.m | 333 +----------------- stella/src/macosx/SDLMain.nib/objects.nib | Bin 1486 -> 1501 bytes .../src/macosx/stella.pbproj/project.pbxproj | 18 + 4 files changed, 46 insertions(+), 321 deletions(-) diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 4ccc29755..d8f873299 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.64 2005-05-28 17:25:41 stephena Exp $ +// $Id: EventHandler.cxx,v 1.65 2005-05-28 21:50:07 markgrebe Exp $ //============================================================================ #include @@ -38,6 +38,12 @@ #include "Snapshot.hxx" #endif +#ifdef MAC_OSX +extern "C" { +void handleMacOSXKeypress(int key); +} +#endif + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventHandler::EventHandler(OSystem* osystem) : myOSystem(osystem), @@ -284,6 +290,14 @@ void EventHandler::poll(uInt32 time) handleEvent(Event::Quit, 1); break; +#ifdef MAC_OSX + case SDLK_h: + case SDLK_m: + case SDLK_SLASH: + handleMacOSXKeypress(int(key)); + break; +#endif + case SDLK_g: // don't change grabmouse in fullscreen mode if(!myOSystem->frameBuffer().fullScreen()) diff --git a/stella/src/macosx/Menus.m b/stella/src/macosx/Menus.m index 09b8bffcd..570c4ae37 100755 --- a/stella/src/macosx/Menus.m +++ b/stella/src/macosx/Menus.m @@ -4,24 +4,15 @@ Mark Grebe */ -/* $Id: Menus.m,v 1.5 2005-02-26 22:16:24 markgrebe Exp $ */ +/* $Id: Menus.m,v 1.6 2005-05-28 21:50:07 markgrebe Exp $ */ #import -#import "Menus.h" #import "SDL.h" #define QZ_m 0x2E #define QZ_o 0x1F #define QZ_h 0x04 #define QZ_SLASH 0x2C -#define QZ_COMMA 0x2B - -extern void soundMute(int state); -extern void setPaddleMode(int mode); -extern void getPrefsSettings(int *gl, int *volume, float *aspect, const char **romdir); -extern void setPrefsSettings(int gl, int volume, float aspect, const char *romdir); -void getRomdirSetting(char *romdir); - /*------------------------------------------------------------------------------ * releaseCmdKeys - This method fixes an issue when modal windows are used with @@ -49,51 +40,6 @@ void releaseCmdKeys(NSString *character, int keyCode) [NSApp postEvent:event2 atStart:NO]; } -/*------------------------------------------------------------------------------ -* browseFile - This allows the user to chose a file to read in. -*-----------------------------------------------------------------------------*/ -char *browseFile(void) { - NSOpenPanel *openPanel = nil; - char *fileName; - NSString *dirName; - char cdirName[FILENAME_MAX]; - - soundMute(1); - fileName = malloc(FILENAME_MAX); - if (fileName == NULL) - { - soundMute(0); - return NULL; - } - - getRomdirSetting(cdirName); - dirName = [NSString stringWithCString:cdirName]; - - openPanel = [NSOpenPanel openPanel]; - [openPanel setCanChooseDirectories:NO]; - [openPanel setCanChooseFiles:YES]; - - if ([openPanel runModalForDirectory:dirName file:nil types:nil] == NSOKButton) { - [[[openPanel filenames] objectAtIndex:0] getCString:fileName]; - releaseCmdKeys(@"o",QZ_o); - [dirName release]; - soundMute(0); - return fileName; - } - else { - releaseCmdKeys(@"o",QZ_o); - [dirName release]; - soundMute(0); - return NULL; - } - } - -void prefsStart(void) -{ - [[Menus sharedInstance] prefsStart]; - releaseCmdKeys(@",",QZ_m); -} - void hideApp(void) { [NSApp hide:nil]; releaseCmdKeys(@"h",QZ_h); @@ -109,269 +55,16 @@ void miniturizeWindow(void) { releaseCmdKeys(@"m",QZ_m); } -void initVideoMenu(int openGl) -{ - [[Menus sharedInstance] initVideoMenu:openGl]; +void handleMacOSXKeypress(int key) { + switch(key) { + case SDLK_h: + hideApp(); + break; + case SDLK_m: + miniturizeWindow(); + break; + case SDLK_SLASH: + showHelp(); + break; + } } - -void setPaddleMenu(int number) -{ - if (number < 4) - [[Menus sharedInstance] setPaddleMenu:number]; -} - -void setSpeedLimitMenu(int limit) -{ - [[Menus sharedInstance] setSpeedLimitMenu:limit]; -} - -void enableGameMenus(void) -{ - [[Menus sharedInstance] enableGameMenus]; -} - -@implementation Menus - -static Menus *sharedInstance = nil; - -+ (Menus *)sharedInstance { - return sharedInstance ? sharedInstance : [[self alloc] init]; -} - -- (id)init -{ - sharedInstance = self; - gameMenusEnabled = 0; - return(self); -} - -/*------------------------------------------------------------------------------ -* browseDir - Method which allows user to choose a directory. -*-----------------------------------------------------------------------------*/ -- (NSString *) browseDir { - NSOpenPanel *openPanel; - - openPanel = [NSOpenPanel openPanel]; - [openPanel setCanChooseDirectories:YES]; - [openPanel setCanChooseFiles:NO]; - - if ([openPanel runModalForTypes:nil] == NSOKButton) - return([[openPanel filenames] objectAtIndex:0]); - else - return nil; - } - -- (void)setSpeedLimitMenu:(int)limit -{ - if (limit) - [limitSpeedMenu setState:NSOnState]; - else - [limitSpeedMenu setState:NSOffState]; -} - -- (void)setPaddleMenu:(int)number -{ - int i; - - for (i=0;i<4;i++) - [[paddlesMenu itemAtIndex:i] setState:NSOffState]; - if (number < 4) - [[paddlesMenu itemAtIndex:number] setState:NSOnState]; -} - -- (void)initVideoMenu:(int)openGl -{ - openGlEnabled = openGl; -} - -- (void)enableGameMenus -{ - gameMenusEnabled = 1; -} - -- (IBAction) paddleChange:(id) sender -{ - setPaddleMode([sender tag]); - [self setPaddleMenu:[sender tag]]; -} - -- (void) prefsStart -{ - int gl, volume; - float aspectRatio; - const char *romdir; - const char *newRomdir; - NSString *romDirString; - - soundMute(1); - getPrefsSettings(&gl, &volume, &aspectRatio, &romdir); - romDirString = [NSString stringWithCString:romdir]; - - [volumeSlider setIntValue:volume]; - [videoModeMatrix selectCellWithTag:gl]; - [aspectRatioField setFloatValue:aspectRatio]; - [romDirField setStringValue:romDirString]; - - [NSApp runModalForWindow:[volumeSlider window]]; - - gl = [[videoModeMatrix selectedCell] tag]; - volume = [volumeSlider intValue]; - aspectRatio = [aspectRatioField floatValue]; - romDirString = [romDirField stringValue]; - newRomdir = [romDirString cString]; - - setPrefsSettings(gl, volume, aspectRatio, newRomdir); - soundMute(0); -} - -- (IBAction) prefsOK:(id) sender -{ - [NSApp stopModal]; - [[volumeSlider window] close]; -} - -- (IBAction) romdirSelect:(id) sender -{ - NSString *directory; - - directory = [self browseDir]; - if (directory != nil) - [romDirField setStringValue:directory]; -} - -- (IBAction)prefsMenu:(id)sender -{ - [[Menus sharedInstance] prefsStart]; -} - --(void)pushKeyEvent:(int)key:(bool)shift -{ - SDL_Event theEvent; - - theEvent.key.type = SDL_KEYDOWN; - theEvent.key.state = SDL_PRESSED; - theEvent.key.keysym.scancode = 0; - theEvent.key.keysym.sym = key; - theEvent.key.keysym.mod = KMOD_LMETA; - if (shift) - theEvent.key.keysym.mod |= KMOD_LSHIFT; - theEvent.key.keysym.unicode = 0; - SDL_PushEvent(&theEvent); -} - -- (IBAction)biggerScreen:(id)sender -{ - [self pushKeyEvent:SDLK_EQUALS:NO]; -} - -- (IBAction)smallerScreen:(id)sender -{ - [self pushKeyEvent:SDLK_MINUS:NO]; -} - -- (IBAction)fullScreen:(id)sender -{ - [self pushKeyEvent:SDLK_RETURN:NO]; -} - -- (IBAction)openCart:(id)sender -{ - [self pushKeyEvent:SDLK_o:NO]; -} - -- (IBAction)restartGame:(id)sender -{ - [self pushKeyEvent:SDLK_r:NO]; -} - -- (IBAction)speedLimit:(id)sender -{ - [self pushKeyEvent:SDLK_l:NO]; -} - -- (IBAction)pauseGame:(id)sender -{ - [self pushKeyEvent:SDLK_p:NO]; -} - -- (IBAction)ntscPalMode:(id)sender -{ - [self pushKeyEvent:SDLK_f:YES]; -} - -- (IBAction)toggleGlFilter:(id)sender -{ - [self pushKeyEvent:SDLK_f:NO]; -} - -- (IBAction)togglePallette:(id)sender -{ - [self pushKeyEvent:SDLK_p:YES]; -} - -- (IBAction)grabMouse:(id)sender -{ - [self pushKeyEvent:SDLK_g:NO]; -} - -- (IBAction)xStartPlus:(id)sender -{ - [self pushKeyEvent:SDLK_HOME:NO]; -} - -- (IBAction)xStartMinus:(id)sender -{ - [self pushKeyEvent:SDLK_END:NO]; -} - -- (IBAction)yStartPlus:(id)sender -{ - [self pushKeyEvent:SDLK_PAGEUP:NO]; -} - -- (IBAction)yStartMinus:(id)sender -{ - [self pushKeyEvent:SDLK_PAGEDOWN:NO]; -} - -- (IBAction)widthPlus:(id)sender -{ - [self pushKeyEvent:SDLK_END:YES]; -} - -- (IBAction)widthMinus:(id)sender -{ - [self pushKeyEvent:SDLK_HOME:YES]; -} - -- (IBAction)heightPlus:(id)sender -{ - [self pushKeyEvent:SDLK_PAGEUP:YES]; -} - -- (IBAction)heightMinus:(id)sender -{ - [self pushKeyEvent:SDLK_PAGEDOWN:YES]; -} - -- (BOOL)validateMenuItem:(id )menuItem -{ - if (gameMenusEnabled) { - if ([[menuItem title] isEqualToString:@"Toggle Open GL Filter"]) { - if (openGlEnabled) - return YES; - else - return NO; - } - else - return YES; - } - else { - if ([[menuItem title] isEqualToString:@"Open New CartridgeÉ"] || - [[menuItem title] isEqualToString:@"Preferences..."]) - return YES; - else - return NO; - } -} -@end diff --git a/stella/src/macosx/SDLMain.nib/objects.nib b/stella/src/macosx/SDLMain.nib/objects.nib index 988bc4aab9ff325b29c7f4301f85ac9faef2b6f3..045694e61d71703962c3258f668be7e34300f65c 100644 GIT binary patch delta 597 zcmYLFO=}ZT6n$?@Fq(Fy!E{j!A_(FpUD~lQk+pWL)3)>r!Jg%;5y)sVdBHcgMkNLcOhMVp4%=N)r@MWd1i(OV;6=V zv|FthOy7fR9W`TtS%w*V0w!`L0(?2>nt+i^i=-c=(`f;Y#Fn--ojs_evNc1x!7L~& z@K5~{;T0!M9Otw6gVT?A$;lD6IlaI>Cjx(R`W0K8enNK@XPo@PDJMP-IRW(6 d@s!ig_=S@OjyO5MZ=Aft0VjtzDcQZ~>R;YE6aWAK delta 632 zcma)2&ubGw82u(cU^P7`_8>xW4+YU%^kREzK}rvX9131MEp$v)(oNW;6ug89*}8__C=c<_(VIGgsOf^@#qy!XEEJ>KWkyVSE^1Z?t} zv>czLt3ea$jmFZpzDw1ed-v7NQi-=}a0#GRozLfBy|UUCShgH)*I(GD`qV<7t>md$ zK8IY{$rlgQ%|hWHZTipKwG9Ah{ny{IV-IBZAF*4P$BXPr6nmQ%WNznXeErVf+bfOE1tH zWi@+XP?L*LLcql&s%@)iRMd=SXt{{-C8K0C-N;a5U;4=}xy{8;Didk>xEMLB361m| zp18g|Yj<7AB=fTRbuP=DwfoK>u~z-icBhh1c4>j;v bin BIN + zip + ZIP CFBundleTypeName Atari 2600 Cartridge File @@ -666,6 +669,7 @@ 2DDBEB7E08457B7D00812C11, 2DDBEBE6084582C400812C11, 2DDFFA2A0847EF4E00201CC8, + 2D47A45308491D4500ABFB6A, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -788,6 +792,20 @@ settings = { }; }; + 2D47A45208491D4500ABFB6A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = Menus.m; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 2D47A45308491D4500ABFB6A = { + fileRef = 2D47A45208491D4500ABFB6A; + isa = PBXBuildFile; + settings = { + }; + }; 2D733D5D062893E7006265D9 = { fileEncoding = 30; isa = PBXFileReference;