aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/ios7/ios7_common.h3
-rw-r--r--backends/platform/ios7/ios7_keyboard.h1
-rw-r--r--backends/platform/ios7/ios7_keyboard.mm149
-rw-r--r--backends/platform/ios7/ios7_osys_events.cpp6
-rw-r--r--backends/platform/ios7/ios7_video.mm4
5 files changed, 158 insertions, 5 deletions
diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index e2ff43441f..aa5134335e 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -40,7 +40,8 @@ enum InputEvent {
kInputApplicationSuspended,
kInputApplicationResumed,
kInputSwipe,
- kInputTap
+ kInputTap,
+ kInputMainMenu
};
enum ScreenOrientation {
diff --git a/backends/platform/ios7/ios7_keyboard.h b/backends/platform/ios7/ios7_keyboard.h
index 1f917cc8c5..51e1ba9c3f 100644
--- a/backends/platform/ios7/ios7_keyboard.h
+++ b/backends/platform/ios7/ios7_keyboard.h
@@ -35,6 +35,7 @@
- (UITextView *)inputView;
- (void)setInputDelegate:(id)delegate;
- (void)handleKeyPress:(unichar)c;
+- (void)handleMainMenuKey;
- (void)showKeyboard;
- (void)hideKeyboard;
diff --git a/backends/platform/ios7/ios7_keyboard.mm b/backends/platform/ios7/ios7_keyboard.mm
index ff084a1a9e..1d25161600 100644
--- a/backends/platform/ios7/ios7_keyboard.mm
+++ b/backends/platform/ios7/ios7_keyboard.mm
@@ -21,6 +21,7 @@
*/
#include "backends/platform/ios7/ios7_keyboard.h"
+#include "common/keyboard.h"
@interface UITextInputTraits
- (void)setAutocorrectionType:(int)type;
@@ -50,6 +51,66 @@
//item.leadingBarButtonGroups = @[];
//item.trailingBarButtonGroups = @[];
+ UIToolbar *toolbar = [[[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)] autorelease];
+ toolbar.barTintColor = keyboard.backgroundColor;
+ toolbar.tintColor = keyboard.tintColor;
+ toolbar.translucent = NO;
+
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
+ toolbar.items = @[
+ // GMM button
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u2630" style:UIBarButtonItemStylePlain target:self action:@selector(mainMenuKey)] autorelease],
+ // Escape key
+ [[[UIBarButtonItem alloc] initWithTitle:@"Esc" style:UIBarButtonItemStylePlain target:self action:@selector(escapeKey)] autorelease],
+ // Return key
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u23ce" style:UIBarButtonItemStylePlain target:self action:@selector(returnKey)] autorelease],
+ // Function keys
+ [[[UIBarButtonItem alloc] initWithTitle:@"F1" style:UIBarButtonItemStylePlain target:self action:@selector(fn1Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F2" style:UIBarButtonItemStylePlain target:self action:@selector(fn2Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F3" style:UIBarButtonItemStylePlain target:self action:@selector(fn3Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F4" style:UIBarButtonItemStylePlain target:self action:@selector(fn4Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F5" style:UIBarButtonItemStylePlain target:self action:@selector(fn5Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F6" style:UIBarButtonItemStylePlain target:self action:@selector(fn6Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F7" style:UIBarButtonItemStylePlain target:self action:@selector(fn7Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F8" style:UIBarButtonItemStylePlain target:self action:@selector(fn8Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F9" style:UIBarButtonItemStylePlain target:self action:@selector(fn9Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F10" style:UIBarButtonItemStylePlain target:self action:@selector(fn10Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F11" style:UIBarButtonItemStylePlain target:self action:@selector(fn11Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F12" style:UIBarButtonItemStylePlain target:self action:@selector(fn12Key)] autorelease],
+ // Arrow keys
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u2190" style:UIBarButtonItemStylePlain target:self action:@selector(leftArrowKey)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u2191" style:UIBarButtonItemStylePlain target:self action:@selector(upArrowKey)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u2192" style:UIBarButtonItemStylePlain target:self action:@selector(rightArrowKey)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u2193" style:UIBarButtonItemStylePlain target:self action:@selector(downArrowKey)] autorelease],
+ // Spacer at the end
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ ];
+ } else {
+ // There is less space, so only add buttons for keys for which we do not have getsures
+ toolbar.items = @[
+ // Return key
+ [[[UIBarButtonItem alloc] initWithTitle:@"\u23ce" style:UIBarButtonItemStylePlain target:self action:@selector(returnKey)] autorelease],
+ // Function keys
+ [[[UIBarButtonItem alloc] initWithTitle:@"F1" style:UIBarButtonItemStylePlain target:self action:@selector(fn1Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F2" style:UIBarButtonItemStylePlain target:self action:@selector(fn2Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F3" style:UIBarButtonItemStylePlain target:self action:@selector(fn3Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F4" style:UIBarButtonItemStylePlain target:self action:@selector(fn4Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F5" style:UIBarButtonItemStylePlain target:self action:@selector(fn5Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F6" style:UIBarButtonItemStylePlain target:self action:@selector(fn6Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F7" style:UIBarButtonItemStylePlain target:self action:@selector(fn7Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F8" style:UIBarButtonItemStylePlain target:self action:@selector(fn8Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F9" style:UIBarButtonItemStylePlain target:self action:@selector(fn9Key)] autorelease],
+ [[[UIBarButtonItem alloc] initWithTitle:@"F10" style:UIBarButtonItemStylePlain target:self action:@selector(fn10Key)] autorelease],
+// [[[UIBarButtonItem alloc] initWithTitle:@"F11" style:UIBarButtonItemStylePlain target:self action:@selector(fn11Key)] autorelease],
+// [[[UIBarButtonItem alloc] initWithTitle:@"F12" style:UIBarButtonItemStylePlain target:self action:@selector(fn12Key)] autorelease],
+ // Spacer at the end
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ ];
+ }
+
+ self.inputAccessoryView = toolbar;
+ [toolbar sizeToFit];
+
return self;
}
@@ -62,19 +123,95 @@
}
- (void) upArrow: (UIKeyCommand *) keyCommand {
- [softKeyboard handleKeyPress:273];
+ [softKeyboard handleKeyPress:Common::KEYCODE_UP];
}
- (void) downArrow: (UIKeyCommand *) keyCommand {
- [softKeyboard handleKeyPress:274];
+ [softKeyboard handleKeyPress:Common::KEYCODE_DOWN];
}
- (void) leftArrow: (UIKeyCommand *) keyCommand {
- [softKeyboard handleKeyPress:276];
+ [softKeyboard handleKeyPress:Common::KEYCODE_LEFT];
}
- (void) rightArrow: (UIKeyCommand *) keyCommand {
- [softKeyboard handleKeyPress:275];
+ [softKeyboard handleKeyPress:Common::KEYCODE_RIGHT];
+}
+
+- (void) mainMenuKey {
+ [softKeyboard handleMainMenuKey];
+}
+
+- (void) escapeKey {
+ [softKeyboard handleKeyPress:Common::KEYCODE_ESCAPE];
+}
+
+- (void) fn1Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F1];
+}
+
+- (void) fn2Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F2];
+}
+
+- (void) fn3Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F3];
+}
+
+- (void) fn4Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F4];
+}
+
+- (void) fn5Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F5];
+}
+
+- (void) fn6Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F6];
+}
+
+- (void) fn7Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F7];
+}
+
+- (void) fn8Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F8];
+}
+
+- (void) fn9Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F9];
+}
+
+- (void) fn10Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F10];
+}
+
+- (void) fn11Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F11];
+}
+
+- (void) fn12Key {
+ [softKeyboard handleKeyPress:Common::KEYCODE_F12];
+}
+
+- (void) leftArrowKey {
+ [softKeyboard handleKeyPress:Common::KEYCODE_LEFT];
+}
+
+- (void) upArrowKey {
+ [softKeyboard handleKeyPress:Common::KEYCODE_UP];
+}
+
+- (void) rightArrowKey {
+ [softKeyboard handleKeyPress:Common::KEYCODE_RIGHT];
+}
+
+- (void) downArrowKey {
+ [softKeyboard handleKeyPress:Common::KEYCODE_DOWN];
+}
+
+- (void) returnKey {
+ [softKeyboard handleKeyPress:Common::KEYCODE_RETURN];
}
@end
@@ -114,6 +251,10 @@
[inputDelegate handleKeyPress:c];
}
+- (void)handleMainMenuKey {
+ [inputDelegate handleMainMenuKey];
+}
+
- (void)showKeyboard {
[inputView becomeFirstResponder];
}
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index da467cf5d6..9924264cd8 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -106,6 +106,12 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
return false;
break;
+ case kInputMainMenu:
+ event.type = Common::EVENT_MAINMENU;
+ _queuedInputEvent.type = Common::EVENT_INVALID;
+ _queuedEventTime = getMillis() + kQueuedInputEventDelay;
+ break;
+
default:
break;
}
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index b00ecf64f9..17d0e1aaaa 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -1066,6 +1066,10 @@ uint getSizeNextPOT(uint size) {
}
}
+- (void)handleMainMenuKey {
+ [self addEvent:InternalEvent(kInputMainMenu, 0, 0)];
+}
+
- (void)applicationSuspend {
[self addEvent:InternalEvent(kInputApplicationSuspended, 0, 0)];
}