Added Mac Menus for key insertion events back in

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@459 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
markgrebe 2005-06-03 05:05:05 +00:00
parent b4de09b4f8
commit 9ac5d2a4d2
4 changed files with 187 additions and 27 deletions

View File

@ -4,40 +4,21 @@
Mark Grebe <atarimac@cox.net>
*/
/* $Id: Menus.h,v 1.4 2005-02-18 05:31:47 markgrebe Exp $ */
/* $Id: Menus.h,v 1.5 2005-06-03 05:04:56 markgrebe Exp $ */
#import <Cocoa/Cocoa.h>
@interface Menus : NSObject {
IBOutlet id limitSpeedMenu;
IBOutlet id paddlesMenu;
IBOutlet id filterMenu;
IBOutlet id videoModeMatrix;
IBOutlet id volumeSlider;
IBOutlet id aspectRatioField;
IBOutlet id romDirField;
int openGlEnabled;
int gameMenusEnabled;
}
+ (Menus *)sharedInstance;
- (NSString *) browseDir;
- (void)setSpeedLimitMenu:(int)limit;
- (void)initVideoMenu:(int)openGl;
- (void)setPaddleMenu:(int)number;
- (void)prefsStart;
- (void)enableGameMenus;
- (void)pushKeyEvent:(int)key:(bool)shift;
- (IBAction) paddleChange:(id) sender;
- (IBAction) prefsOK:(id) sender;
- (IBAction) romdirSelect:(id) sender;
- (IBAction)prefsMenu:(id)sender;
- (void)pushKeyEvent:(int)key:(bool)shift:(bool)cmd;
- (IBAction)paddleChange:(id) sender;
- (IBAction)biggerScreen:(id)sender;
- (IBAction)smallerScreen:(id)sender;
- (IBAction)fullScreen:(id)sender;
- (IBAction)openCart:(id)sender;
- (IBAction)restartGame:(id)sender;
- (IBAction)speedLimit:(id)sender;
- (IBAction)pauseGame:(id)sender;
- (IBAction)ntscPalMode:(id)sender;
- (IBAction)togglePallette:(id)sender;
@ -51,5 +32,8 @@
- (IBAction)widthMinus:(id)sender;
- (IBAction)heightPlus:(id)sender;
- (IBAction)heightMinus:(id)sender;
- (IBAction)doPrefs:(id)sender;
- (IBAction)volumePlus:(id)sender;
- (IBAction)volumeMinus:(id)sender;
@end

View File

@ -4,10 +4,11 @@
Mark Grebe <atarimac@cox.net>
*/
/* $Id: Menus.m,v 1.6 2005-05-28 21:50:07 markgrebe Exp $ */
/* $Id: Menus.m,v 1.7 2005-06-03 05:05:05 markgrebe Exp $ */
#import <Cocoa/Cocoa.h>
#import "SDL.h"
#import "Menus.h"
#define QZ_m 0x2E
#define QZ_o 0x1F
@ -68,3 +69,160 @@ void handleMacOSXKeypress(int key) {
break;
}
}
@implementation Menus
static Menus *sharedInstance = nil;
+ (Menus *)sharedInstance {
return sharedInstance ? sharedInstance : [[self alloc] init];
}
- (id)init
{
sharedInstance = self;
return(self);
}
-(void)pushKeyEvent:(int)key:(bool)shift:(bool)cmd
{
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 = 0;
if (cmd)
theEvent.key.keysym.mod = KMOD_LMETA;
if (shift)
theEvent.key.keysym.mod |= KMOD_LSHIFT;
theEvent.key.keysym.unicode = 0;
SDL_PushEvent(&theEvent);
}
- (IBAction) paddleChange:(id) sender
{
switch([sender tag])
{
case 0:
[self pushKeyEvent:SDLK_0:NO:YES];
break;
case 1:
[self pushKeyEvent:SDLK_1:NO:YES];
break;
case 2:
[self pushKeyEvent:SDLK_2:NO:YES];
break;
case 3:
[self pushKeyEvent:SDLK_3:NO:YES];
break;
}
}
- (IBAction)biggerScreen:(id)sender
{
[self pushKeyEvent:SDLK_EQUALS:YES:YES];
}
- (IBAction)smallerScreen:(id)sender
{
[self pushKeyEvent:SDLK_MINUS:YES:YES];
}
- (IBAction)fullScreen:(id)sender
{
[self pushKeyEvent:SDLK_RETURN:NO:YES];
}
- (IBAction)openCart:(id)sender
{
[self pushKeyEvent:SDLK_ESCAPE:NO:NO];
}
- (IBAction)restartGame:(id)sender
{
[self pushKeyEvent:SDLK_r:NO:YES];
}
- (IBAction)pauseGame:(id)sender
{
[self pushKeyEvent:SDLK_PAUSE:NO:NO];
}
- (IBAction)ntscPalMode:(id)sender
{
[self pushKeyEvent:SDLK_f:NO:YES];
}
- (IBAction)toggleGlFilter:(id)sender
{
[self pushKeyEvent:SDLK_f:YES:YES];
}
- (IBAction)togglePallette:(id)sender
{
[self pushKeyEvent:SDLK_p:NO:YES];
}
- (IBAction)grabMouse:(id)sender
{
[self pushKeyEvent:SDLK_g:NO:YES];
}
- (IBAction)xStartPlus:(id)sender
{
[self pushKeyEvent:SDLK_HOME:YES:YES];
}
- (IBAction)xStartMinus:(id)sender
{
[self pushKeyEvent:SDLK_END:YES:YES];
}
- (IBAction)yStartPlus:(id)sender
{
[self pushKeyEvent:SDLK_PAGEUP:YES:YES];
}
- (IBAction)yStartMinus:(id)sender
{
[self pushKeyEvent:SDLK_PAGEDOWN:YES:YES];
}
- (IBAction)widthPlus:(id)sender
{
[self pushKeyEvent:SDLK_END:NO:YES];
}
- (IBAction)widthMinus:(id)sender
{
[self pushKeyEvent:SDLK_HOME:NO:YES];
}
- (IBAction)heightPlus:(id)sender
{
[self pushKeyEvent:SDLK_PAGEUP:NO:YES];
}
- (IBAction)heightMinus:(id)sender
{
[self pushKeyEvent:SDLK_PAGEDOWN:NO:YES];
}
- (IBAction)doPrefs:(id)sender
{
[self pushKeyEvent:SDLK_TAB:NO:NO];
}
- (IBAction)volumePlus:(id)sender
{
[self pushKeyEvent:SDLK_RIGHTBRACKET:YES:YES];
}
- (IBAction)volumeMinus:(id)sender
{
[self pushKeyEvent:SDLK_LEFTBRACKET:YES:YES];
}
@end

View File

@ -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: OSystemMACOSX.cxx,v 1.2 2005-05-28 21:06:41 markgrebe Exp $
// $Id: OSystemMACOSX.cxx,v 1.3 2005-06-03 05:05:05 markgrebe Exp $
//============================================================================
#include <cstdlib>
@ -149,12 +149,12 @@ void OSystemMACOSX::mainLoop()
myFrameBuffer->update();
currentTime = getTicks();
virtualTime += myTimePerFrame;
virtualTime = startTime + myTimePerFrame;
if(currentTime < virtualTime)
{
SDL_Delay((virtualTime - currentTime)/1000);
SDL_Delay((virtualTime - currentTime)/1000);
}
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;

View File

@ -11,6 +11,7 @@
F5A47A9E01A0483001D3D55B,
2DDBEBE3084582C400812C11,
2DDBEBE4084582C400812C11,
2D62C40E085011050063A4A3,
2D47A45208491D4500ABFB6A,
);
isa = PBXGroup;
@ -428,6 +429,8 @@
<array>
<string>bin</string>
<string>BIN</string>
<string>rom</string>
<string>ROM</string>
<string>zip</string>
<string>ZIP</string>
</array>
@ -565,6 +568,7 @@
2DDBEB7F08457B7D00812C11,
2DDBEBE5084582C400812C11,
2DDFFA2B0847EF4E00201CC8,
2D62C40F085011050063A4A3,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -806,6 +810,20 @@
settings = {
};
};
2D62C40E085011050063A4A3 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
path = Menus.h;
refType = 2;
sourceTree = SOURCE_ROOT;
};
2D62C40F085011050063A4A3 = {
fileRef = 2D62C40E085011050063A4A3;
isa = PBXBuildFile;
settings = {
};
};
2D733D5D062893E7006265D9 = {
fileEncoding = 30;
isa = PBXFileReference;