mirror of https://github.com/snes9xgit/snes9x.git
Rewrite keyboard input handling, importing from the Carbon prefs
This commit is contained in:
parent
0d698f666f
commit
41bf8cef73
|
@ -6,19 +6,24 @@
|
|||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import <Carbon/Carbon.h>
|
||||
#import <snes9x_framework/snes9x_framework.h>
|
||||
|
||||
@interface AppDelegate ()
|
||||
@property (nonatomic, strong) S9xEngine *s9xEngine;
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSNumber *> *keys;
|
||||
@property (nonatomic, strong) NSWindow *window;
|
||||
@end
|
||||
|
||||
static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
|
||||
static NSString * const kKeyboardPrefs = @"KeyboardConfig";
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
self.s9xEngine = [S9xEngine new];
|
||||
[self setupKeyboard];
|
||||
[self importRecentItems];
|
||||
|
||||
NSWindow *window = [[NSWindow alloc] initWithContentRect:s9xView.frame styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
|
||||
|
@ -55,6 +60,89 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
|
|||
// Insert code here to tear down your application
|
||||
}
|
||||
|
||||
- (void)setupKeyboard
|
||||
{
|
||||
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
||||
|
||||
NSDictionary *defaultKeyBindings = @{
|
||||
kKeyboardPrefs : @{
|
||||
@(k1PUp).stringValue : @(kVK_UpArrow),
|
||||
@(k1PDown).stringValue : @(kVK_DownArrow),
|
||||
@(k1PLeft).stringValue : @(kVK_LeftArrow),
|
||||
@(k1PRight).stringValue : @(kVK_RightArrow),
|
||||
@(k1PY).stringValue : @(kVK_ANSI_X),
|
||||
@(k1PB).stringValue : @(kVK_ANSI_C),
|
||||
@(k1PX).stringValue : @(kVK_ANSI_D),
|
||||
@(k1PA).stringValue : @(kVK_ANSI_V),
|
||||
@(k1PL).stringValue : @(kVK_ANSI_A),
|
||||
@(k1PR).stringValue : @(kVK_ANSI_S),
|
||||
@(k1PStart).stringValue : @(kVK_Space),
|
||||
@(k1PSelect).stringValue : @(kVK_Return),
|
||||
|
||||
@(k2PUp).stringValue : @(kVK_ANSI_Keypad8),
|
||||
@(k2PDown).stringValue : @(kVK_ANSI_Keypad2),
|
||||
@(k2PLeft).stringValue : @(kVK_ANSI_Keypad4),
|
||||
@(k2PRight).stringValue : @(kVK_ANSI_Keypad6),
|
||||
@(k2PY).stringValue : @(kVK_PageDown),
|
||||
@(k2PB).stringValue : @(kVK_PageUp),
|
||||
@(k2PX).stringValue : @(kVK_End),
|
||||
@(k2PA).stringValue : @(kVK_Home),
|
||||
@(k2PL).stringValue : @(kVK_ANSI_Keypad0),
|
||||
@(k2PR).stringValue : @(kVK_ANSI_KeypadDecimal),
|
||||
@(k2PStart).stringValue : @(kVK_ANSI_KeypadEnter),
|
||||
@(k2PSelect).stringValue : @(kVK_ANSI_KeypadPlus),
|
||||
|
||||
@(k1PKeyFastForward).stringValue : @(kVK_ANSI_Backslash),
|
||||
@(k1PKeyFreeze).stringValue : @(kVK_ANSI_1),
|
||||
@(k1PKeyDefrost).stringValue : @(kVK_ANSI_0),
|
||||
@(k1PKeyScreenshot).stringValue : @(kVK_ANSI_Grave),
|
||||
@(k1PKeySPC).stringValue : @(kVK_ANSI_R),
|
||||
@(k1PKeyScopeTurbo).stringValue : @(kVK_ANSI_B),
|
||||
@(k1PKeyScopePause).stringValue : @(kVK_ANSI_N),
|
||||
@(k1PKeyScopeCursor).stringValue : @(kVK_ANSI_Q),
|
||||
@(k1PKeyOffScreen).stringValue : @(kVK_Tab),
|
||||
@(k1PKeyFunction).stringValue : @(kVK_ANSI_Slash),
|
||||
@(k1PKeyAlt).stringValue : @(kVK_ANSI_Period),
|
||||
@(k1PKeyFFDown).stringValue : @(kVK_ANSI_Q),
|
||||
@(k1PKeyFFUp).stringValue : @(kVK_ANSI_W),
|
||||
@(k1PKeyEsc).stringValue : @(kVK_Escape),
|
||||
@(k1PKeyTC).stringValue : @(kVK_ANSI_Comma)
|
||||
}
|
||||
};
|
||||
|
||||
[defaults registerDefaults:defaultKeyBindings];
|
||||
|
||||
self.keys = [[defaults objectForKey:kKeyboardPrefs] mutableCopy];
|
||||
|
||||
for (NSString *control in [self.keys copy])
|
||||
{
|
||||
[self setControl:@(control.integerValue) forKey:self.keys[control]];
|
||||
}
|
||||
|
||||
[self importKeySettings];
|
||||
[defaults synchronize];
|
||||
}
|
||||
|
||||
- (void)setControl:(NSNumber *)control forKey:(NSNumber *)key
|
||||
{
|
||||
if (key == nil || control == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self.keys[control.stringValue] = key;
|
||||
|
||||
S9xKey oldControl = kNumButtons;
|
||||
[self.s9xEngine setControl:(S9xKey)control.intValue forKey:key.intValue oldControl:&oldControl oldKey:NULL];
|
||||
|
||||
if (oldControl >= 0 && oldControl < kNumButtons)
|
||||
{
|
||||
[self.keys removeObjectForKey:@(oldControl).stringValue];
|
||||
}
|
||||
|
||||
[NSUserDefaults.standardUserDefaults setObject:[self.keys copy] forKey:kKeyboardPrefs];
|
||||
}
|
||||
|
||||
- (void)importRecentItems
|
||||
{
|
||||
const NSInteger maxRecents = 20;
|
||||
|
@ -74,6 +162,41 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
|
|||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
- (void)importKeySettings
|
||||
{
|
||||
NSData *data = [NSUserDefaults.standardUserDefaults objectForKey:@"Preferences_byek"];
|
||||
|
||||
if (data == nil)
|
||||
{
|
||||
data = [NSUserDefaults.standardUserDefaults objectForKey:@"Preferences_keyb"];
|
||||
|
||||
if (data != nil)
|
||||
{
|
||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:@"Preferences_keyb"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:@"Preferences_byek"];
|
||||
}
|
||||
|
||||
NSUInteger length = data.length;
|
||||
char *bytes = (char*)data.bytes;
|
||||
for ( NSUInteger i = 0; i < length; ++i )
|
||||
{
|
||||
// The enum values for controls changed between the Carbon and Cocoa versions.
|
||||
// The first 24 enum values are the same, but we have to adjust after that.
|
||||
if ( i < 24 )
|
||||
{
|
||||
[self setControl:@(i) forKey:@(bytes[i])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setControl:@(i - 24 + k1PKeyFastForward) forKey:@(bytes[i])];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename
|
||||
{
|
||||
return [self openURL:[NSURL fileURLWithPath:filename]];
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#ifndef _mac_controls_h_
|
||||
#define _mac_controls_h_
|
||||
|
||||
#define KeyIsPressed(km, bm, k) (km[k] || bm[k])
|
||||
|
||||
enum
|
||||
{
|
||||
k_HD = 0x80000000,
|
||||
|
@ -177,7 +179,282 @@ enum
|
|||
kMacCMapPseudoPtrBase = k_HD | k_PS | k_LG | k_C2 // for Justifier 2P
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
k1PUp,
|
||||
k1PDown,
|
||||
k1PLeft,
|
||||
k1PRight,
|
||||
k1PY,
|
||||
k1PB,
|
||||
k1PX,
|
||||
k1PA,
|
||||
k1PL,
|
||||
k1PR,
|
||||
k1PStart,
|
||||
k1PSelect,
|
||||
|
||||
k2PUp,
|
||||
k2PDown,
|
||||
k2PLeft,
|
||||
k2PRight,
|
||||
k2PY,
|
||||
k2PB,
|
||||
k2PX,
|
||||
k2PA,
|
||||
k2PL,
|
||||
k2PR,
|
||||
k2PStart,
|
||||
k2PSelect,
|
||||
|
||||
k3PUp,
|
||||
k3PDown,
|
||||
k3PLeft,
|
||||
k3PRight,
|
||||
k3PY,
|
||||
k3PB,
|
||||
k3PX,
|
||||
k3PA,
|
||||
k3PL,
|
||||
k3PR,
|
||||
k3PStart,
|
||||
k3PSelect,
|
||||
|
||||
k4PUp,
|
||||
k4PDown,
|
||||
k4PLeft,
|
||||
k4PRight,
|
||||
k4PY,
|
||||
k4PB,
|
||||
k4PX,
|
||||
k4PA,
|
||||
k4PL,
|
||||
k4PR,
|
||||
k4PStart,
|
||||
k4PSelect,
|
||||
|
||||
k5PUp,
|
||||
k5PDown,
|
||||
k5PLeft,
|
||||
k5PRight,
|
||||
k5PY,
|
||||
k5PB,
|
||||
k5PX,
|
||||
k5PA,
|
||||
k5PL,
|
||||
k5PR,
|
||||
k5PStart,
|
||||
k5PSelect,
|
||||
|
||||
k6PUp,
|
||||
k6PDown,
|
||||
k6PLeft,
|
||||
k6PRight,
|
||||
k6PY,
|
||||
k6PB,
|
||||
k6PX,
|
||||
k6PA,
|
||||
k6PL,
|
||||
k6PR,
|
||||
k6PStart,
|
||||
k6PSelect,
|
||||
|
||||
k7PUp,
|
||||
k7PDown,
|
||||
k7PLeft,
|
||||
k7PRight,
|
||||
k7PY,
|
||||
k7PB,
|
||||
k7PX,
|
||||
k7PA,
|
||||
k7PL,
|
||||
k7PR,
|
||||
k7PStart,
|
||||
k7PSelect,
|
||||
|
||||
k8PUp,
|
||||
k8PDown,
|
||||
k8PLeft,
|
||||
k8PRight,
|
||||
k8PY,
|
||||
k8PB,
|
||||
k8PX,
|
||||
k8PA,
|
||||
k8PL,
|
||||
k8PR,
|
||||
k8PStart,
|
||||
k8PSelect,
|
||||
|
||||
k1PKeyFastForward,
|
||||
k1PKeyFreeze,
|
||||
k1PKeyDefrost,
|
||||
k1PKeyScreenshot,
|
||||
k1PKeySPC,
|
||||
k1PKeyScopeTurbo,
|
||||
k1PKeyScopePause,
|
||||
k1PKeyScopeCursor,
|
||||
k1PKeyOffScreen,
|
||||
k1PKeyFunction,
|
||||
k1PKeyAlt,
|
||||
k1PKeyFFDown,
|
||||
k1PKeyFFUp,
|
||||
k1PKeyEsc,
|
||||
k1PKeyTC,
|
||||
k1PKeyMouseLeft,
|
||||
k1PKeyMouseRight,
|
||||
|
||||
k2PKeyFastForward,
|
||||
k2PKeyFreeze,
|
||||
k2PKeyDefrost,
|
||||
k2PKeyScreenshot,
|
||||
k2PKeySPC,
|
||||
k2PKeyScopeTurbo,
|
||||
k2PKeyScopePause,
|
||||
k2PKeyScopeCursor,
|
||||
k2PKeyOffScreen,
|
||||
k2PKeyFunction,
|
||||
k2PKeyAlt,
|
||||
k2PKeyFFDown,
|
||||
k2PKeyFFUp,
|
||||
k2PKeyEsc,
|
||||
k2PKeyTC,
|
||||
k2PKeyMouseLeft,
|
||||
k2PKeyMouseRight,
|
||||
|
||||
k3PKeyFastForward,
|
||||
k3PKeyFreeze,
|
||||
k3PKeyDefrost,
|
||||
k3PKeyScreenshot,
|
||||
k3PKeySPC,
|
||||
k3PKeyScopeTurbo,
|
||||
k3PKeyScopePause,
|
||||
k3PKeyScopeCursor,
|
||||
k3PKeyOffScreen,
|
||||
k3PKeyFunction,
|
||||
k3PKeyAlt,
|
||||
k3PKeyFFDown,
|
||||
k3PKeyFFUp,
|
||||
k3PKeyEsc,
|
||||
k3PKeyTC,
|
||||
k3PKeyMouseLeft,
|
||||
k3PKeyMouseRight,
|
||||
|
||||
k4PKeyFastForward,
|
||||
k4PKeyFreeze,
|
||||
k4PKeyDefrost,
|
||||
k4PKeyScreenshot,
|
||||
k4PKeySPC,
|
||||
k4PKeyScopeTurbo,
|
||||
k4PKeyScopePause,
|
||||
k4PKeyScopeCursor,
|
||||
k4PKeyOffScreen,
|
||||
k4PKeyFunction,
|
||||
k4PKeyAlt,
|
||||
k4PKeyFFDown,
|
||||
k4PKeyFFUp,
|
||||
k4PKeyEsc,
|
||||
k4PKeyTC,
|
||||
k4PKeyMouseLeft,
|
||||
k4PKeyMouseRight,
|
||||
|
||||
k5PKeyFastForward,
|
||||
k5PKeyFreeze,
|
||||
k5PKeyDefrost,
|
||||
k5PKeyScreenshot,
|
||||
k5PKeySPC,
|
||||
k5PKeyScopeTurbo,
|
||||
k5PKeyScopePause,
|
||||
k5PKeyScopeCursor,
|
||||
k5PKeyOffScreen,
|
||||
k5PKeyFunction,
|
||||
k5PKeyAlt,
|
||||
k5PKeyFFDown,
|
||||
k5PKeyFFUp,
|
||||
k5PKeyEsc,
|
||||
k5PKeyTC,
|
||||
k5PKeyMouseLeft,
|
||||
k5PKeyMouseRight,
|
||||
|
||||
k6PKeyFastForward,
|
||||
k6PKeyFreeze,
|
||||
k6PKeyDefrost,
|
||||
k6PKeyScreenshot,
|
||||
k6PKeySPC,
|
||||
k6PKeyScopeTurbo,
|
||||
k6PKeyScopePause,
|
||||
k6PKeyScopeCursor,
|
||||
k6PKeyOffScreen,
|
||||
k6PKeyFunction,
|
||||
k6PKeyAlt,
|
||||
k6PKeyFFDown,
|
||||
k6PKeyFFUp,
|
||||
k6PKeyEsc,
|
||||
k6PKeyTC,
|
||||
k6PKeyMouseLeft,
|
||||
k6PKeyMouseRight,
|
||||
|
||||
k7PKeyFastForward,
|
||||
k7PKeyFreeze,
|
||||
k7PKeyDefrost,
|
||||
k7PKeyScreenshot,
|
||||
k7PKeySPC,
|
||||
k7PKeyScopeTurbo,
|
||||
k7PKeyScopePause,
|
||||
k7PKeyScopeCursor,
|
||||
k7PKeyOffScreen,
|
||||
k7PKeyFunction,
|
||||
k7PKeyAlt,
|
||||
k7PKeyFFDown,
|
||||
k7PKeyFFUp,
|
||||
k7PKeyEsc,
|
||||
k7PKeyTC,
|
||||
k7PKeyMouseLeft,
|
||||
k7PKeyMouseRight,
|
||||
|
||||
k8PKeyFastForward,
|
||||
k8PKeyFreeze,
|
||||
k8PKeyDefrost,
|
||||
k8PKeyScreenshot,
|
||||
k8PKeySPC,
|
||||
k8PKeyScopeTurbo,
|
||||
k8PKeyScopePause,
|
||||
k8PKeyScopeCursor,
|
||||
k8PKeyOffScreen,
|
||||
k8PKeyFunction,
|
||||
k8PKeyAlt,
|
||||
k8PKeyFFDown,
|
||||
k8PKeyFFUp,
|
||||
k8PKeyEsc,
|
||||
k8PKeyTC,
|
||||
k8PKeyMouseLeft,
|
||||
k8PKeyMouseRight,
|
||||
|
||||
kNumButtons
|
||||
} S9xKey;
|
||||
|
||||
typedef enum {
|
||||
kISpFastForward,
|
||||
kISpFreeze,
|
||||
kISpDefrost,
|
||||
kISpScreenshot,
|
||||
kISpSPC,
|
||||
kISpScopeTurbo,
|
||||
kISpScopePause,
|
||||
kISpScopeCursor,
|
||||
kISpOffScreen,
|
||||
kISpFunction,
|
||||
kISpAlt,
|
||||
kISpFFDown,
|
||||
kISpFFUp,
|
||||
kISpEsc,
|
||||
kISpTC,
|
||||
kISpMouseLeft,
|
||||
kISpMouseRight
|
||||
} ISpKey;
|
||||
|
||||
void ControlPadFlagsToS9xReportButtons (int, uint32);
|
||||
void ControlPadFlagsToS9xPseudoPointer (uint32);
|
||||
|
||||
long ISpKeyIsPressed (bool8 keys[kNumButtons], bool8 gamepadButtons[kNumButtons], ISpKey key);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#define ASSIGN_POINTRf(n, s) S9xMapPointer(n, cmd = S9xGetCommandT(s), false)
|
||||
#define ASSIGN_POINTRt(n, s) S9xMapPointer(n, cmd = S9xGetCommandT(s), true)
|
||||
|
||||
|
||||
void S9xSetupDefaultKeymap (void)
|
||||
{
|
||||
s9xcommand_t cmd;
|
||||
|
@ -174,56 +173,57 @@ void S9xSetupDefaultKeymap (void)
|
|||
|
||||
bool S9xPollButton (uint32 id, bool *pressed)
|
||||
{
|
||||
// #define kmControlKey 0x3B
|
||||
//
|
||||
// KeyMap keys;
|
||||
//
|
||||
// GetKeys(keys);
|
||||
//
|
||||
// *pressed = false;
|
||||
//
|
||||
// if (id & k_MO) // mouse
|
||||
// {
|
||||
// switch (id & 0xFF)
|
||||
// {
|
||||
// case 0: *pressed = ISpKeyIsPressed(kISpMouseL); break;
|
||||
// case 1: *pressed = ISpKeyIsPressed(kISpMouseR);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// if (id & k_SS) // superscope
|
||||
// {
|
||||
// switch (id & 0xFF)
|
||||
// {
|
||||
// case 0: *pressed = ISpKeyIsPressed(kISpOffScreen) | KeyIsPressed(keys, keyCode[kKeyOffScreen]); break;
|
||||
// case 2: *pressed = ISpKeyIsPressed(kISpScopeC) | KeyIsPressed(keys, keyCode[kKeyScopeCursor]); break;
|
||||
// case 3: *pressed = ISpKeyIsPressed(kISpScopeT) | KeyIsPressed(keys, keyCode[kKeyScopeTurbo]); break;
|
||||
// case 4: *pressed = ISpKeyIsPressed(kISpScopeP) | KeyIsPressed(keys, keyCode[kKeyScopePause]); break;
|
||||
// case 1: *pressed = ISpKeyIsPressed(kISpMouseL);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// if (id & k_LG) // justifier
|
||||
// {
|
||||
// if (id & k_C1)
|
||||
// {
|
||||
// switch (id & 0xFF)
|
||||
// {
|
||||
// case 0: *pressed = ISpKeyIsPressed(kISpOffScreen) | KeyIsPressed(keys, keyCode[kKeyOffScreen]); break;
|
||||
// case 1: *pressed = ISpKeyIsPressed(kISpMouseL); break;
|
||||
// case 2: *pressed = ISpKeyIsPressed(kISpMouseR);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// switch (id & 0xFF)
|
||||
// {
|
||||
// case 0: *pressed = ISpKeyIsPressed(kISp2PStart) | KeyIsPressed(keys, keyCode[k2PStart]); break;
|
||||
// case 1: *pressed = ISpKeyIsPressed(kISp2PB) | KeyIsPressed(keys, keyCode[k2PB]); break;
|
||||
// case 2: *pressed = ISpKeyIsPressed(kISp2PA) | KeyIsPressed(keys, keyCode[k2PA]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
#define kmControlKey 0x3B
|
||||
|
||||
bool8 keys[MAC_NUM_KEYCODES];
|
||||
bool8 gamepadButtons[kNumButtons];
|
||||
|
||||
CopyPressedKeys(keys, gamepadButtons);
|
||||
|
||||
*pressed = false;
|
||||
|
||||
if (id & k_MO) // mouse
|
||||
{
|
||||
switch (id & 0xFF)
|
||||
{
|
||||
case 0: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpMouseLeft); break;
|
||||
case 1: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpMouseRight);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (id & k_SS) // superscope
|
||||
{
|
||||
switch (id & 0xFF)
|
||||
{
|
||||
case 0: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpOffScreen); break;
|
||||
case 2: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpScopeCursor); break;
|
||||
case 3: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpScopeTurbo); break;
|
||||
case 4: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpScopePause); break;
|
||||
case 1: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpMouseLeft);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (id & k_LG) // justifier
|
||||
{
|
||||
if (id & k_C1)
|
||||
{
|
||||
switch (id & 0xFF)
|
||||
{
|
||||
case 0: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpOffScreen); break;
|
||||
case 1: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpMouseLeft); break; break;
|
||||
case 2: *pressed = ISpKeyIsPressed(keys, gamepadButtons, kISpMouseRight);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (id & 0xFF)
|
||||
{
|
||||
case 0: *pressed = KeyIsPressed(keys, gamepadButtons, k2PStart); break;
|
||||
case 1: *pressed = KeyIsPressed(keys, gamepadButtons, k2PB); break;
|
||||
case 2: *pressed = KeyIsPressed(keys, gamepadButtons, k2PA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
@ -309,3 +309,199 @@ void ControlPadFlagsToS9xPseudoPointer (uint32 p)
|
|||
if (!(p & 0x0200))
|
||||
S9xReportButton(kMacCMapPseudoPtrBase + 3, (p & 0x0100));
|
||||
}
|
||||
|
||||
long ISpKeyIsPressed (bool8 keys[kNumButtons], bool8 gamepadButtons[kNumButtons], ISpKey key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case kISpFastForward:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyFastForward) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyFastForward);
|
||||
|
||||
case kISpFreeze:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyFreeze) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyFreeze);
|
||||
|
||||
case kISpDefrost:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyDefrost) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyDefrost);
|
||||
|
||||
case kISpScreenshot:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyScreenshot) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyScreenshot);
|
||||
|
||||
case kISpSPC:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeySPC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeySPC);
|
||||
|
||||
case kISpScopeTurbo:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyScopeTurbo) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyScopeTurbo);
|
||||
|
||||
case kISpScopePause:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyScopePause) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyScopePause);
|
||||
|
||||
case kISpScopeCursor:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyScopeCursor) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyScopeCursor);
|
||||
|
||||
case kISpOffScreen:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyOffScreen) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyOffScreen);
|
||||
|
||||
case kISpFunction:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyFunction) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyFunction);
|
||||
|
||||
case kISpAlt:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyAlt) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyAlt);
|
||||
|
||||
case kISpFFDown:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyFFDown) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyFFDown);
|
||||
|
||||
case kISpFFUp:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyFFUp) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyFFUp);
|
||||
|
||||
case kISpEsc:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyEsc) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyEsc);
|
||||
|
||||
case kISpTC:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyTC) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k8PKeyTC);
|
||||
|
||||
case kISpMouseLeft:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyMouseLeft) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyMouseLeft);
|
||||
|
||||
case kISpMouseRight:
|
||||
return
|
||||
KeyIsPressed(keys, gamepadButtons, k1PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k2PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k3PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k4PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k5PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k6PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyMouseRight) ||
|
||||
KeyIsPressed(keys, gamepadButtons, k7PKeyMouseRight);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,140 +22,7 @@
|
|||
#ifndef _mac_joypad_h_
|
||||
#define _mac_joypad_h_
|
||||
|
||||
enum
|
||||
{
|
||||
kISp1PUp = 0,
|
||||
kISp1PDn,
|
||||
kISp1PLf,
|
||||
kISp1PRt,
|
||||
|
||||
kISp2PUp,
|
||||
kISp2PDn,
|
||||
kISp2PLf,
|
||||
kISp2PRt,
|
||||
|
||||
kISp3PUp,
|
||||
kISp3PDn,
|
||||
kISp3PLf,
|
||||
kISp3PRt,
|
||||
|
||||
kISp4PUp,
|
||||
kISp4PDn,
|
||||
kISp4PLf,
|
||||
kISp4PRt,
|
||||
|
||||
kISp5PUp,
|
||||
kISp5PDn,
|
||||
kISp5PLf,
|
||||
kISp5PRt,
|
||||
|
||||
kISp6PUp,
|
||||
kISp6PDn,
|
||||
kISp6PLf,
|
||||
kISp6PRt,
|
||||
|
||||
kISp7PUp,
|
||||
kISp7PDn,
|
||||
kISp7PLf,
|
||||
kISp7PRt,
|
||||
|
||||
kISp8PUp,
|
||||
kISp8PDn,
|
||||
kISp8PLf,
|
||||
kISp8PRt,
|
||||
|
||||
kISp1PB,
|
||||
kISp1PA,
|
||||
kISp1PX,
|
||||
kISp1PY,
|
||||
kISp1PL,
|
||||
kISp1PR,
|
||||
kISp1PSelect,
|
||||
kISp1PStart,
|
||||
|
||||
kISp2PB,
|
||||
kISp2PA,
|
||||
kISp2PX,
|
||||
kISp2PY,
|
||||
kISp2PL,
|
||||
kISp2PR,
|
||||
kISp2PSelect,
|
||||
kISp2PStart,
|
||||
|
||||
kISp3PB,
|
||||
kISp3PA,
|
||||
kISp3PX,
|
||||
kISp3PY,
|
||||
kISp3PL,
|
||||
kISp3PR,
|
||||
kISp3PSelect,
|
||||
kISp3PStart,
|
||||
|
||||
kISp4PB,
|
||||
kISp4PA,
|
||||
kISp4PX,
|
||||
kISp4PY,
|
||||
kISp4PL,
|
||||
kISp4PR,
|
||||
kISp4PSelect,
|
||||
kISp4PStart,
|
||||
|
||||
kISp5PB,
|
||||
kISp5PA,
|
||||
kISp5PX,
|
||||
kISp5PY,
|
||||
kISp5PL,
|
||||
kISp5PR,
|
||||
kISp5PSelect,
|
||||
kISp5PStart,
|
||||
|
||||
kISp6PB,
|
||||
kISp6PA,
|
||||
kISp6PX,
|
||||
kISp6PY,
|
||||
kISp6PL,
|
||||
kISp6PR,
|
||||
kISp6PSelect,
|
||||
kISp6PStart,
|
||||
|
||||
kISp7PB,
|
||||
kISp7PA,
|
||||
kISp7PX,
|
||||
kISp7PY,
|
||||
kISp7PL,
|
||||
kISp7PR,
|
||||
kISp7PSelect,
|
||||
kISp7PStart,
|
||||
|
||||
kISp8PB,
|
||||
kISp8PA,
|
||||
kISp8PX,
|
||||
kISp8PY,
|
||||
kISp8PL,
|
||||
kISp8PR,
|
||||
kISp8PSelect,
|
||||
kISp8PStart,
|
||||
|
||||
kISpFastForward,
|
||||
kISpFreeze,
|
||||
kISpDefrost,
|
||||
kISpScreenshot,
|
||||
kISpEsc,
|
||||
kISpSPC,
|
||||
kISpMouseL,
|
||||
kISpMouseR,
|
||||
kISpScopeT,
|
||||
kISpScopeP,
|
||||
kISpScopeC,
|
||||
kISpOffScreen,
|
||||
kISpFunction,
|
||||
kISpAlt,
|
||||
kISpFFUp,
|
||||
kISpFFDown,
|
||||
kISpTC,
|
||||
|
||||
kNeedCount
|
||||
};
|
||||
#include "mac-controls.h"
|
||||
|
||||
void SetUpHID (void);
|
||||
void ReleaseHID (void);
|
||||
|
@ -163,7 +30,6 @@ void ReleaseHID (void);
|
|||
void ClearPadSetting (void);
|
||||
void SaveControllerSettings (void);
|
||||
void LoadControllerSettings (void);
|
||||
long ISpKeyIsPressed (int);
|
||||
void JoypadScanDirection (int, uint32 *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -74,409 +74,10 @@ typedef struct padDirectionInfo
|
|||
long min [2];
|
||||
} directionInfo;
|
||||
|
||||
static actionRec gActionRecs[kNeedCount];
|
||||
static actionRec gActionRecs[kNumButtons];
|
||||
static directionInfo gDirectionInfo[MAC_MAX_PLAYERS];
|
||||
static int gDirectionHint[MAC_MAX_PLAYERS];
|
||||
|
||||
static const HIViewID gControlIDs[kNeedCount] =
|
||||
{
|
||||
{ '1_Up', 0 },
|
||||
{ '1_Dn', 0 },
|
||||
{ '1_Lf', 0 },
|
||||
{ '1_Rt', 0 },
|
||||
|
||||
{ '2_Up', 0 },
|
||||
{ '2_Dn', 0 },
|
||||
{ '2_Lf', 0 },
|
||||
{ '2_Rt', 0 },
|
||||
|
||||
{ '3_Up', 0 },
|
||||
{ '3_Dn', 0 },
|
||||
{ '3_Lf', 0 },
|
||||
{ '3_Rt', 0 },
|
||||
|
||||
{ '4_Up', 0 },
|
||||
{ '4_Dn', 0 },
|
||||
{ '4_Lf', 0 },
|
||||
{ '4_Rt', 0 },
|
||||
|
||||
{ '5_Up', 0 },
|
||||
{ '5_Dn', 0 },
|
||||
{ '5_Lf', 0 },
|
||||
{ '5_Rt', 0 },
|
||||
|
||||
{ '6_Up', 0 },
|
||||
{ '6_Dn', 0 },
|
||||
{ '6_Lf', 0 },
|
||||
{ '6_Rt', 0 },
|
||||
|
||||
{ '7_Up', 0 },
|
||||
{ '7_Dn', 0 },
|
||||
{ '7_Lf', 0 },
|
||||
{ '7_Rt', 0 },
|
||||
|
||||
{ '8_Up', 0 },
|
||||
{ '8_Dn', 0 },
|
||||
{ '8_Lf', 0 },
|
||||
{ '8_Rt', 0 },
|
||||
|
||||
{ '1__B', 0 },
|
||||
{ '1__A', 0 },
|
||||
{ '1__X', 0 },
|
||||
{ '1__Y', 0 },
|
||||
{ '1__L', 0 },
|
||||
{ '1__R', 0 },
|
||||
{ '1Sel', 0 },
|
||||
{ '1Srt', 0 },
|
||||
|
||||
{ '2__B', 0 },
|
||||
{ '2__A', 0 },
|
||||
{ '2__X', 0 },
|
||||
{ '2__Y', 0 },
|
||||
{ '2__L', 0 },
|
||||
{ '2__R', 0 },
|
||||
{ '2Sel', 0 },
|
||||
{ '2Srt', 0 },
|
||||
|
||||
{ '3__B', 0 },
|
||||
{ '3__A', 0 },
|
||||
{ '3__X', 0 },
|
||||
{ '3__Y', 0 },
|
||||
{ '3__L', 0 },
|
||||
{ '3__R', 0 },
|
||||
{ '3Sel', 0 },
|
||||
{ '3Srt', 0 },
|
||||
|
||||
{ '4__B', 0 },
|
||||
{ '4__A', 0 },
|
||||
{ '4__X', 0 },
|
||||
{ '4__Y', 0 },
|
||||
{ '4__L', 0 },
|
||||
{ '4__R', 0 },
|
||||
{ '4Sel', 0 },
|
||||
{ '4Srt', 0 },
|
||||
|
||||
{ '5__B', 0 },
|
||||
{ '5__A', 0 },
|
||||
{ '5__X', 0 },
|
||||
{ '5__Y', 0 },
|
||||
{ '5__L', 0 },
|
||||
{ '5__R', 0 },
|
||||
{ '5Sel', 0 },
|
||||
{ '5Srt', 0 },
|
||||
|
||||
{ '6__B', 0 },
|
||||
{ '6__A', 0 },
|
||||
{ '6__X', 0 },
|
||||
{ '6__Y', 0 },
|
||||
{ '6__L', 0 },
|
||||
{ '6__R', 0 },
|
||||
{ '6Sel', 0 },
|
||||
{ '6Srt', 0 },
|
||||
|
||||
{ '7__B', 0 },
|
||||
{ '7__A', 0 },
|
||||
{ '7__X', 0 },
|
||||
{ '7__Y', 0 },
|
||||
{ '7__L', 0 },
|
||||
{ '7__R', 0 },
|
||||
{ '7Sel', 0 },
|
||||
{ '7Srt', 0 },
|
||||
|
||||
{ '8__B', 0 },
|
||||
{ '8__A', 0 },
|
||||
{ '8__X', 0 },
|
||||
{ '8__Y', 0 },
|
||||
{ '8__L', 0 },
|
||||
{ '8__R', 0 },
|
||||
{ '8Sel', 0 },
|
||||
{ '8Srt', 0 },
|
||||
|
||||
{ '__FF', 0 },
|
||||
{ '_Frz', 0 },
|
||||
{ '_DeF', 0 },
|
||||
{ '_Snp', 0 },
|
||||
{ '_Esc', 0 },
|
||||
{ '_SPC', 0 },
|
||||
{ 'MouL', 0 },
|
||||
{ 'MouR', 0 },
|
||||
{ 'ScoT', 0 },
|
||||
{ 'ScoP', 0 },
|
||||
{ 'ScoC', 0 },
|
||||
{ 'Ofsc', 0 },
|
||||
{ '__Fn', 0 },
|
||||
{ '_Alt', 0 },
|
||||
{ 'FFUp', 0 },
|
||||
{ 'FFDn', 0 },
|
||||
{ '__TC', 0 }
|
||||
};
|
||||
|
||||
static char gNeeds[kNeedCount][64] =
|
||||
{
|
||||
"1P Up",
|
||||
"1P Down",
|
||||
"1P Left",
|
||||
"1P Right",
|
||||
|
||||
"2P Up",
|
||||
"2P Down",
|
||||
"2P Left",
|
||||
"2P Right",
|
||||
|
||||
"3P Up",
|
||||
"3P Down",
|
||||
"3P Left",
|
||||
"3P Right",
|
||||
|
||||
"4P Up",
|
||||
"4P Down",
|
||||
"4P Left",
|
||||
"4P Right",
|
||||
|
||||
"5P Up",
|
||||
"5P Down",
|
||||
"5P Left",
|
||||
"5P Right",
|
||||
|
||||
"6P Up",
|
||||
"6P Down",
|
||||
"6P Left",
|
||||
"6P Right",
|
||||
|
||||
"7P Up",
|
||||
"7P Down",
|
||||
"7P Left",
|
||||
"7P Right",
|
||||
|
||||
"8P Up",
|
||||
"8P Down",
|
||||
"8P Left",
|
||||
"8P Right",
|
||||
|
||||
"1P B Button",
|
||||
"1P A Button",
|
||||
"1P X Button",
|
||||
"1P Y Button",
|
||||
"1P L Button",
|
||||
"1P R Button",
|
||||
"1P Select",
|
||||
"1P Start",
|
||||
|
||||
"2P B Button",
|
||||
"2P A Button",
|
||||
"2P X Button",
|
||||
"2P Y Button",
|
||||
"2P L Button",
|
||||
"2P R Button",
|
||||
"2P Select",
|
||||
"2P Start",
|
||||
|
||||
"3P B Button",
|
||||
"3P A Button",
|
||||
"3P X Button",
|
||||
"3P Y Button",
|
||||
"3P L Button",
|
||||
"3P R Button",
|
||||
"3P Select",
|
||||
"3P Start",
|
||||
|
||||
"4P B Button",
|
||||
"4P A Button",
|
||||
"4P X Button",
|
||||
"4P Y Button",
|
||||
"4P L Button",
|
||||
"4P R Button",
|
||||
"4P Select",
|
||||
"4P Start",
|
||||
|
||||
"5P B Button",
|
||||
"5P A Button",
|
||||
"5P X Button",
|
||||
"5P Y Button",
|
||||
"5P L Button",
|
||||
"5P R Button",
|
||||
"5P Select",
|
||||
"5P Start",
|
||||
|
||||
"6P B Button",
|
||||
"6P A Button",
|
||||
"6P X Button",
|
||||
"6P Y Button",
|
||||
"6P L Button",
|
||||
"6P R Button",
|
||||
"6P Select",
|
||||
"6P Start",
|
||||
|
||||
"7P B Button",
|
||||
"7P A Button",
|
||||
"7P X Button",
|
||||
"7P Y Button",
|
||||
"7P L Button",
|
||||
"7P R Button",
|
||||
"7P Select",
|
||||
"7P Start",
|
||||
|
||||
"8P B Button",
|
||||
"8P A Button",
|
||||
"8P X Button",
|
||||
"8P Y Button",
|
||||
"8P L Button",
|
||||
"8P R Button",
|
||||
"8P Select",
|
||||
"8P Start",
|
||||
|
||||
"Fast Forward",
|
||||
"Freeze Game",
|
||||
"Defrost Game",
|
||||
"Screenshot",
|
||||
"Break",
|
||||
"Save SPC",
|
||||
"Mouse Left",
|
||||
"Mouse Right",
|
||||
"Scope Turbo",
|
||||
"Scope Pause",
|
||||
"Scope Cursor",
|
||||
"Offscreen",
|
||||
"Fn Modifier",
|
||||
"Alt Modifier",
|
||||
"Turbo Speed Up",
|
||||
"Turbo Speed Down",
|
||||
"Turbo Control Modifier"
|
||||
};
|
||||
|
||||
static int gIconNumber[kNeedCount] =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
|
||||
36,
|
||||
37,
|
||||
38,
|
||||
39,
|
||||
|
||||
48,
|
||||
49,
|
||||
50,
|
||||
51,
|
||||
|
||||
60,
|
||||
61,
|
||||
62,
|
||||
63,
|
||||
|
||||
72,
|
||||
73,
|
||||
74,
|
||||
75,
|
||||
|
||||
84,
|
||||
85,
|
||||
86,
|
||||
87,
|
||||
|
||||
5,
|
||||
7,
|
||||
6,
|
||||
4,
|
||||
8,
|
||||
9,
|
||||
11,
|
||||
10,
|
||||
|
||||
17,
|
||||
19,
|
||||
18,
|
||||
16,
|
||||
20,
|
||||
21,
|
||||
23,
|
||||
22,
|
||||
|
||||
29,
|
||||
31,
|
||||
30,
|
||||
28,
|
||||
32,
|
||||
33,
|
||||
35,
|
||||
34,
|
||||
|
||||
41,
|
||||
43,
|
||||
42,
|
||||
40,
|
||||
44,
|
||||
45,
|
||||
47,
|
||||
46,
|
||||
|
||||
53,
|
||||
55,
|
||||
54,
|
||||
52,
|
||||
56,
|
||||
57,
|
||||
59,
|
||||
58,
|
||||
|
||||
65,
|
||||
67,
|
||||
66,
|
||||
64,
|
||||
68,
|
||||
69,
|
||||
71,
|
||||
70,
|
||||
|
||||
77,
|
||||
79,
|
||||
78,
|
||||
76,
|
||||
80,
|
||||
81,
|
||||
83,
|
||||
82,
|
||||
|
||||
89,
|
||||
91,
|
||||
90,
|
||||
88,
|
||||
92,
|
||||
93,
|
||||
95,
|
||||
94,
|
||||
|
||||
101,
|
||||
102,
|
||||
103,
|
||||
104,
|
||||
114,
|
||||
105,
|
||||
116,
|
||||
117,
|
||||
106,
|
||||
107,
|
||||
108,
|
||||
109,
|
||||
110,
|
||||
111,
|
||||
112,
|
||||
113,
|
||||
115
|
||||
};
|
||||
|
||||
static void JoypadSetDirectionInfo (void);
|
||||
//static void IdleTimer (EventLoopTimerRef, void *);
|
||||
//static OSStatus ControllerEventHandler (EventHandlerCallRef, EventRef, void *);
|
||||
|
@ -539,7 +140,7 @@ void LoadControllerSettings (void)
|
|||
{
|
||||
// CFStringRef keyCFStringRef;
|
||||
//
|
||||
// for (int a = 0; a < kNeedCount; a++)
|
||||
// for (int a = 0; a < kNumButtons; a++)
|
||||
// {
|
||||
// pRecDevice pDevice = NULL;
|
||||
// pRecElement pElement = NULL;
|
||||
|
@ -556,7 +157,7 @@ void LoadControllerSettings (void)
|
|||
// keyCFStringRef = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s"), needCStr);
|
||||
// if (keyCFStringRef)
|
||||
// {
|
||||
// r = HIDRestoreElementPref(keyCFStringRef, kCFPreferencesCurrentApplication, &pDevice, &pElement);
|
||||
// // r = HIDRestoreElementPref(keyCFStringRef, kCFPreferencesCurrentApplication, &pDevice, &pElement);
|
||||
// if (r && pDevice && pElement)
|
||||
// {
|
||||
// gActionRecs[a].fDevice = pDevice;
|
||||
|
@ -838,26 +439,26 @@ void SetUpHID (void)
|
|||
// hidExist = true;
|
||||
//
|
||||
// ClearPadSetting();
|
||||
//
|
||||
// LoadControllerSettings();
|
||||
|
||||
LoadControllerSettings();
|
||||
}
|
||||
|
||||
void ClearPadSetting (void)
|
||||
{
|
||||
// for (int i = 0; i < MAC_MAX_PLAYERS; i++)
|
||||
// {
|
||||
// gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeNone;
|
||||
// gDirectionInfo[i].device [0] = gDirectionInfo[i].device [1] = NULL;
|
||||
// gDirectionInfo[i].element[0] = gDirectionInfo[i].element[1] = NULL;
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < kNeedCount; i++)
|
||||
// {
|
||||
// gActionRecs[i].fDevice = NULL;
|
||||
// gActionRecs[i].fElement = NULL;
|
||||
// gActionRecs[i].fValue = 0;
|
||||
// gActionRecs[i].fOldValue = -2;
|
||||
// }
|
||||
for (int i = 0; i < MAC_MAX_PLAYERS; i++)
|
||||
{
|
||||
gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeNone;
|
||||
gDirectionInfo[i].device [0] = gDirectionInfo[i].device [1] = NULL;
|
||||
gDirectionInfo[i].element[0] = gDirectionInfo[i].element[1] = NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < kNumButtons; i++)
|
||||
{
|
||||
gActionRecs[i].fDevice = NULL;
|
||||
gActionRecs[i].fElement = NULL;
|
||||
gActionRecs[i].fValue = 0;
|
||||
gActionRecs[i].fOldValue = -2;
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseHID (void)
|
||||
|
@ -956,12 +557,6 @@ void ReleaseHID (void)
|
|||
// }
|
||||
//}
|
||||
|
||||
long ISpKeyIsPressed (int needID)
|
||||
{
|
||||
// return (gActionRecs[needID].fDevice ? HIDGetElementValue(gActionRecs[needID].fDevice, gActionRecs[needID].fElement) : 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
void JoypadScanDirection (int i, uint32 *pad)
|
||||
{
|
||||
// long state;
|
||||
|
@ -1075,76 +670,76 @@ void JoypadScanDirection (int i, uint32 *pad)
|
|||
|
||||
static void JoypadSetDirectionInfo (void)
|
||||
{
|
||||
// for (int i = 0; i < MAC_MAX_PLAYERS; i++)
|
||||
// {
|
||||
// if (((gActionRecs[kUp(i)].fDevice) && (gActionRecs[kUp(i)].fElement)) &&
|
||||
// ((gActionRecs[kDn(i)].fDevice) && (gActionRecs[kDn(i)].fElement)) &&
|
||||
// ((gActionRecs[kLf(i)].fDevice) && (gActionRecs[kLf(i)].fElement)) &&
|
||||
// ((gActionRecs[kRt(i)].fDevice) && (gActionRecs[kRt(i)].fElement)))
|
||||
// {
|
||||
// if ((gActionRecs[kUp(i)].fDevice == gActionRecs[kDn(i)].fDevice) &&
|
||||
// (gActionRecs[kDn(i)].fDevice == gActionRecs[kLf(i)].fDevice) &&
|
||||
// (gActionRecs[kLf(i)].fDevice == gActionRecs[kRt(i)].fDevice) &&
|
||||
// (gActionRecs[kUp(i)].fElement == gActionRecs[kDn(i)].fElement) &&
|
||||
// (gActionRecs[kDn(i)].fElement == gActionRecs[kLf(i)].fElement) &&
|
||||
// (gActionRecs[kLf(i)].fElement == gActionRecs[kRt(i)].fElement) &&
|
||||
// (gActionRecs[kUp(i)].fElement->usage == kHIDUsage_GD_Hatswitch)) // Hat Switch
|
||||
// {
|
||||
// if ((gDirectionHint[i] == kPadElemTypeHat8) || (gDirectionHint[i] == kPadElemTypeOtherHat8) ||
|
||||
// (gDirectionHint[i] == kPadElemTypeHat4) || (gDirectionHint[i] == kPadElemTypeOtherHat4))
|
||||
// gDirectionInfo[i].type = gDirectionHint[i];
|
||||
// else // Assuming...
|
||||
// {
|
||||
// if ((gActionRecs[kUp(i)].fDevice->vendorID == 1103) || (gActionRecs[kUp(i)].fElement->min == 0))
|
||||
// gDirectionInfo[i].type = (gActionRecs[kUp(i)].fElement->max > 4) ? kPadElemTypeOtherHat8 : kPadElemTypeOtherHat4;
|
||||
// else
|
||||
// gDirectionInfo[i].type = (gActionRecs[kUp(i)].fElement->max > 4) ? kPadElemTypeHat8 : kPadElemTypeHat4;
|
||||
//
|
||||
// gDirectionHint[i] = gDirectionInfo[i].type;
|
||||
// }
|
||||
//
|
||||
// gDirectionInfo[i].device [kPadHat] = gActionRecs[kUp(i)].fDevice;
|
||||
// gDirectionInfo[i].element[kPadHat] = gActionRecs[kUp(i)].fElement;
|
||||
// gDirectionInfo[i].max [kPadHat] = gActionRecs[kUp(i)].fElement->max;
|
||||
// gDirectionInfo[i].min [kPadHat] = gActionRecs[kUp(i)].fElement->min;
|
||||
// }
|
||||
// else
|
||||
// if ((gActionRecs[kUp(i)].fDevice == gActionRecs[kDn(i)].fDevice) &&
|
||||
// (gActionRecs[kLf(i)].fDevice == gActionRecs[kRt(i)].fDevice) &&
|
||||
// (gActionRecs[kUp(i)].fElement == gActionRecs[kDn(i)].fElement) &&
|
||||
// (gActionRecs[kLf(i)].fElement == gActionRecs[kRt(i)].fElement) &&
|
||||
// (gActionRecs[kUp(i)].fElement->max - gActionRecs[kUp(i)].fElement->min > 1) &&
|
||||
// (gActionRecs[kLf(i)].fElement->max - gActionRecs[kLf(i)].fElement->min > 1)) // Axis (maybe)
|
||||
// {
|
||||
// gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeAxis;
|
||||
//
|
||||
// gDirectionInfo[i].device [kPadYAxis] = gActionRecs[kUp(i)].fDevice;
|
||||
// gDirectionInfo[i].element[kPadYAxis] = gActionRecs[kUp(i)].fElement;
|
||||
// gDirectionInfo[i].max [kPadYAxis] = gActionRecs[kUp(i)].fElement->max;
|
||||
// gDirectionInfo[i].min [kPadYAxis] = gActionRecs[kUp(i)].fElement->min;
|
||||
// gDirectionInfo[i].mid [kPadYAxis] = (gDirectionInfo[i].max[kPadYAxis] + gDirectionInfo[i].min[kPadYAxis]) >> 1;
|
||||
// gDirectionInfo[i].maxmid [kPadYAxis] = (gDirectionInfo[i].max[kPadYAxis] + gDirectionInfo[i].mid[kPadYAxis]) >> 1;
|
||||
// gDirectionInfo[i].midmin [kPadYAxis] = (gDirectionInfo[i].mid[kPadYAxis] + gDirectionInfo[i].min[kPadYAxis]) >> 1;
|
||||
//
|
||||
// gDirectionInfo[i].device [kPadXAxis] = gActionRecs[kLf(i)].fDevice;
|
||||
// gDirectionInfo[i].element[kPadXAxis] = gActionRecs[kLf(i)].fElement;
|
||||
// gDirectionInfo[i].max [kPadXAxis] = gActionRecs[kLf(i)].fElement->max;
|
||||
// gDirectionInfo[i].min [kPadXAxis] = gActionRecs[kLf(i)].fElement->min;
|
||||
// gDirectionInfo[i].mid [kPadXAxis] = (gDirectionInfo[i].max[kPadXAxis] + gDirectionInfo[i].min[kPadXAxis]) >> 1;
|
||||
// gDirectionInfo[i].maxmid [kPadXAxis] = (gDirectionInfo[i].max[kPadXAxis] + gDirectionInfo[i].mid[kPadXAxis]) >> 1;
|
||||
// gDirectionInfo[i].midmin [kPadXAxis] = (gDirectionInfo[i].mid[kPadXAxis] + gDirectionInfo[i].min[kPadXAxis]) >> 1;
|
||||
// }
|
||||
// else // Button (maybe)
|
||||
// gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeButton;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// gActionRecs[kUp(i)].fDevice = gActionRecs[kDn(i)].fDevice = gActionRecs[kLf(i)].fDevice = gActionRecs[kRt(i)].fDevice = NULL;
|
||||
// gActionRecs[kUp(i)].fElement = gActionRecs[kDn(i)].fElement = gActionRecs[kLf(i)].fElement = gActionRecs[kRt(i)].fElement = NULL;
|
||||
//
|
||||
// gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeNone;
|
||||
// gDirectionInfo[i].device [0] = gDirectionInfo[i].device [1] = NULL;
|
||||
// gDirectionInfo[i].element[0] = gDirectionInfo[i].element[1] = NULL;
|
||||
// }
|
||||
// }
|
||||
for (int i = 0; i < MAC_MAX_PLAYERS; i++)
|
||||
{
|
||||
if (((gActionRecs[kUp(i)].fDevice) && (gActionRecs[kUp(i)].fElement)) &&
|
||||
((gActionRecs[kDn(i)].fDevice) && (gActionRecs[kDn(i)].fElement)) &&
|
||||
((gActionRecs[kLf(i)].fDevice) && (gActionRecs[kLf(i)].fElement)) &&
|
||||
((gActionRecs[kRt(i)].fDevice) && (gActionRecs[kRt(i)].fElement)))
|
||||
{
|
||||
if ((gActionRecs[kUp(i)].fDevice == gActionRecs[kDn(i)].fDevice) &&
|
||||
(gActionRecs[kDn(i)].fDevice == gActionRecs[kLf(i)].fDevice) &&
|
||||
(gActionRecs[kLf(i)].fDevice == gActionRecs[kRt(i)].fDevice) &&
|
||||
(gActionRecs[kUp(i)].fElement == gActionRecs[kDn(i)].fElement) &&
|
||||
(gActionRecs[kDn(i)].fElement == gActionRecs[kLf(i)].fElement) &&
|
||||
(gActionRecs[kLf(i)].fElement == gActionRecs[kRt(i)].fElement) &&
|
||||
(gActionRecs[kUp(i)].fElement->usage == kHIDUsage_GD_Hatswitch)) // Hat Switch
|
||||
{
|
||||
if ((gDirectionHint[i] == kPadElemTypeHat8) || (gDirectionHint[i] == kPadElemTypeOtherHat8) ||
|
||||
(gDirectionHint[i] == kPadElemTypeHat4) || (gDirectionHint[i] == kPadElemTypeOtherHat4))
|
||||
gDirectionInfo[i].type = gDirectionHint[i];
|
||||
else // Assuming...
|
||||
{
|
||||
if ((gActionRecs[kUp(i)].fDevice->vendorID == 1103) || (gActionRecs[kUp(i)].fElement->min == 0))
|
||||
gDirectionInfo[i].type = (gActionRecs[kUp(i)].fElement->max > 4) ? kPadElemTypeOtherHat8 : kPadElemTypeOtherHat4;
|
||||
else
|
||||
gDirectionInfo[i].type = (gActionRecs[kUp(i)].fElement->max > 4) ? kPadElemTypeHat8 : kPadElemTypeHat4;
|
||||
|
||||
gDirectionHint[i] = gDirectionInfo[i].type;
|
||||
}
|
||||
|
||||
gDirectionInfo[i].device [kPadHat] = gActionRecs[kUp(i)].fDevice;
|
||||
gDirectionInfo[i].element[kPadHat] = gActionRecs[kUp(i)].fElement;
|
||||
gDirectionInfo[i].max [kPadHat] = gActionRecs[kUp(i)].fElement->max;
|
||||
gDirectionInfo[i].min [kPadHat] = gActionRecs[kUp(i)].fElement->min;
|
||||
}
|
||||
else
|
||||
if ((gActionRecs[kUp(i)].fDevice == gActionRecs[kDn(i)].fDevice) &&
|
||||
(gActionRecs[kLf(i)].fDevice == gActionRecs[kRt(i)].fDevice) &&
|
||||
(gActionRecs[kUp(i)].fElement == gActionRecs[kDn(i)].fElement) &&
|
||||
(gActionRecs[kLf(i)].fElement == gActionRecs[kRt(i)].fElement) &&
|
||||
(gActionRecs[kUp(i)].fElement->max - gActionRecs[kUp(i)].fElement->min > 1) &&
|
||||
(gActionRecs[kLf(i)].fElement->max - gActionRecs[kLf(i)].fElement->min > 1)) // Axis (maybe)
|
||||
{
|
||||
gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeAxis;
|
||||
|
||||
gDirectionInfo[i].device [kPadYAxis] = gActionRecs[kUp(i)].fDevice;
|
||||
gDirectionInfo[i].element[kPadYAxis] = gActionRecs[kUp(i)].fElement;
|
||||
gDirectionInfo[i].max [kPadYAxis] = gActionRecs[kUp(i)].fElement->max;
|
||||
gDirectionInfo[i].min [kPadYAxis] = gActionRecs[kUp(i)].fElement->min;
|
||||
gDirectionInfo[i].mid [kPadYAxis] = (gDirectionInfo[i].max[kPadYAxis] + gDirectionInfo[i].min[kPadYAxis]) >> 1;
|
||||
gDirectionInfo[i].maxmid [kPadYAxis] = (gDirectionInfo[i].max[kPadYAxis] + gDirectionInfo[i].mid[kPadYAxis]) >> 1;
|
||||
gDirectionInfo[i].midmin [kPadYAxis] = (gDirectionInfo[i].mid[kPadYAxis] + gDirectionInfo[i].min[kPadYAxis]) >> 1;
|
||||
|
||||
gDirectionInfo[i].device [kPadXAxis] = gActionRecs[kLf(i)].fDevice;
|
||||
gDirectionInfo[i].element[kPadXAxis] = gActionRecs[kLf(i)].fElement;
|
||||
gDirectionInfo[i].max [kPadXAxis] = gActionRecs[kLf(i)].fElement->max;
|
||||
gDirectionInfo[i].min [kPadXAxis] = gActionRecs[kLf(i)].fElement->min;
|
||||
gDirectionInfo[i].mid [kPadXAxis] = (gDirectionInfo[i].max[kPadXAxis] + gDirectionInfo[i].min[kPadXAxis]) >> 1;
|
||||
gDirectionInfo[i].maxmid [kPadXAxis] = (gDirectionInfo[i].max[kPadXAxis] + gDirectionInfo[i].mid[kPadXAxis]) >> 1;
|
||||
gDirectionInfo[i].midmin [kPadXAxis] = (gDirectionInfo[i].mid[kPadXAxis] + gDirectionInfo[i].min[kPadXAxis]) >> 1;
|
||||
}
|
||||
else // Button (maybe)
|
||||
gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeButton;
|
||||
}
|
||||
else
|
||||
{
|
||||
gActionRecs[kUp(i)].fDevice = gActionRecs[kDn(i)].fDevice = gActionRecs[kLf(i)].fDevice = gActionRecs[kRt(i)].fDevice = NULL;
|
||||
gActionRecs[kUp(i)].fElement = gActionRecs[kDn(i)].fElement = gActionRecs[kLf(i)].fElement = gActionRecs[kRt(i)].fElement = NULL;
|
||||
|
||||
gDirectionInfo[i].type = gDirectionHint[i] = kPadElemTypeNone;
|
||||
gDirectionInfo[i].device [0] = gDirectionInfo[i].device [1] = NULL;
|
||||
gDirectionInfo[i].element[0] = gDirectionInfo[i].element[1] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,57 +22,15 @@
|
|||
#ifndef _mac_keyboard_h_
|
||||
#define _mac_keyboard_h_
|
||||
|
||||
#define kKeys 39
|
||||
#include "mac-controls.h"
|
||||
|
||||
extern uint8 keyCode[kKeys];
|
||||
#define MAC_NUM_KEYCODES 255
|
||||
|
||||
enum
|
||||
{
|
||||
k1PUp,
|
||||
k1PDown,
|
||||
k1PLeft,
|
||||
k1PRight,
|
||||
k1PY,
|
||||
k1PB,
|
||||
k1PX,
|
||||
k1PA,
|
||||
k1PL,
|
||||
k1PR,
|
||||
k1PStart,
|
||||
k1PSelect,
|
||||
|
||||
k2PUp,
|
||||
k2PDown,
|
||||
k2PLeft,
|
||||
k2PRight,
|
||||
k2PY,
|
||||
k2PB,
|
||||
k2PX,
|
||||
k2PA,
|
||||
k2PL,
|
||||
k2PR,
|
||||
k2PStart,
|
||||
k2PSelect,
|
||||
|
||||
kKeyFastForward,
|
||||
kKeyFreeze,
|
||||
kKeyDefrost,
|
||||
kKeyScreenshot,
|
||||
kKeySPC,
|
||||
kKeyScopeTurbo,
|
||||
kKeyScopePause,
|
||||
kKeyScopeCursor,
|
||||
kKeyOffScreen,
|
||||
kKeyFunction,
|
||||
kKeyAlt,
|
||||
kKeyFFDown,
|
||||
kKeyFFUp,
|
||||
kKeyEsc,
|
||||
kKeyTC
|
||||
};
|
||||
extern int16 keyCodes[MAC_NUM_KEYCODES];
|
||||
|
||||
void InitKeyboard (void);
|
||||
void DeinitKeyboard (void);
|
||||
void ConfigureKeyboard (void);
|
||||
|
||||
void SetKeyCode(int16 keyCode, S9xKey control, int16 *oldKeyCode, S9xKey *oldControl);
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,8 @@
|
|||
|
||||
#import <os/lock.h>
|
||||
|
||||
#import "mac-controls.h"
|
||||
|
||||
enum
|
||||
{
|
||||
kDrawingReserved1 = 1, // unused
|
||||
|
@ -112,7 +114,6 @@ typedef struct
|
|||
#define kMacWindowHeight (SNES_HEIGHT_EXTENDED)
|
||||
#define MAC_MAX_PLAYERS 8
|
||||
#define MAC_MAX_CHEATS 150
|
||||
#define MAC_NUM_KEYCODES 255
|
||||
|
||||
extern volatile bool8 running, s9xthreadrunning;
|
||||
extern volatile bool8 eventQueued, windowExtend;
|
||||
|
@ -134,7 +135,7 @@ extern bool8 finished, cartOpen,
|
|||
autofire, hidExist, directDisplay;
|
||||
extern bool8 fullscreen, autoRes,
|
||||
glstretch, gl32bit, vsync, drawoverscan, lastoverscan, screencurvature,
|
||||
multiprocessor, ciFilterEnable;
|
||||
ciFilterEnable;
|
||||
extern long drawingMethod;
|
||||
extern int videoMode;
|
||||
extern SInt32 macSoundVolume;
|
||||
|
@ -163,7 +164,8 @@ extern CFStringRef multiCartPath[2];
|
|||
extern IconRef macIconRef[118];
|
||||
#endif
|
||||
|
||||
extern bool8 pressedKeys[MAC_NUM_KEYCODES];
|
||||
extern bool8 pressedKeys[kNumButtons];
|
||||
extern bool8 pressedGamepadButtons[kNumButtons];
|
||||
extern os_unfair_lock keyLock;
|
||||
|
||||
extern NSOpenGLView *s9xView;
|
||||
|
@ -178,11 +180,19 @@ void PostQueueToSubEventLoop (void);
|
|||
int PromptFreezeDefrost (Boolean);
|
||||
uint64 GetMicroseconds(void);
|
||||
|
||||
void CopyPressedKeys(uint8 keys[kNumButtons], uint8 gamepadButtons[kNumButtons]);
|
||||
|
||||
@interface S9xEngine : NSObject
|
||||
|
||||
- (void)start;
|
||||
- (void)stop;
|
||||
|
||||
- (BOOL)isPaused;
|
||||
- (void)pause;
|
||||
- (void)resume;
|
||||
|
||||
- (void)setControl:(S9xKey)control forKey:(int16)key oldControl:(S9xKey *)oldControl oldKey:(int16 *)oldControl;
|
||||
|
||||
- (BOOL)loadROM:(NSURL *)fileURL;
|
||||
|
||||
@end
|
||||
|
|
1617
macosx/mac-os.mm
1617
macosx/mac-os.mm
File diff suppressed because it is too large
Load Diff
|
@ -141,7 +141,6 @@ static PrefList prefList[] =
|
|||
{ 'glst', &glstretch, sizeof(bool8 ) },
|
||||
{ 'draw', &drawingMethod, sizeof(long ) },
|
||||
{ 'Vmod', &videoMode, sizeof(int ) },
|
||||
{ 'MPmt', &multiprocessor, sizeof(bool8 ) },
|
||||
{ 'VSNC', &vsync, sizeof(bool8 ) },
|
||||
{ 'H239', &drawoverscan, sizeof(bool8 ) },
|
||||
{ 'SCur', &screencurvature, sizeof(bool8 ) },
|
||||
|
@ -182,7 +181,7 @@ static PrefList prefList[] =
|
|||
|
||||
{ 'tab ', &lastTabIndex, sizeof(int ) },
|
||||
{ 'Ftab', &autofireLastTabIndex, sizeof(int ) },
|
||||
{ 'keyb', keyCode, sizeof(keyCode ) },
|
||||
{ 'keyb', keyCodes, sizeof(keyCodes ) },
|
||||
{ 'pset', &padSetting, sizeof(int ) },
|
||||
{ 'dset', &deviceSetting, sizeof(int ) },
|
||||
{ 'chea', &applycheat, sizeof(bool8 ) },
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
|
||||
typedef void (* Blitter) (uint8 *, int, uint8 *, int, int, int);
|
||||
|
||||
static OSStatus BlitMPGLTask (void *);
|
||||
static OSStatus PrepareMPBlitGL (void);
|
||||
static void S9xInitFullScreen (void);
|
||||
static void S9xDeinitFullScreen (void);
|
||||
static void S9xInitWindowMode (void);
|
||||
|
@ -287,19 +285,12 @@ void DrawPauseScreen (CGContextRef ctx, HIRect bounds)
|
|||
|
||||
void DrawFreezeDefrostScreen (uint8 *draw)
|
||||
{
|
||||
const int w = SNES_WIDTH << 1, h = kMacWindowHeight;
|
||||
const int w = SNES_WIDTH << 1, h = SNES_HEIGHT << 1;
|
||||
|
||||
imageWidth[0] = imageHeight[0] = 0;
|
||||
imageWidth[1] = imageHeight[1] = 0;
|
||||
prevBlitWidth = prevBlitHeight = 0;
|
||||
|
||||
if ((drawingMethod == kDrawingBlitGL) && multiprocessor)
|
||||
{
|
||||
MPWaitOnSemaphore(readySemaphore, kDurationForever);
|
||||
printf("MP: Send dummy signal.\n");
|
||||
MPNotifyQueue(taskQueue, (void *) kMPBlitNone, 0, 0);
|
||||
}
|
||||
|
||||
if (nx < 0 && !ciFilterEnable)
|
||||
{
|
||||
for (int y = 0; y < h; y++)
|
||||
|
@ -308,7 +299,7 @@ void DrawFreezeDefrostScreen (uint8 *draw)
|
|||
else
|
||||
memcpy(blitGLBuffer, draw, w * h * 2);
|
||||
|
||||
S9xPutImageBlitGL2(512, kMacWindowHeight);
|
||||
S9xPutImageBlitGL2(w, h);
|
||||
}
|
||||
|
||||
void ClearGFXScreen (void)
|
||||
|
@ -375,23 +366,10 @@ static void S9xDeinitOpenGL (void)
|
|||
|
||||
static void S9xInitBlitGL (void)
|
||||
{
|
||||
if (multiprocessor)
|
||||
{
|
||||
printf("MP: Creating BlitGL thread.\n");
|
||||
|
||||
if (noErr != PrepareMPBlitGL())
|
||||
multiprocessor = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void S9xDeinitBlitGL (void)
|
||||
{
|
||||
if (multiprocessor)
|
||||
{
|
||||
notificationQueue = NULL;
|
||||
|
||||
printf("MP: Successfully received terminate signal from BlitGL thread.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void GLPrepareTexture (bool8 useRange, int texNo, int rangeOnW, int rangeOnH, int rangeOffW, int rangeOffH, int filter)
|
||||
|
@ -821,75 +799,6 @@ static inline void RenderBlitScreen (Blitter Fn, int x, int sW, int sH, int cW,
|
|||
S9xPutImageBlitGL2(cW, cH);
|
||||
}
|
||||
|
||||
static OSStatus PrepareMPBlitGL (void)
|
||||
{
|
||||
OSStatus err;
|
||||
|
||||
mpBlit = (MPData *) MPAllocateAligned(sizeof(MPData), kMPAllocateDefaultAligned, kMPAllocateClearMask);
|
||||
if (!mpBlit)
|
||||
return (memFullErr);
|
||||
|
||||
err = MPCreateQueue(¬ificationQueue);
|
||||
if (err == noErr)
|
||||
{
|
||||
err = MPCreateQueue(&taskQueue);
|
||||
if (err == noErr)
|
||||
{
|
||||
err = MPCreateBinarySemaphore(&readySemaphore);
|
||||
if (err == noErr)
|
||||
{
|
||||
MPSignalSemaphore(readySemaphore);
|
||||
err = MPCreateTask(BlitMPGLTask, NULL, 0, notificationQueue, NULL, NULL, 0, &taskID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
static OSStatus BlitMPGLTask (void *parameter)
|
||||
{
|
||||
OSStatus err = noErr;
|
||||
int32 theCommand, param1, param2;
|
||||
|
||||
printf("MP: Entered BlitGL thread.\n");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
err = MPWaitOnQueue(taskQueue, (void **) &theCommand, (void **) ¶m1, (void **) ¶m2, kDurationForever);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
if (theCommand == kMPBlitFrame)
|
||||
{
|
||||
RenderBlitScreen(mpBlit->blitFn, mpBlit->nx, mpBlit->srcWidth, mpBlit->srcHeight, mpBlit->copyWidth, mpBlit->copyHeight, mpBlit->gfxBuffer);
|
||||
MPSignalSemaphore(readySemaphore);
|
||||
}
|
||||
else
|
||||
if (theCommand == kMPBlitNone)
|
||||
MPSignalSemaphore(readySemaphore);
|
||||
else
|
||||
if (theCommand == kMPBlitDone)
|
||||
break;
|
||||
else
|
||||
{
|
||||
err = userCanceledErr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MPFree(mpBlit);
|
||||
MPDeleteSemaphore(readySemaphore);
|
||||
MPDeleteQueue(taskQueue);
|
||||
mpBlit = NULL;
|
||||
readySemaphore = NULL;
|
||||
taskQueue = NULL;
|
||||
|
||||
printf("MP: Exited BlitGL thread.\n");
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
void S9xPutImage (int width, int height)
|
||||
{
|
||||
static float fps = 0.0f;
|
||||
|
@ -1226,25 +1135,7 @@ static void S9xPutImageBlitGL (int width, int height)
|
|||
imageWidth[whichBuf] = width;
|
||||
imageHeight[whichBuf] = height;
|
||||
|
||||
if (multiprocessor)
|
||||
{
|
||||
MPWaitOnSemaphore(readySemaphore, kDurationForever);
|
||||
|
||||
mpBlit->nx = nx;
|
||||
mpBlit->blitFn = blitFn;
|
||||
mpBlit->srcWidth = width;
|
||||
mpBlit->srcHeight = height;
|
||||
mpBlit->copyWidth = copyWidth;
|
||||
mpBlit->copyHeight = copyHeight;
|
||||
mpBlit->gfxBuffer = GFX.Screen;
|
||||
|
||||
MPNotifyQueue(taskQueue, (void *) kMPBlitFrame, 0, 0);
|
||||
|
||||
whichBuf = 1 - whichBuf;
|
||||
GFX.Screen = gfxScreen[whichBuf];
|
||||
}
|
||||
else
|
||||
RenderBlitScreen(blitFn, nx, width, height, copyWidth, copyHeight, GFX.Screen);
|
||||
RenderBlitScreen(blitFn, nx, width, height, copyWidth, copyHeight, GFX.Screen);
|
||||
}
|
||||
|
||||
static void S9xPutImageBlitGL2 (int blit_width, int blit_height)
|
||||
|
@ -1260,15 +1151,6 @@ static void S9xPutImageBlitGL2 (int blit_width, int blit_height)
|
|||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (glstretch)
|
||||
{
|
||||
int sh = (blit_width < blit_height) ? (blit_height >> 1) : ((blit_width > blit_height * 2) ? (blit_height << 1) : blit_height);
|
||||
float fpw = (float) glScreenH / (float) sh * (float) blit_width;
|
||||
int pw = (int) (fpw + ((float) glScreenW - fpw) * (float) macAspectRatio / 10000.0);
|
||||
|
||||
glViewport((glScreenW - pw) >> 1, 0, pw, glScreenH);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sw, sh;
|
||||
|
||||
|
@ -1418,7 +1300,6 @@ static void S9xPutImageBlitGL2 (int blit_width, int blit_height)
|
|||
DrawWithCoreImageFilter(src, cgBlitImage);
|
||||
}
|
||||
|
||||
//CGLFlushDrawable(s9xView.openGLContext.CGLContextObj);
|
||||
glSwapAPPLE();
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ void WriteThumbnailToExtendedAttribute (const char *path, int destWidth, int des
|
|||
}
|
||||
}
|
||||
|
||||
void DrawThumbnailFomExtendedAttribute (const char *path, CGContextRef ctx, CGRect bounds)
|
||||
void DrawThumbnailFromExtendedAttribute (const char *path, CGContextRef ctx, CGRect bounds)
|
||||
{
|
||||
CGContextSaveGState(ctx);
|
||||
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
3000A9CF23418799007DC37F /* logo_freeze.png in Resources */ = {isa = PBXBuildFile; fileRef = EA3D300B0A260A3200BDACCC /* logo_freeze.png */; };
|
||||
3000A9D02341879B007DC37F /* logo_defrost.png in Resources */ = {isa = PBXBuildFile; fileRef = EA3D300C0A260A3200BDACCC /* logo_defrost.png */; };
|
||||
3000A9D123418852007DC37F /* freeze_defrost.aiff in Resources */ = {isa = PBXBuildFile; fileRef = EA85C3560B4ECBD900F5F9C9 /* freeze_defrost.aiff */; };
|
||||
302EEC9C22DAD0AB006D1502 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EEC9A22DAD0AB006D1502 /* AudioToolbox.framework */; };
|
||||
302EEC9D22DAD0AB006D1502 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EEC9B22DAD0AB006D1502 /* AudioUnit.framework */; };
|
||||
302EEC9F22DAD0B1006D1502 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EEC9E22DAD0B1006D1502 /* AGL.framework */; };
|
||||
302EECA122DAD0B9006D1502 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EECA022DAD0B9006D1502 /* OpenGL.framework */; };
|
||||
302EECA322DAD0C5006D1502 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EECA222DAD0C5006D1502 /* CoreImage.framework */; };
|
||||
302EECA522DAD1B9006D1502 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302EECA422DAD1B9006D1502 /* CoreAudio.framework */; };
|
||||
3042F7E3232E9BDD00C03F5E /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3042F7E2232E9BDD00C03F5E /* Carbon.framework */; };
|
||||
3045A1EF22D03C4B0092B97D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3045A1EE22D03C4B0092B97D /* Cocoa.framework */; };
|
||||
30714719230E379500917F82 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30714718230E379500917F82 /* AppDelegate.m */; };
|
||||
3071471B230E379600917F82 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3071471A230E379600917F82 /* Assets.xcassets */; };
|
||||
|
@ -217,6 +221,8 @@
|
|||
302EECA022DAD0B9006D1502 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
|
||||
302EECA222DAD0C5006D1502 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; };
|
||||
302EECA422DAD1B9006D1502 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
|
||||
3042F7E0232E9BD200C03F5E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
|
||||
3042F7E2232E9BDD00C03F5E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
|
||||
3045A1EC22D03C430092B97D /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||
3045A1EE22D03C4B0092B97D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||
30714704230E372B00917F82 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
|
@ -491,6 +497,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3042F7E3232E9BDD00C03F5E /* Carbon.framework in Frameworks */,
|
||||
308092F92320B06F006A2860 /* Quartz.framework in Frameworks */,
|
||||
308092F72320B041006A2860 /* CoreGraphics.framework in Frameworks */,
|
||||
302EECA522DAD1B9006D1502 /* CoreAudio.framework in Frameworks */,
|
||||
|
@ -561,6 +568,8 @@
|
|||
3045A1EB22D03C420092B97D /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3042F7E2232E9BDD00C03F5E /* Carbon.framework */,
|
||||
3042F7E0232E9BD200C03F5E /* CoreServices.framework */,
|
||||
308092F82320B06F006A2860 /* Quartz.framework */,
|
||||
308092F62320B041006A2860 /* CoreGraphics.framework */,
|
||||
302EECA422DAD1B9006D1502 /* CoreAudio.framework */,
|
||||
|
@ -1110,6 +1119,9 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3000A9D02341879B007DC37F /* logo_defrost.png in Resources */,
|
||||
3000A9D123418852007DC37F /* freeze_defrost.aiff in Resources */,
|
||||
3000A9CF23418799007DC37F /* logo_freeze.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1411,6 +1423,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
VALID_ARCHS = x86_64;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1469,6 +1482,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
VALID_ARCHS = x86_64;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue