diff --git a/Classes/ControlPadEventDelegate.h b/Classes/ControlPadEventDelegate.h new file mode 100644 index 0000000..4336653 --- /dev/null +++ b/Classes/ControlPadEventDelegate.h @@ -0,0 +1,39 @@ +// +// ControlPadEventDelegate.h +// SNES4iOS +// +// Created by Shawn Allen on 9/28/12. +// +// + +#import + +typedef enum ControlPadState { + ControlPadStateNone = 0x000, + ControlPadStateUp = 0x001, + ControlPadStateRight = 0x002, + ControlPadStateDown = 0x004, + ControlPadStateLeft = 0x008, + + ControlPadStateUpRight = ControlPadStateUp | ControlPadStateRight, + ControlPadStateDownRight = ControlPadStateDown | ControlPadStateRight, + ControlPadStateUpLeft = ControlPadStateUp | ControlPadStateLeft, + ControlPadStateDownLeft = ControlPadStateDown | ControlPadStateLeft, + + ControlPadStateButtonA = 0x010, + ControlPadStateButtonB = 0x020, + ControlPadStateButtonC = 0x040, + ControlPadStateButtonD = 0x080, + ControlPadStateButtonE = 0x100, + ControlPadStateButtonF = 0x200, + ControlPadStateButtonG = 0x400, + ControlPadStateButtonH = 0x800, + +} ControlPadState; + +@protocol ControlPadEventDelegate + +@required +- (void)padChangedState:(ControlPadState)changedState pressed:(BOOL)pressed; + +@end diff --git a/Classes/ControlPadManager.h b/Classes/ControlPadManager.h index 417b3a4..029313e 100644 --- a/Classes/ControlPadManager.h +++ b/Classes/ControlPadManager.h @@ -8,12 +8,13 @@ #import #import +#import "ControlPadEventDelegate.h" #define MAX_CONTROL_PADS 4 extern unsigned long padStatusForPadNumber(int which); -@interface ControlPadManager : NSObject { +@interface ControlPadManager : NSObject { GKSession *gkSession; NSMutableArray *controlPadPeerIDs; diff --git a/Classes/ControlPadManager.m b/Classes/ControlPadManager.m index b32bc15..ebc67a0 100644 --- a/Classes/ControlPadManager.m +++ b/Classes/ControlPadManager.m @@ -131,6 +131,88 @@ - (void) denyPendingConnection self.pendingConnectionPeerID = nil; } +#pragma mark - +#pragma mark ControlPadEventDelegate + +enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40, + GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11, + GP2X_A=1<<12, GP2X_B=1<<13, GP2X_X=1<<14, GP2X_Y=1<<15, + GP2X_VOL_UP=1<<23, GP2X_VOL_DOWN=1<<22, GP2X_PUSH=1<<27 }; + +- (void)padChangedState:(ControlPadState)changedState pressed:(BOOL)pressed; +{ + static unsigned long padState = 0; + + unsigned long stateInGP2XValue = 0; + + /* + A SELECT + B LEFT SHOULDER + C START + D RIGHT SHOULDER + E Y + F A + G B + H X + */ + + switch (changedState) { + case ControlPadStateNone: + stateInGP2XValue = 0; + break; + case ControlPadStateUp: + stateInGP2XValue = GP2X_UP; + break; + case ControlPadStateDown: + stateInGP2XValue = GP2X_DOWN; + break; + case ControlPadStateLeft: + stateInGP2XValue = GP2X_LEFT; + break; + case ControlPadStateRight: + stateInGP2XValue = GP2X_RIGHT; + break; + case ControlPadStateButtonA: + stateInGP2XValue = GP2X_SELECT; + break; + case ControlPadStateButtonB: + stateInGP2XValue = GP2X_L; + break; + case ControlPadStateButtonC: + stateInGP2XValue = GP2X_START; + break; + case ControlPadStateButtonD: + stateInGP2XValue = GP2X_R; + break; + case ControlPadStateButtonE: + stateInGP2XValue = GP2X_Y; + break; + case ControlPadStateButtonF: + stateInGP2XValue = GP2X_A; + break; + case ControlPadStateButtonG: + stateInGP2XValue = GP2X_B; + break; + case ControlPadStateButtonH: + stateInGP2XValue = GP2X_X; + break; + case ControlPadStateDownLeft: + case ControlPadStateDownRight: + case ControlPadStateUpLeft: + case ControlPadStateUpRight: + default: + NSLog(@"%s Compound pad movement sent, but was unhandled.", __PRETTY_FUNCTION__); + break; + } + + if (pressed) + padState |= stateInGP2XValue; + else + padState ^= stateInGP2XValue; + + [self convertData:[NSData dataWithBytes:&padState length:sizeof(padState)] padNumber:0]; +} + #pragma mark - #pragma mark GKSession Delegate methods - (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state { diff --git a/Classes/SNES4iOSAppDelegate.h b/Classes/SNES4iOSAppDelegate.h index 01c2ac5..63fbcde 100644 --- a/Classes/SNES4iOSAppDelegate.h +++ b/Classes/SNES4iOSAppDelegate.h @@ -10,6 +10,7 @@ #import "SNESControllerAppDelegate.h" #import "SNESControllerViewController.h" +@class iCadeViewController; @class EmulationViewController; @class RomSelectionViewController; @class RomDetailViewController; @@ -46,6 +47,7 @@ @property (nonatomic, strong) ControlPadManager *controlPadManager; @property (nonatomic, strong) EmulationViewController *emulationViewController; +@property (nonatomic, strong) iCadeViewController *iCadeViewController; @property (nonatomic, strong) WebBrowserViewController *webViewController; @property (nonatomic, strong) UINavigationController *webNavController; @property (strong, nonatomic) UITabBarController *tabBarController; diff --git a/Classes/SNES4iOSAppDelegate.m b/Classes/SNES4iOSAppDelegate.m index 3a9bc02..01a654b 100644 --- a/Classes/SNES4iOSAppDelegate.m +++ b/Classes/SNES4iOSAppDelegate.m @@ -26,7 +26,7 @@ @implementation SNES4iOSAppDelegate @synthesize window, splitViewController, romSelectionViewController, romDetailViewController, settingsViewController; @synthesize controlPadConnectViewController, controlPadManager; @synthesize romDirectoryPath, saveDirectoryPath, snapshotDirectoryPath; -@synthesize emulationViewController, webViewController, webNavController; +@synthesize emulationViewController, iCadeViewController, webViewController, webNavController; @synthesize tabBarController; @synthesize snesControllerAppDelegate, snesControllerViewController; @synthesize sramDirectoryPath; @@ -69,6 +69,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // Make the main emulator view controller emulationViewController = [[EmulationViewController alloc] init]; emulationViewController.view.hidden = YES; + + // Construct and attach the iCade view controller into the emulation view controller's view hierarchy + [self setICadeViewController:[[iCadeViewController alloc] init]]; + [[[self emulationViewController] view] addSubview:[[self iCadeViewController] view]]; + [[self iCadeViewController] setDelegate:[self controlPadManager]]; // Make the web browser view controller webViewController = [[WebBrowserViewController alloc] initWithNibName:@"WebBrowserViewController" bundle:nil]; diff --git a/Classes/iCadeViewController.h b/Classes/iCadeViewController.h new file mode 100644 index 0000000..7e91f14 --- /dev/null +++ b/Classes/iCadeViewController.h @@ -0,0 +1,17 @@ +// +// iCadeViewController.h +// SNES4iOS +// +// Created by Shawn Allen on 9/28/12. +// +// + +#import +#import "iCadeReaderView.h" +#import "ControlPadEventDelegate.h" + +@interface iCadeViewController : UIViewController + +@property (nonatomic, weak) IBOutlet id delegate; + +@end diff --git a/Classes/iCadeViewController.m b/Classes/iCadeViewController.m new file mode 100644 index 0000000..645c1e3 --- /dev/null +++ b/Classes/iCadeViewController.m @@ -0,0 +1,95 @@ +// +// iCadeViewController.m +// SNES4iOS +// +// Created by Shawn Allen on 9/28/12. +// +// + +#import "iCadeViewController.h" + +@interface iCadeViewController () + +- (void)setState:(BOOL)state forButton:(iCadeState)button; + +@end + +@implementation iCadeViewController + +#pragma mark - +#pragma mark Class extension + +- (void)setState:(BOOL)state forButton:(iCadeState)button; +{ + ControlPadState padButton = ControlPadStateNone; + + switch (button) { + case iCadeButtonA: + padButton = ControlPadStateButtonA; + break; + case iCadeButtonB: + padButton = ControlPadStateButtonB; + break; + case iCadeButtonC: + padButton = ControlPadStateButtonC; + break; + case iCadeButtonD: + padButton = ControlPadStateButtonD; + break; + case iCadeButtonE: + padButton = ControlPadStateButtonE; + break; + case iCadeButtonF: + padButton = ControlPadStateButtonF; + break; + case iCadeButtonG: + padButton = ControlPadStateButtonG; + break; + case iCadeButtonH: + padButton = ControlPadStateButtonH; + break; + case iCadeJoystickUp: + padButton = ControlPadStateUp; + break; + case iCadeJoystickRight: + padButton = ControlPadStateRight; + break; + case iCadeJoystickDown: + padButton = ControlPadStateDown; + break; + case iCadeJoystickLeft: + padButton = ControlPadStateLeft; + break; + default: + break; + } + + [[self delegate] padChangedState:padButton pressed:state]; +} + +#pragma mark - +#pragma mark UIViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + iCadeReaderView *control = [[iCadeReaderView alloc] initWithFrame:CGRectZero]; + [[self view] addSubview:control]; + [control setActive:YES]; + [control setDelegate:self]; +} + +#pragma mark - +#pragma mark iCadeEventDelegate + +- (void)buttonDown:(iCadeState)button; +{ + [self setState:YES forButton:button]; +} + +- (void)buttonUp:(iCadeState)button; +{ + [self setState:NO forButton:button]; +} + +@end diff --git a/SNES4iOS.xcodeproj/project.pbxproj b/SNES4iOS.xcodeproj/project.pbxproj index 3a0cb9f..1a25cc4 100755 --- a/SNES4iOS.xcodeproj/project.pbxproj +++ b/SNES4iOS.xcodeproj/project.pbxproj @@ -14,6 +14,8 @@ 2804200B108E984D000629CD /* RomSelectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28042008108E984D000629CD /* RomSelectionViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 2804200C108E984D000629CD /* RomDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2804200A108E984D000629CD /* RomDetailViewController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 2892E4100DC94CBA00A64D0F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; }; + 520D7C3E1618A9C4009306B7 /* iCadeReaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 520D7C3C1618A9C4009306B7 /* iCadeReaderView.m */; }; + 520D7C441618AA10009306B7 /* iCadeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 520D7C431618AA10009306B7 /* iCadeViewController.m */; }; 6C3CE6EB135BCD0400D61F53 /* IOSurface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C3CE6EA135BCD0400D61F53 /* IOSurface.framework */; }; 6CD00F45135FED04003E789A /* libpocketsnes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CD00F44135FED04003E789A /* libpocketsnes.a */; }; 6CD00F60135FEE9C003E789A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CD00F5F135FEE9C003E789A /* AudioToolbox.framework */; }; @@ -99,6 +101,12 @@ 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 28A0AAE50D9B0CCF005BE974 /* SNES4iOS_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SNES4iOS_Prefix.pch; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 520D7C3B1618A9C4009306B7 /* iCadeReaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iCadeReaderView.h; sourceTree = ""; }; + 520D7C3C1618A9C4009306B7 /* iCadeReaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iCadeReaderView.m; sourceTree = ""; }; + 520D7C3D1618A9C4009306B7 /* iCadeState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iCadeState.h; sourceTree = ""; }; + 520D7C411618AA10009306B7 /* ControlPadEventDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ControlPadEventDelegate.h; sourceTree = ""; }; + 520D7C421618AA10009306B7 /* iCadeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iCadeViewController.h; sourceTree = ""; }; + 520D7C431618AA10009306B7 /* iCadeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iCadeViewController.m; sourceTree = ""; }; 6C3CE6EA135BCD0400D61F53 /* IOSurface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOSurface.framework; path = System/Library/PrivateFrameworks/IOSurface.framework; sourceTree = SDKROOT; }; 6CD00F44135FED04003E789A /* libpocketsnes.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpocketsnes.a; path = src/snes4iphone_src/libpocketsnes.a; sourceTree = ""; }; 6CD00F5F135FEE9C003E789A /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; @@ -222,6 +230,9 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 520D7C411618AA10009306B7 /* ControlPadEventDelegate.h */, + 520D7C421618AA10009306B7 /* iCadeViewController.h */, + 520D7C431618AA10009306B7 /* iCadeViewController.m */, 1D3623240D0F684500981E51 /* SNES4iOSAppDelegate.h */, 1D3623250D0F684500981E51 /* SNES4iOSAppDelegate.m */, 28042007108E984D000629CD /* RomSelectionViewController.h */, @@ -264,6 +275,7 @@ 080E96DDFE201D6D7F000001 /* Classes */, CE43A4CC119DFEF70007E399 /* Resources */, 29B97315FDCFA39411CA2CEA /* Other Sources */, + 520D7C401618A9F1009306B7 /* External Libraries */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 19C28FACFE9D520D11CA2CBB /* Products */, ); @@ -301,6 +313,24 @@ name = Frameworks; sourceTree = ""; }; + 520D7C3A1618A9C4009306B7 /* iCade */ = { + isa = PBXGroup; + children = ( + 520D7C3B1618A9C4009306B7 /* iCadeReaderView.h */, + 520D7C3C1618A9C4009306B7 /* iCadeReaderView.m */, + 520D7C3D1618A9C4009306B7 /* iCadeState.h */, + ); + path = iCade; + sourceTree = ""; + }; + 520D7C401618A9F1009306B7 /* External Libraries */ = { + isa = PBXGroup; + children = ( + 520D7C3A1618A9C4009306B7 /* iCade */, + ); + name = "External Libraries"; + sourceTree = ""; + }; BF7B7A0C14A64BEE00014E61 /* SNES Controller */ = { isa = PBXGroup; children = ( @@ -544,6 +574,8 @@ BF7B7A0914A64BEA00014E61 /* SessionController.m in Sources */, BF7B7A0A14A64BEA00014E61 /* SNESControllerAppDelegate.m in Sources */, BF7B7A0B14A64BEA00014E61 /* SNESControllerViewController.m in Sources */, + 520D7C3E1618A9C4009306B7 /* iCadeReaderView.m in Sources */, + 520D7C441618AA10009306B7 /* iCadeViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iCade/iCadeReaderView.h b/iCade/iCadeReaderView.h new file mode 100755 index 0000000..d0b814f --- /dev/null +++ b/iCade/iCadeReaderView.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2011 by Stuart Carnie + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +#import +#import "iCadeState.h" + +/* + UP ON,OFF = w,e + RT ON,OFF = d,c + DN ON,OFF = x,z + LT ON,OFF = a,q + A ON,OFF = y,t + B ON,OFF = h,r + C ON,OFF = u,f + D ON,OFF = j,n + E ON,OFF = i,m + F ON,OFF = k,p + G ON,OFF = o,g + H ON,OFF = l,v +*/ + +@protocol iCadeEventDelegate + +@optional +- (void)stateChanged:(iCadeState)state; +- (void)buttonDown:(iCadeState)button; +- (void)buttonUp:(iCadeState)button; + +@end + +@interface iCadeReaderView : UIView { + UIView *inputView; + + struct { + bool stateChanged:1; + bool buttonDown:1; + bool buttonUp:1; + } _delegateFlags; +} + +@property (nonatomic, assign) iCadeState iCadeState; +@property (nonatomic, assign) id delegate; +@property (nonatomic, assign) BOOL active; + +@end diff --git a/iCade/iCadeReaderView.m b/iCade/iCadeReaderView.m new file mode 100755 index 0000000..5b30b65 --- /dev/null +++ b/iCade/iCadeReaderView.m @@ -0,0 +1,140 @@ +/* + Copyright (C) 2011 by Stuart Carnie + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +#import "iCadeReaderView.h" + +static const char *ON_STATES = "wdxayhujikol"; +static const char *OFF_STATES = "eczqtrfnmpgv"; + +@interface iCadeReaderView() + +- (void)didEnterBackground; +- (void)didBecomeActive; + +@end + +@implementation iCadeReaderView + +@synthesize active; + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + inputView = [[UIView alloc] initWithFrame:CGRectZero]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; +} + +- (void)didEnterBackground { + if (self.active) + [self resignFirstResponder]; +} + +- (void)didBecomeActive { + if (self.active) + [self becomeFirstResponder]; +} + +- (BOOL)canBecomeFirstResponder { + return YES; +} + +- (void)setActive:(BOOL)value { + if (active == value) return; + + active = value; + if (active) { + [self becomeFirstResponder]; + } else { + [self resignFirstResponder]; + } +} + +- (UIView*) inputView { + return inputView; +} + +- (void)setDelegate:(id)delegate { + _delegate = delegate; + if (!_delegate) return; + + _delegateFlags.stateChanged = [_delegate respondsToSelector:@selector(stateChanged:)]; + _delegateFlags.buttonDown = [_delegate respondsToSelector:@selector(buttonDown:)]; + _delegateFlags.buttonUp = [_delegate respondsToSelector:@selector(buttonUp:)]; +} + +#pragma mark - +#pragma mark UIKeyInput Protocol Methods + +- (BOOL)hasText { + return NO; +} + +- (void)insertText:(NSString *)text { + + char ch = [text characterAtIndex:0]; + char *p = strchr(ON_STATES, ch); + bool stateChanged = false; + if (p) { + int index = p-ON_STATES; + _iCadeState |= (1 << index); + stateChanged = true; + if (_delegateFlags.buttonDown) { + [_delegate buttonDown:(1 << index)]; + } + } else { + p = strchr(OFF_STATES, ch); + if (p) { + int index = p-OFF_STATES; + _iCadeState &= ~(1 << index); + stateChanged = true; + if (_delegateFlags.buttonUp) { + [_delegate buttonUp:(1 << index)]; + } + } + } + + if (stateChanged && _delegateFlags.stateChanged) { + [_delegate stateChanged:_iCadeState]; + } + + static int cycleResponder = 0; + if (++cycleResponder > 20) { + // necessary to clear a buffer that accumulates internally + cycleResponder = 0; + [self resignFirstResponder]; + [self becomeFirstResponder]; + } +} + +- (void)deleteBackward { + // This space intentionally left blank to complete protocol +} + +@end diff --git a/iCade/iCadeState.h b/iCade/iCadeState.h new file mode 100755 index 0000000..0355ee9 --- /dev/null +++ b/iCade/iCadeState.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2011 by Stuart Carnie + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +typedef enum iCadeState { + iCadeJoystickNone = 0x000, + iCadeJoystickUp = 0x001, + iCadeJoystickRight = 0x002, + iCadeJoystickDown = 0x004, + iCadeJoystickLeft = 0x008, + + iCadeJoystickUpRight = iCadeJoystickUp | iCadeJoystickRight, + iCadeJoystickDownRight = iCadeJoystickDown | iCadeJoystickRight, + iCadeJoystickUpLeft = iCadeJoystickUp | iCadeJoystickLeft, + iCadeJoystickDownLeft = iCadeJoystickDown | iCadeJoystickLeft, + + iCadeButtonA = 0x010, + iCadeButtonB = 0x020, + iCadeButtonC = 0x040, + iCadeButtonD = 0x080, + iCadeButtonE = 0x100, + iCadeButtonF = 0x200, + iCadeButtonG = 0x400, + iCadeButtonH = 0x800, + +} iCadeState;