mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-11-22 03:30:59 +00:00
support bluetooth keyboard
This commit is contained in:
parent
c6f4b9e0f6
commit
f21cb523de
@ -14,6 +14,7 @@
|
||||
28BA89801CE7315400A98104 /* KBKeyboardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89791CE7315400A98104 /* KBKeyboardView.m */; };
|
||||
28BA89821CE7336500A98104 /* Keyboard Layouts in Resources */ = {isa = PBXBuildFile; fileRef = 28BA89811CE7336500A98104 /* Keyboard Layouts */; };
|
||||
28BA89851CE73E7200A98104 /* TrackPad.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89841CE73E7200A98104 /* TrackPad.m */; };
|
||||
28BA89881CE73FBC00A98104 /* MNVMApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89871CE73FBC00A98104 /* MNVMApplication.m */; };
|
||||
28CE8EB51CD4C3B200FE25A8 /* GLOBGLUE.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E931CD4C3B200FE25A8 /* GLOBGLUE.c */; };
|
||||
28CE8EB61CD4C3B200FE25A8 /* IWMEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E961CD4C3B200FE25A8 /* IWMEMDEV.c */; };
|
||||
28CE8EB71CD4C3B200FE25A8 /* KBRDEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E981CD4C3B200FE25A8 /* KBRDEMDV.c */; };
|
||||
@ -54,6 +55,8 @@
|
||||
28BA89811CE7336500A98104 /* Keyboard Layouts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "Keyboard Layouts"; sourceTree = "<group>"; };
|
||||
28BA89831CE73E7200A98104 /* TrackPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackPad.h; sourceTree = "<group>"; };
|
||||
28BA89841CE73E7200A98104 /* TrackPad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TrackPad.m; sourceTree = "<group>"; };
|
||||
28BA89861CE73FBC00A98104 /* MNVMApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNVMApplication.h; sourceTree = "<group>"; };
|
||||
28BA89871CE73FBC00A98104 /* MNVMApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MNVMApplication.m; sourceTree = "<group>"; };
|
||||
28CE8E881CD4C33E00FE25A8 /* CNFGGLOB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGGLOB.h; sourceTree = "<group>"; };
|
||||
28CE8E891CD4C33E00FE25A8 /* CNFGRAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGRAPI.h; sourceTree = "<group>"; };
|
||||
28CE8E8A1CD4C33E00FE25A8 /* EMCONFIG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EMCONFIG.h; sourceTree = "<group>"; };
|
||||
@ -213,6 +216,8 @@
|
||||
children = (
|
||||
28F676C31CD15E0B00FC6FA6 /* AppDelegate.h */,
|
||||
28F676C41CD15E0B00FC6FA6 /* AppDelegate.m */,
|
||||
28BA89861CE73FBC00A98104 /* MNVMApplication.h */,
|
||||
28BA89871CE73FBC00A98104 /* MNVMApplication.m */,
|
||||
28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */,
|
||||
28CE8ED41CD4F56C00FE25A8 /* ScreenView.h */,
|
||||
28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */,
|
||||
@ -277,6 +282,7 @@
|
||||
TargetAttributes = {
|
||||
28F676BC1CD15E0B00FC6FA6 = {
|
||||
CreatedOnToolsVersion = 7.3;
|
||||
DevelopmentTeam = UJXNDZ5TNU;
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -331,6 +337,7 @@
|
||||
28CE8EC31CD4C3B200FE25A8 /* VIAEMDEV.c in Sources */,
|
||||
28CE8EB81CD4C3B200FE25A8 /* M68KITAB.c in Sources */,
|
||||
28848B651CDE97E900B86C45 /* SettingsViewController.m in Sources */,
|
||||
28BA89881CE73FBC00A98104 /* MNVMApplication.m in Sources */,
|
||||
28CE8EB71CD4C3B200FE25A8 /* KBRDEMDV.c in Sources */,
|
||||
28CE8EBC1CD4C3B200FE25A8 /* ROMEMDEV.c in Sources */,
|
||||
28BA897F1CE7315400A98104 /* KBKeyboardLayout.m in Sources */,
|
||||
@ -457,10 +464,13 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
INFOPLIST_FILE = "Mini vMac/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.namedfork.minivmac;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -468,10 +478,13 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
INFOPLIST_FILE = "Mini vMac/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.namedfork.minivmac;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
13
Mini vMac/MNVMApplication.h
Normal file
13
Mini vMac/MNVMApplication.h
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// MNVMApplication.h
|
||||
// Mini vMac
|
||||
//
|
||||
// Created by Jesús A. Álvarez on 14/05/2016.
|
||||
// Copyright © 2016 namedfork. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MNVMApplication : UIApplication
|
||||
|
||||
@end
|
109
Mini vMac/MNVMApplication.m
Normal file
109
Mini vMac/MNVMApplication.m
Normal file
@ -0,0 +1,109 @@
|
||||
//
|
||||
// MNVMApplication.m
|
||||
// Mini vMac
|
||||
//
|
||||
// Created by Jesús A. Álvarez on 14/05/2016.
|
||||
// Copyright © 2016 namedfork. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MNVMApplication.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface UIApplication ()
|
||||
- (void)handleKeyUIEvent:(UIEvent *)event;
|
||||
@end
|
||||
|
||||
Class keyboardEventClass = nil;
|
||||
|
||||
static int8_t usb_to_adb_scancode[] = {
|
||||
-1, -1, -1, -1, 0, 11, 8, 2, 14, 3, 5, 4, 34, 38, 40, 37,
|
||||
46, 45, 31, 35, 12, 15, 1, 17, 32, 9, 13, 7, 16, 6, 18, 19,
|
||||
20, 21, 23, 22, 26, 28, 25, 29, 36, 53, 51, 48, 49, 27, 24, 33,
|
||||
30, 42, 42, 41, 39, 10, 43, 47, 44, 57, 122, 120, 99, 118, 96, 97,
|
||||
98, 100, 101, 109, 103, 111, 105, 107, 113, 114, 115, 116, 117, 119, 121, 60,
|
||||
59, 61, 62, 71, 75, 67, 78, 69, 76, 83, 84, 85, 86, 87, 88, 89,
|
||||
91, 92, 82, 65, 50, 55, 126, 81, 105, 107, 113, 106, 64, 79, 80, 90,
|
||||
-1, -1, -1, -1, -1, 114, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74,
|
||||
72, 73, -1, -1, -1, 95, -1, 94, -1, 93, -1, -1, -1, -1, -1, -1,
|
||||
104, 102, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
54, 56, 58, 55, 54, 56, 58, 55, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
@interface UIPhysicalKeyboardEvent : UIPressesEvent
|
||||
|
||||
@property (nonatomic, readonly) BOOL _isKeyDown;
|
||||
@property (nonatomic, readonly) long _keyCode;
|
||||
@property (nonatomic) int _modifierFlags;
|
||||
@property(retain, nonatomic) NSString *_unmodifiedInput;
|
||||
@property(retain, nonatomic) NSString *_modifiedInput;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MNVMApplication
|
||||
{
|
||||
BOOL physicalCapsLocked;
|
||||
}
|
||||
|
||||
+ (void)load {
|
||||
// class is not visible
|
||||
keyboardEventClass = NSClassFromString(@"UIPhysicalKeyboardEvent");
|
||||
}
|
||||
|
||||
- (void)handleKeyboardEvent:(UIPhysicalKeyboardEvent *)event {
|
||||
long keycode = event._keyCode;
|
||||
int scancode = -1;
|
||||
|
||||
if (keycode >= 0 && keycode < sizeof(usb_to_adb_scancode)) {
|
||||
scancode = usb_to_adb_scancode[keycode];
|
||||
}
|
||||
|
||||
if (scancode == 57) {
|
||||
// caps lock
|
||||
if (event._isKeyDown && !physicalCapsLocked) {
|
||||
[[AppDelegate sharedInstance] keyDown:scancode];
|
||||
physicalCapsLocked = YES;
|
||||
} else if (event._isKeyDown && physicalCapsLocked) {
|
||||
[[AppDelegate sharedInstance] keyUp:scancode];
|
||||
physicalCapsLocked = NO;
|
||||
}
|
||||
} else if (scancode >= 0 && [AppDelegate sharedInstance].emulatorRunning) {
|
||||
if (event._isKeyDown) {
|
||||
[self _updateCapsLockStatus:event];
|
||||
[[AppDelegate sharedInstance] keyDown:scancode];
|
||||
} else {
|
||||
[[AppDelegate sharedInstance] keyUp:scancode];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_updateCapsLockStatus:(UIPhysicalKeyboardEvent *)event {
|
||||
if (event._modifierFlags == 0 && event._unmodifiedInput.length == 1) {
|
||||
unichar unmodifiedChar = [event._unmodifiedInput characterAtIndex:0];
|
||||
unichar modifiedChar = [event._modifiedInput characterAtIndex:0];
|
||||
if ([[NSCharacterSet lowercaseLetterCharacterSet] characterIsMember:unmodifiedChar]) {
|
||||
BOOL currentCapsLock = [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:modifiedChar];
|
||||
if (currentCapsLock != physicalCapsLocked) {
|
||||
physicalCapsLocked = currentCapsLock;
|
||||
if (physicalCapsLocked) {
|
||||
[[AppDelegate sharedInstance] keyDown:57];
|
||||
} else {
|
||||
[[AppDelegate sharedInstance] keyUp:57];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleKeyUIEvent:(UIEvent *)event {
|
||||
[super handleKeyUIEvent:event];
|
||||
if ([event isKindOfClass:keyboardEventClass]) {
|
||||
[self handleKeyboardEvent:(UIPhysicalKeyboardEvent*)event];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
@ -11,6 +11,6 @@
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
return UIApplicationMain(argc, argv, @"MNVMApplication", NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user