mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(iOS 7) Bring back keyboard mode
This commit is contained in:
parent
12bd064490
commit
ed2724e5ee
@ -70,7 +70,6 @@
|
||||
static const float ALMOST_INVISIBLE = .021f;
|
||||
static GLKView* g_view;
|
||||
static UIView* g_pause_indicator_view;
|
||||
static UITextField* g_text_hide;
|
||||
|
||||
// Camera
|
||||
static AVCaptureSession *_session;
|
||||
@ -156,14 +155,6 @@ static bool g_is_syncing = true;
|
||||
g_view.enableSetNeedsDisplay = NO;
|
||||
[g_view addSubview:g_pause_indicator_view];
|
||||
|
||||
if (is_ios_7())
|
||||
{
|
||||
g_text_hide = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||
[g_view addSubview:g_text_hide];
|
||||
g_text_hide.hidden = YES;
|
||||
[g_text_hide becomeFirstResponder];
|
||||
}
|
||||
|
||||
self.view = g_view;
|
||||
return self;
|
||||
}
|
||||
@ -182,9 +173,6 @@ static bool g_is_syncing = true;
|
||||
|
||||
g_pause_indicator_view.frame = CGRectMake(tenpctw * 4.0f, 0.0f, tenpctw * 2.0f, tenpcth);
|
||||
[g_pause_indicator_view viewWithTag:1].frame = CGRectMake(0, 0, tenpctw * 2.0f, tenpcth);
|
||||
|
||||
if (is_ios_7())
|
||||
[g_text_hide becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)hidePauseButton
|
||||
@ -195,12 +183,6 @@ static bool g_is_syncing = true;
|
||||
];
|
||||
}
|
||||
|
||||
- (void)iOS7SetiCadeMode:(bool)on
|
||||
{
|
||||
g_text_hide.enabled = on;
|
||||
[self viewWillLayoutSubviews];
|
||||
}
|
||||
|
||||
void event_process_camera_frame(void* pixelBufferPtr)
|
||||
{
|
||||
CVPixelBufferRef pixelBuffer = (CVPixelBufferRef)pixelBufferPtr;
|
||||
|
@ -359,9 +359,6 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
||||
delegate:self
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:@"Clear Keyboard", @"Clear Joystick", @"Clear Axis", nil];
|
||||
|
||||
if (is_ios_7())
|
||||
self.alert.alertViewStyle = UIAlertViewStylePlainTextInput;
|
||||
|
||||
[self.alert show];
|
||||
|
||||
|
@ -42,7 +42,6 @@ const void* apple_get_frontend_settings(void);
|
||||
|
||||
@interface RAGameView : UIViewController<AVCaptureAudioDataOutputSampleBufferDelegate>
|
||||
+ (RAGameView*)get;
|
||||
- (void)iOS7SetiCadeMode:(bool)on;
|
||||
@end
|
||||
|
||||
@interface RetroArch_iOS : UINavigationController<UIApplicationDelegate, UINavigationControllerDelegate, RetroArch_Platform>
|
||||
@ -67,6 +66,5 @@ const void* apple_get_frontend_settings(void);
|
||||
|
||||
// modes are: keyboard, icade and btstack
|
||||
void ios_set_bluetooth_mode(NSString* mode);
|
||||
bool is_ios_7();
|
||||
|
||||
#endif
|
||||
|
@ -32,27 +32,10 @@
|
||||
|
||||
apple_frontend_settings_t apple_frontend_settings;
|
||||
|
||||
//#define HAVE_DEBUG_FILELOG
|
||||
bool is_ios_7()
|
||||
{
|
||||
return [[UIDevice currentDevice].systemVersion compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending;
|
||||
}
|
||||
|
||||
void ios_set_bluetooth_mode(NSString* mode)
|
||||
{
|
||||
if (!is_ios_7())
|
||||
{
|
||||
apple_input_enable_icade([mode isEqualToString:@"icade"]);
|
||||
btstack_set_poweron([mode isEqualToString:@"btstack"]);
|
||||
}
|
||||
#ifdef __IPHONE_7_0 // iOS7 iCade Support
|
||||
else
|
||||
{
|
||||
bool enabled = [mode isEqualToString:@"icade"];
|
||||
apple_input_enable_icade(enabled);
|
||||
[[RAGameView get] iOS7SetiCadeMode:enabled];
|
||||
}
|
||||
#endif
|
||||
apple_input_enable_icade([mode isEqualToString:@"icade"]);
|
||||
btstack_set_poweron([mode isEqualToString:@"btstack"]);
|
||||
}
|
||||
|
||||
const void* apple_get_frontend_settings(void)
|
||||
@ -70,9 +53,7 @@ const void* apple_get_frontend_settings(void)
|
||||
sizeof(apple_frontend_settings.bluetooth_mode), "none");
|
||||
|
||||
// Set ios_btmode options based on runtime environment
|
||||
if (is_ios_7())
|
||||
settings[4].values = "none|icade";
|
||||
else if (btstack_try_load())
|
||||
if (btstack_try_load())
|
||||
settings[4].values = "none|icade|keyboard|btstack";
|
||||
else
|
||||
settings[4].values = "none|icade|keyboard";
|
||||
@ -138,52 +119,33 @@ static void handle_touch_event(NSArray* touches)
|
||||
|
||||
@implementation RApplication
|
||||
|
||||
// iOS7: This method is called instead of sendEvent for key events; do not try to merge it
|
||||
// with the sendEvent method.
|
||||
- (void)handleKeyUIEvent:(UIEvent*)event
|
||||
{
|
||||
if ([event respondsToSelector:@selector(_gsEvent)])
|
||||
{
|
||||
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
|
||||
uint8_t* eventMem = (uint8_t*)(void*)CFBridgingRetain([event performSelector:@selector(_gsEvent)]);
|
||||
int eventType = eventMem ? *(int*)&eventMem[8] : 0;
|
||||
|
||||
if (eventType == GSEVENT_TYPE_KEYDOWN || eventType == GSEVENT_TYPE_KEYUP)
|
||||
apple_input_handle_key_event(*(uint16_t*)&eventMem[0x3C], eventType == GSEVENT_TYPE_KEYDOWN);
|
||||
|
||||
CFBridgingRelease(eventMem);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
[super sendEvent:event];
|
||||
|
||||
if ([[event allTouches] count])
|
||||
handle_touch_event(event.allTouches.allObjects);
|
||||
else if ([event respondsToSelector:@selector(_gsEvent)])
|
||||
{
|
||||
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
|
||||
uint8_t* eventMem = (uint8_t*)(void*)CFBridgingRetain([event performSelector:@selector(_gsEvent)]);
|
||||
int eventType = eventMem ? *(int*)&eventMem[8] : 0;
|
||||
|
||||
if (eventType == GSEVENT_TYPE_KEYDOWN || eventType == GSEVENT_TYPE_KEYUP)
|
||||
apple_input_handle_key_event(*(uint16_t*)&eventMem[0x3C], eventType == GSEVENT_TYPE_KEYDOWN);
|
||||
|
||||
CFBridgingRelease(eventMem);
|
||||
}
|
||||
[self handleKeyUIEvent:event];
|
||||
}
|
||||
|
||||
#ifdef __IPHONE_7_0 // iOS7 iCade Support
|
||||
|
||||
- (NSArray*)keyCommands
|
||||
{
|
||||
static NSMutableArray* key_commands;
|
||||
|
||||
if (!key_commands)
|
||||
{
|
||||
key_commands = [NSMutableArray array];
|
||||
|
||||
for (int i = 0; i < 26; i ++)
|
||||
{
|
||||
[key_commands addObject:[UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:@"%c", 'a' + i]
|
||||
modifierFlags:0 action:@selector(keyGotten:)]];
|
||||
}
|
||||
}
|
||||
|
||||
return key_commands;
|
||||
}
|
||||
|
||||
- (void)keyGotten:(UIKeyCommand *)keyCommand
|
||||
{
|
||||
apple_input_handle_key_event([keyCommand.input characterAtIndex:0] - 'a' + 4, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@implementation RetroArch_iOS
|
||||
|
Loading…
x
Reference in New Issue
Block a user