aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ios7/ios7_keyboard.mm
diff options
context:
space:
mode:
authorThierry Crozat2019-06-23 21:46:47 +0100
committerThierry Crozat2019-06-30 12:36:43 +0100
commit3ba9245138b6b6c9fe4450ece8d91a893b8a3e1f (patch)
tree701afcad5630d5eecbcefd2fbcec14a174c7739c /backends/platform/ios7/ios7_keyboard.mm
parentd6a1248a160d2cd55c274cf9bb106e7273d9f003 (diff)
downloadscummvm-rg350-3ba9245138b6b6c9fe4450ece8d91a893b8a3e1f.tar.gz
scummvm-rg350-3ba9245138b6b6c9fe4450ece8d91a893b8a3e1f.tar.bz2
scummvm-rg350-3ba9245138b6b6c9fe4450ece8d91a893b8a3e1f.zip
IOS7: Add input accessory view to virtual keyboard
This adds buttons for some keys that are not present on the iOS keyboard, such as the function and arrow keys, as well as a GMM key.
Diffstat (limited to 'backends/platform/ios7/ios7_keyboard.mm')
-rw-r--r--backends/platform/ios7/ios7_keyboard.mm149
1 files changed, 145 insertions, 4 deletions
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];
}