mirror of https://github.com/stella-emu/stella.git
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
This commit is contained in:
parent
ce294522a7
commit
57979ea033
|
@ -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 <algorithm>
|
||||
|
@ -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())
|
||||
|
|
|
@ -4,24 +4,15 @@
|
|||
Mark Grebe <atarimac@cox.net>
|
||||
|
||||
*/
|
||||
/* $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 <Cocoa/Cocoa.h>
|
||||
#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 <NSMenuItem>)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
|
||||
|
|
Binary file not shown.
|
@ -11,6 +11,7 @@
|
|||
F5A47A9E01A0483001D3D55B,
|
||||
2DDBEBE3084582C400812C11,
|
||||
2DDBEBE4084582C400812C11,
|
||||
2D47A45208491D4500ABFB6A,
|
||||
);
|
||||
isa = PBXGroup;
|
||||
name = Classes;
|
||||
|
@ -427,6 +428,8 @@
|
|||
<array>
|
||||
<string>bin</string>
|
||||
<string>BIN</string>
|
||||
<string>zip</string>
|
||||
<string>ZIP</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Atari 2600 Cartridge File</string>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue