Skip to content

Commit 9f2e3f8

Browse files
committed
support bluetooth HID pointing devices through BTC Mouse
1 parent 81d985f commit 9f2e3f8

File tree

7 files changed

+43
-1
lines changed

7 files changed

+43
-1
lines changed

Mini vMac.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@
274274
283423EC1CFA329C0088B634 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
275275
283423ED1CFA329C0088B634 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = "<group>"; };
276276
283423EE1CFA329C0088B634 /* Icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@3x.png"; sourceTree = "<group>"; };
277+
283CA9821DF47AF300B33D5E /* BTCMouse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTCMouse.h; sourceTree = "<group>"; };
277278
285A8C901D05AFD3002993DE /* PlugIn-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PlugIn-Info.plist"; sourceTree = "<group>"; };
278279
28848B601CDE97D600B86C45 /* InsertDiskViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InsertDiskViewController.h; sourceTree = "<group>"; };
279280
28848B611CDE97D600B86C45 /* InsertDiskViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InsertDiskViewController.m; sourceTree = "<group>"; };
@@ -628,6 +629,7 @@
628629
28F6B4511CF07C48002D76D0 /* UIImage+DiskImageIcon.m */,
629630
28F6B4C91CF1FA7A002D76D0 /* about.plist */,
630631
28F6B4CE1CF77099002D76D0 /* compat.m */,
632+
283CA9821DF47AF300B33D5E /* BTCMouse.h */,
631633
283422EF1CF8F33A0088B634 /* Emulator Bundles */,
632634
);
633635
path = "Mini vMac";

Mini vMac/AppDelegate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <UIKit/UIKit.h>
1010
#import "EmulatorProtocol.h"
11+
#import "BTCMouse.h"
1112

1213
extern NSString *DocumentsChangedNotification;
1314

Mini vMac/AppDelegate.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
static NSObject<Emulator> *sharedEmulator = nil;
1616
NSString *DocumentsChangedNotification = @"documentsChanged";
1717

18-
@interface AppDelegate () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning>
18+
@interface AppDelegate () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning, BTCMouseDelegate>
1919

2020
@end
2121

@@ -40,6 +40,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4040
[self initDefaults];
4141
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:NULL];
4242
[sharedEmulator performSelector:@selector(run) withObject:nil afterDelay:0.1];
43+
44+
if ([application respondsToSelector:@selector(btcMouseSetRawMode:)]) {
45+
[application btcMouseSetRawMode:YES];
46+
[application btcMouseSetDelegate:self];
47+
}
4348
return YES;
4449
}
4550

@@ -109,6 +114,11 @@ - (void)applicationDidEnterBackground:(UIApplication *)application {
109114
}
110115
}
111116

117+
- (void)handleEventWithMove:(CGPoint)move andWheel:(float)wheel andPan:(float)pan andButtons:(int)buttons {
118+
[sharedEmulator moveMouseX:move.x/2.0 Y:move.y/2.0];
119+
[sharedEmulator setMouseButton:buttons == 1];
120+
}
121+
112122
- (void)applicationWillEnterForeground:(UIApplication *)application {
113123
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
114124
if (sharedEmulator.running) {

Mini vMac/BTCMouse.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// BTCMouse.h
3+
// Mini vMac
4+
//
5+
// Created by Jesús A. Álvarez on 04/12/2016.
6+
// Copyright © 2016 namedfork. All rights reserved.
7+
//
8+
9+
10+
@protocol BTCMouseDelegate
11+
- (void)handleEventWithMove:(CGPoint)move andWheel:(float)wheel andPan:(float)pan andButtons:(int)buttons;
12+
@end
13+
14+
@interface UIApplication (BTCMouse)
15+
- (void)btcMouseSetPanning:(BOOL)panning;
16+
- (void)btcMouseSetZooming:(BOOL)zooming;
17+
- (void)btcMouseSetDelegate:(id<BTCMouseDelegate>)delegate;
18+
- (void)btcMouseSetRawMode:(BOOL)rawMode;
19+
@end
20+

Mini vMac/InsertDiskViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ - (void)viewDidAppear:(BOOL)animated {
6565
[nc addObserver:self selector:@selector(reloadData:) name:[AppDelegate sharedEmulator].insertDiskNotification object:nil];
6666
[nc addObserver:self selector:@selector(reloadData:) name:[AppDelegate sharedEmulator].ejectDiskNotification object:nil];
6767
[nc addObserver:self selector:@selector(reloadData:) name:DocumentsChangedNotification object:nil];
68+
if ([UIApplication instancesRespondToSelector:@selector(btcMouseSetRawMode:)]) {
69+
[[UIApplication sharedApplication] btcMouseSetRawMode:NO];
70+
}
6871
}
6972

7073
- (void)viewDidDisappear:(BOOL)animated {

Mini vMac/SettingsViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ - (void)loadCredits {
9090
- (void)viewDidAppear:(BOOL)animated {
9191
[super viewDidAppear:animated];
9292
[AppDelegate sharedEmulator].running = NO;
93+
if ([UIApplication instancesRespondToSelector:@selector(btcMouseSetRawMode:)]) {
94+
[[UIApplication sharedApplication] btcMouseSetRawMode:NO];
95+
}
9396
}
9497

9598
- (void)viewWillDisappear:(BOOL)animated {

Mini vMac/ViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ - (void)setUpPointingDevice {
6464
pointingDeviceView = [[pointingDeviceClass alloc] initWithFrame:self.view.bounds];
6565
pointingDeviceView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
6666
[self.view insertSubview:pointingDeviceView aboveSubview:self.screenView];
67+
if ([UIApplication instancesRespondToSelector:@selector(btcMouseSetRawMode:)]) {
68+
[[UIApplication sharedApplication] btcMouseSetRawMode:YES];
69+
}
6770
}
6871

6972
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {

0 commit comments

Comments
 (0)