mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 07:20:31 +02:00
iOS: Remove the iCade support
It has done nothing since 2017. iCade input came through iCadeReaderView,
a hidden UIKeyInput view that decoded the controller's keystrokes, and
f0ba66fcd6 ("add support for smart keyboard") commented out the code
that created it. Nothing has made one since, so the view controller's
iCadeEventDelegate methods and the ICadeTracker behind them were never
called.
iCade controllers present themselves to iOS as Bluetooth keyboards, so
their keys still arrive as hardware keyboard presses, which can be
mapped like any other keys. Modern controllers go through
GameController.framework anyway.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8c3ba8bb6
commit
cfcf8cc17c
13 files changed
+1
-455
No files matched your search
@@ -955,9 +955,6 @@ elseif(IOS AND NOT LIBRETRO)
|
||||
ios/CameraHelper.h
|
||||
ios/LocationHelper.mm
|
||||
ios/LocationHelper.h
|
||||
ios/iCade/iCadeReaderView.h
|
||||
ios/iCade/iCadeReaderView.m
|
||||
ios/iCade/iCadeState.h
|
||||
Common/Battery/AppleBatteryClient.m
|
||||
)
|
||||
|
||||
@@ -987,7 +984,6 @@ elseif(IOS AND NOT LIBRETRO)
|
||||
ios/ViewControllerMetal.mm
|
||||
ios/iOSCoreAudio.mm
|
||||
ios/IAPManager.mm
|
||||
ios/iCade/iCadeReaderView.m
|
||||
ios/main.mm
|
||||
ios/CameraHelper.mm
|
||||
ios/LocationHelper.mm
|
||||
|
||||
@@ -730,22 +730,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\iCade\iCadeReaderView.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\iCade\iCadeState.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\iOSCoreAudio.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1141,14 +1125,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</None>
|
||||
<None Include="..\ios\iCade\iCadeReaderView.m">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</None>
|
||||
<None Include="..\ios\iOSCoreAudio.mm">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -50,9 +50,6 @@
|
||||
<Filter Include="Build\Actions">
|
||||
<UniqueIdentifier>{14abd855-ec8b-47a5-8b4c-eadcff122dc8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Other Platforms\iOS\iCade">
|
||||
<UniqueIdentifier>{ce617e38-1bc8-4eab-a3cb-d3d664116c91}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Build\CMake">
|
||||
<UniqueIdentifier>{8f39c005-9738-41c5-a8d8-cfc05bf178e8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -481,12 +478,6 @@
|
||||
<ClInclude Include="..\libretro\retro_inline.h">
|
||||
<Filter>Other Platforms\libretro</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\iCade\iCadeState.h">
|
||||
<Filter>Other Platforms\iOS\iCade</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\iCade\iCadeReaderView.h">
|
||||
<Filter>Other Platforms\iOS\iCade</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="W32Util\DarkMode.h">
|
||||
<Filter>Windows\W32Util</Filter>
|
||||
</ClInclude>
|
||||
@@ -692,9 +683,6 @@
|
||||
<None Include="..\ios\README.md">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</None>
|
||||
<None Include="..\ios\iCade\iCadeReaderView.m">
|
||||
<Filter>Other Platforms\iOS\iCade</Filter>
|
||||
</None>
|
||||
<None Include="..\cmake\Modules\FindMINIUPNPC.cmake">
|
||||
<Filter>Build\CMake</Filter>
|
||||
</None>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string_view>
|
||||
|
||||
#import <GameController/GameController.h>
|
||||
#import <CoreMotion/CoreMotion.h>
|
||||
|
||||
#include "iCade/iCadeState.h"
|
||||
#include "Common/Input/InputState.h"
|
||||
|
||||
// Code extracted from ViewController.mm, in order to modularize
|
||||
@@ -27,22 +25,6 @@ private:
|
||||
UITouch *touches_[10]{};
|
||||
};
|
||||
|
||||
// Can probably get rid of this, but let's keep it for now.
|
||||
struct ICadeTracker {
|
||||
public:
|
||||
void ButtonDown(iCadeState button);
|
||||
void ButtonUp(iCadeState button);
|
||||
void InitKeyMap();
|
||||
private:
|
||||
bool simulateAnalog = false;
|
||||
bool iCadeConnectNotified = false;
|
||||
|
||||
std::map<uint16_t, InputKeyCode> iCadeToKeyMap;
|
||||
|
||||
double lastSelectPress = 0.0f;
|
||||
double lastStartPress = 0.0f;
|
||||
};
|
||||
|
||||
void ProcessAccelerometerData(CMAccelerometerData *accData);
|
||||
InputKeyCode HIDUsageToInputKeyCode(UIKeyboardHIDUsage usage);
|
||||
|
||||
|
||||
-125
@@ -287,131 +287,6 @@ void TouchTracker::Cancelled(NSSet *touches, UIView *view) {
|
||||
}
|
||||
}
|
||||
|
||||
void ICadeTracker::InitKeyMap() {
|
||||
iCadeToKeyMap[iCadeJoystickUp] = NKCODE_DPAD_UP;
|
||||
iCadeToKeyMap[iCadeJoystickRight] = NKCODE_DPAD_RIGHT;
|
||||
iCadeToKeyMap[iCadeJoystickDown] = NKCODE_DPAD_DOWN;
|
||||
iCadeToKeyMap[iCadeJoystickLeft] = NKCODE_DPAD_LEFT;
|
||||
iCadeToKeyMap[iCadeButtonA] = NKCODE_BUTTON_9; // Select
|
||||
iCadeToKeyMap[iCadeButtonB] = NKCODE_BUTTON_7; // LTrigger
|
||||
iCadeToKeyMap[iCadeButtonC] = NKCODE_BUTTON_10; // Start
|
||||
iCadeToKeyMap[iCadeButtonD] = NKCODE_BUTTON_8; // RTrigger
|
||||
iCadeToKeyMap[iCadeButtonE] = NKCODE_BUTTON_4; // Square
|
||||
iCadeToKeyMap[iCadeButtonF] = NKCODE_BUTTON_2; // Cross
|
||||
iCadeToKeyMap[iCadeButtonG] = NKCODE_BUTTON_1; // Triangle
|
||||
iCadeToKeyMap[iCadeButtonH] = NKCODE_BUTTON_3; // Circle
|
||||
}
|
||||
|
||||
void ICadeTracker::ButtonDown(iCadeState button) {
|
||||
if (simulateAnalog &&
|
||||
((button == iCadeJoystickUp) ||
|
||||
(button == iCadeJoystickDown) ||
|
||||
(button == iCadeJoystickLeft) ||
|
||||
(button == iCadeJoystickRight))) {
|
||||
AxisInput axis;
|
||||
switch (button) {
|
||||
case iCadeJoystickUp :
|
||||
axis.axisId = JOYSTICK_AXIS_Y;
|
||||
axis.value = -1.0f;
|
||||
break;
|
||||
|
||||
case iCadeJoystickDown :
|
||||
axis.axisId = JOYSTICK_AXIS_Y;
|
||||
axis.value = 1.0f;
|
||||
break;
|
||||
|
||||
case iCadeJoystickLeft :
|
||||
axis.axisId = JOYSTICK_AXIS_X;
|
||||
axis.value = -1.0f;
|
||||
break;
|
||||
|
||||
case iCadeJoystickRight :
|
||||
axis.axisId = JOYSTICK_AXIS_X;
|
||||
axis.value = 1.0f;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
axis.deviceId = DEVICE_ID_PAD_0;
|
||||
NativeAxis(&axis, 1);
|
||||
} else {
|
||||
KeyInput key;
|
||||
key.flags = KeyInputFlags::DOWN;
|
||||
key.keyCode = iCadeToKeyMap[button];
|
||||
key.deviceId = DEVICE_ID_PAD_0;
|
||||
NativeKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
void ICadeTracker::ButtonUp(iCadeState button) {
|
||||
if (!iCadeConnectNotified) {
|
||||
iCadeConnectNotified = true;
|
||||
KeyMap::NotifyPadConnected(DEVICE_ID_PAD_0, "iCade");
|
||||
}
|
||||
|
||||
if (button == iCadeButtonA) {
|
||||
// Pressing Select twice within 1 second toggles the DPad between
|
||||
// normal operation and simulating the Analog stick.
|
||||
if ((lastSelectPress + 1.0f) > time_now_d())
|
||||
simulateAnalog = !simulateAnalog;
|
||||
lastSelectPress = time_now_d();
|
||||
}
|
||||
|
||||
if (button == iCadeButtonC) {
|
||||
// Pressing Start twice within 1 second will take to the Emu menu
|
||||
if ((lastStartPress + 1.0f) > time_now_d()) {
|
||||
KeyInput key;
|
||||
key.flags = KeyInputFlags::DOWN;
|
||||
key.keyCode = NKCODE_ESCAPE;
|
||||
key.deviceId = DEVICE_ID_KEYBOARD;
|
||||
NativeKey(key);
|
||||
return;
|
||||
}
|
||||
lastStartPress = time_now_d();
|
||||
}
|
||||
|
||||
if (simulateAnalog &&
|
||||
((button == iCadeJoystickUp) ||
|
||||
(button == iCadeJoystickDown) ||
|
||||
(button == iCadeJoystickLeft) ||
|
||||
(button == iCadeJoystickRight))) {
|
||||
AxisInput axis;
|
||||
switch (button) {
|
||||
case iCadeJoystickUp :
|
||||
axis.axisId = JOYSTICK_AXIS_Y;
|
||||
axis.value = 0.0f;
|
||||
break;
|
||||
|
||||
case iCadeJoystickDown :
|
||||
axis.axisId = JOYSTICK_AXIS_Y;
|
||||
axis.value = 0.0f;
|
||||
break;
|
||||
|
||||
case iCadeJoystickLeft :
|
||||
axis.axisId = JOYSTICK_AXIS_X;
|
||||
axis.value = 0.0f;
|
||||
break;
|
||||
|
||||
case iCadeJoystickRight :
|
||||
axis.axisId = JOYSTICK_AXIS_X;
|
||||
axis.value = 0.0f;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
axis.deviceId = DEVICE_ID_PAD_0;
|
||||
NativeAxis(&axis, 1);
|
||||
} else {
|
||||
KeyInput key;
|
||||
key.flags = KeyInputFlags::UP;
|
||||
key.keyCode = iCadeToKeyMap[button];
|
||||
key.deviceId = DEVICE_ID_PAD_0;
|
||||
NativeKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessAccelerometerData(CMAccelerometerData *accData) {
|
||||
CMAcceleration acc = accData.acceleration;
|
||||
// INFO_LOG(SYSTEM, "%f %f %f", acc.x, acc.y, acc.z);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <GLKit/GLKit.h>
|
||||
|
||||
#import "iCade/iCadeReaderView.h"
|
||||
#import "LocationHelper.h"
|
||||
|
||||
#import "ViewControllerCommon.h"
|
||||
|
||||
@@ -138,11 +138,6 @@ PPSSPPBaseViewController *sharedViewController;
|
||||
ERROR_LOG(Log::G3D, "InitSurface failed: %s", errorMessage.c_str());
|
||||
}
|
||||
|
||||
/*self.iCadeView = [[iCadeReaderView alloc] init];
|
||||
[self.view addSubview:self.iCadeView];
|
||||
self.iCadeView.delegate = self;
|
||||
self.iCadeView.active = YES;*/
|
||||
|
||||
if ([[GCController controllers] count] > 0) {
|
||||
[self setupController:[[GCController controllers] firstObject]];
|
||||
}
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
|
||||
#import "CameraHelper.h"
|
||||
#import "LocationHelper.h"
|
||||
#import "iCade/iCadeReaderView.h"
|
||||
|
||||
@interface PPSSPPBaseViewController : UIViewController<
|
||||
UIImagePickerControllerDelegate, UINavigationControllerDelegate,
|
||||
PHPickerViewControllerDelegate,
|
||||
CameraFrameDelegate, LocationHandlerDelegate,
|
||||
UIGestureRecognizerDelegate, iCadeEventDelegate>
|
||||
UIGestureRecognizerDelegate>
|
||||
|
||||
- (void)hideKeyboard;
|
||||
- (void)showKeyboard;
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
@interface PPSSPPBaseViewController () {
|
||||
CameraHelper *cameraHelper;
|
||||
LocationHelper *locationHelper;
|
||||
ICadeTracker g_iCadeTracker;
|
||||
TouchTracker g_touchTracker;
|
||||
}
|
||||
|
||||
@@ -98,8 +97,6 @@ static int GetPickerRequestId(id picker) {
|
||||
if (self) {
|
||||
sharedViewController = self;
|
||||
|
||||
g_iCadeTracker.InitKeyMap();
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil];
|
||||
@@ -474,16 +471,6 @@ extern float g_safeInsetBottom;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)buttonDown:(iCadeState)button
|
||||
{
|
||||
g_iCadeTracker.ButtonDown(button);
|
||||
}
|
||||
|
||||
- (void)buttonUp:(iCadeState)button
|
||||
{
|
||||
g_iCadeTracker.ButtonUp(button);
|
||||
}
|
||||
|
||||
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
|
||||
KeyboardPressesBegan(presses, event);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
|
||||
#import "ViewControllerCommon.h"
|
||||
#import "iCade/iCadeReaderView.h"
|
||||
|
||||
@interface PPSSPPViewControllerMetal : PPSSPPBaseViewController
|
||||
@end
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
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 <UIKit/UIKit.h>
|
||||
#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 <NSObject>
|
||||
|
||||
@optional
|
||||
- (void)stateChanged:(iCadeState)state;
|
||||
- (void)buttonDown:(iCadeState)button;
|
||||
- (void)buttonUp:(iCadeState)button;
|
||||
|
||||
@end
|
||||
|
||||
@interface iCadeReaderView : UIView<UIKeyInput> {
|
||||
UIView *inputView;
|
||||
iCadeState _iCadeState;
|
||||
id<iCadeEventDelegate> __weak _delegate;
|
||||
|
||||
struct {
|
||||
bool stateChanged:1;
|
||||
bool buttonDown:1;
|
||||
bool buttonUp:1;
|
||||
} _delegateFlags;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) iCadeState iCadeState;
|
||||
@property (nonatomic, weak) id<iCadeEventDelegate> delegate;
|
||||
@property (nonatomic, assign) BOOL active;
|
||||
|
||||
@end
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
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 * const ON_STATES = "wdxayhujikol";
|
||||
static const char * const OFF_STATES = "eczqtrfnmpgv";
|
||||
|
||||
@interface iCadeReaderView()
|
||||
|
||||
- (void)didEnterBackground;
|
||||
- (void)didBecomeActive;
|
||||
|
||||
@end
|
||||
|
||||
@implementation iCadeReaderView
|
||||
|
||||
@synthesize iCadeState=_iCadeState, delegate=_delegate, 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<iCadeEventDelegate>)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
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
Reference in new issue
Block a user