mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-06-27 05:29:29 +00:00
add mouse input
This commit is contained in:
parent
7e813065fc
commit
9b4aa7a9e7
|
@ -24,6 +24,7 @@
|
||||||
28CE8EC31CD4C3B200FE25A8 /* VIAEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EB31CD4C3B200FE25A8 /* VIAEMDEV.c */; };
|
28CE8EC31CD4C3B200FE25A8 /* VIAEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EB31CD4C3B200FE25A8 /* VIAEMDEV.c */; };
|
||||||
28CE8ECC1CD4CDC500FE25A8 /* MYOSGLUE.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
28CE8ECC1CD4CDC500FE25A8 /* MYOSGLUE.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||||
28CE8ED61CD4F56C00FE25A8 /* ScreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */; };
|
28CE8ED61CD4F56C00FE25A8 /* ScreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */; };
|
||||||
|
28D5A3FD1CD6868F001A33F6 /* TouchScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D5A3FC1CD6868E001A33F6 /* TouchScreen.m */; };
|
||||||
28F676C21CD15E0B00FC6FA6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C11CD15E0B00FC6FA6 /* main.m */; };
|
28F676C21CD15E0B00FC6FA6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C11CD15E0B00FC6FA6 /* main.m */; };
|
||||||
28F676C51CD15E0B00FC6FA6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C41CD15E0B00FC6FA6 /* AppDelegate.m */; };
|
28F676C51CD15E0B00FC6FA6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C41CD15E0B00FC6FA6 /* AppDelegate.m */; };
|
||||||
28F676C81CD15E0B00FC6FA6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C71CD15E0B00FC6FA6 /* ViewController.m */; };
|
28F676C81CD15E0B00FC6FA6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C71CD15E0B00FC6FA6 /* ViewController.m */; };
|
||||||
|
@ -77,6 +78,8 @@
|
||||||
28CE8ECF1CD4D5B900FE25A8 /* INTLCHAR.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = INTLCHAR.h; sourceTree = "<group>"; };
|
28CE8ECF1CD4D5B900FE25A8 /* INTLCHAR.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = INTLCHAR.h; sourceTree = "<group>"; };
|
||||||
28CE8ED41CD4F56C00FE25A8 /* ScreenView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenView.h; sourceTree = "<group>"; };
|
28CE8ED41CD4F56C00FE25A8 /* ScreenView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenView.h; sourceTree = "<group>"; };
|
||||||
28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreenView.m; sourceTree = "<group>"; };
|
28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreenView.m; sourceTree = "<group>"; };
|
||||||
|
28D5A3FB1CD6868E001A33F6 /* TouchScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchScreen.h; sourceTree = "<group>"; };
|
||||||
|
28D5A3FC1CD6868E001A33F6 /* TouchScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TouchScreen.m; sourceTree = "<group>"; };
|
||||||
28F676BD1CD15E0B00FC6FA6 /* Mini vMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mini vMac.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
28F676BD1CD15E0B00FC6FA6 /* Mini vMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mini vMac.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
28F676C11CD15E0B00FC6FA6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
28F676C11CD15E0B00FC6FA6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
28F676C31CD15E0B00FC6FA6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
28F676C31CD15E0B00FC6FA6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
|
@ -179,6 +182,8 @@
|
||||||
28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */,
|
28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */,
|
||||||
28CE8ED41CD4F56C00FE25A8 /* ScreenView.h */,
|
28CE8ED41CD4F56C00FE25A8 /* ScreenView.h */,
|
||||||
28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */,
|
28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */,
|
||||||
|
28D5A3FB1CD6868E001A33F6 /* TouchScreen.h */,
|
||||||
|
28D5A3FC1CD6868E001A33F6 /* TouchScreen.m */,
|
||||||
28F676C61CD15E0B00FC6FA6 /* ViewController.h */,
|
28F676C61CD15E0B00FC6FA6 /* ViewController.h */,
|
||||||
28F676C71CD15E0B00FC6FA6 /* ViewController.m */,
|
28F676C71CD15E0B00FC6FA6 /* ViewController.m */,
|
||||||
28F676C91CD15E0B00FC6FA6 /* Main.storyboard */,
|
28F676C91CD15E0B00FC6FA6 /* Main.storyboard */,
|
||||||
|
@ -285,6 +290,7 @@
|
||||||
28CE8EBC1CD4C3B200FE25A8 /* ROMEMDEV.c in Sources */,
|
28CE8EBC1CD4C3B200FE25A8 /* ROMEMDEV.c in Sources */,
|
||||||
28CE8EBB1CD4C3B200FE25A8 /* PROGMAIN.c in Sources */,
|
28CE8EBB1CD4C3B200FE25A8 /* PROGMAIN.c in Sources */,
|
||||||
28F676C81CD15E0B00FC6FA6 /* ViewController.m in Sources */,
|
28F676C81CD15E0B00FC6FA6 /* ViewController.m in Sources */,
|
||||||
|
28D5A3FD1CD6868F001A33F6 /* TouchScreen.m in Sources */,
|
||||||
28CE8EC21CD4C3B200FE25A8 /* SONYEMDV.c in Sources */,
|
28CE8EC21CD4C3B200FE25A8 /* SONYEMDV.c in Sources */,
|
||||||
28F676C51CD15E0B00FC6FA6 /* AppDelegate.m in Sources */,
|
28F676C51CD15E0B00FC6FA6 /* AppDelegate.m in Sources */,
|
||||||
28CE8EBE1CD4C3B200FE25A8 /* SCCEMDEV.c in Sources */,
|
28CE8EBE1CD4C3B200FE25A8 /* SCCEMDEV.c in Sources */,
|
||||||
|
|
|
@ -11,8 +11,12 @@
|
||||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||||
|
|
||||||
@property (strong, nonatomic) UIWindow *window;
|
@property (strong, nonatomic) UIWindow *window;
|
||||||
|
@property (assign, nonatomic, getter=isEmulatorRunning) BOOL emulatorRunning;
|
||||||
|
|
||||||
+ (instancetype)sharedInstance;
|
+ (instancetype)sharedInstance;
|
||||||
|
- (void)setMouseX:(NSInteger)x Y:(NSInteger)y;
|
||||||
|
- (void)moveMouseX:(NSInteger)x Y:(NSInteger)y;
|
||||||
|
- (void)setMouseButton:(BOOL)down;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
#include "MYOSGLUE.h"
|
#include "MYOSGLUE.h"
|
||||||
|
|
||||||
IMPORTPROC RunEmulator(void);
|
IMPORTPROC RunEmulator(void);
|
||||||
|
IMPORTFUNC blnr GetSpeedStopped(void);
|
||||||
IMPORTPROC SetSpeedStopped(blnr stopped);
|
IMPORTPROC SetSpeedStopped(blnr stopped);
|
||||||
|
IMPORTPROC SetMouseButton(blnr down);
|
||||||
|
IMPORTPROC SetMouseLoc(ui4r h, ui4r v);
|
||||||
|
IMPORTPROC SetMouseDelta(ui4r dh, ui4r dv);
|
||||||
|
|
||||||
static AppDelegate *sharedAppDelegate = nil;
|
static AppDelegate *sharedAppDelegate = nil;
|
||||||
|
|
||||||
|
@ -27,6 +31,7 @@ static AppDelegate *sharedAppDelegate = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
|
sharedAppDelegate = self;
|
||||||
[self performSelector:@selector(runEmulator) withObject:nil afterDelay:1.0];
|
[self performSelector:@selector(runEmulator) withObject:nil afterDelay:1.0];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -39,8 +44,30 @@ static AppDelegate *sharedAppDelegate = nil;
|
||||||
SetSpeedStopped(falseblnr);
|
SetSpeedStopped(falseblnr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Emulation
|
||||||
|
|
||||||
- (void)runEmulator {
|
- (void)runEmulator {
|
||||||
RunEmulator();
|
RunEmulator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEmulatorRunning {
|
||||||
|
return !GetSpeedStopped();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setEmulatorRunning:(BOOL)emulatorRunning {
|
||||||
|
SetSpeedStopped(emulatorRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setMouseX:(NSInteger)x Y:(NSInteger)y {
|
||||||
|
SetMouseLoc(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)moveMouseX:(NSInteger)x Y:(NSInteger)y {
|
||||||
|
SetMouseDelta(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setMouseButton:(BOOL)down {
|
||||||
|
SetMouseButton(down);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
<constraint firstAttribute="trailing" secondItem="70W-4V-tYr" secondAttribute="trailing" id="kDH-sv-91j"/>
|
<constraint firstAttribute="trailing" secondItem="70W-4V-tYr" secondAttribute="trailing" id="kDH-sv-91j"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="screenView" destination="70W-4V-tYr" id="W9r-vA-9kk"/>
|
||||||
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
|
|
|
@ -853,9 +853,16 @@ LOCALFUNC blnr InitLocationDat(void) {
|
||||||
|
|
||||||
#pragma mark - Mouse
|
#pragma mark - Mouse
|
||||||
|
|
||||||
LOCALFUNC blnr MyMoveMouse(si4b h, si4b v) {
|
GLOBALPROC SetMouseButton(blnr down) {
|
||||||
// TODO: move mouse
|
MyMouseButtonSet(down);
|
||||||
return trueblnr;
|
}
|
||||||
|
|
||||||
|
GLOBALPROC SetMouseLoc(ui4r h, ui4r v) {
|
||||||
|
MyMousePositionSet(h, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLOBALPROC SetMouseDelta(ui4r dh, ui4r dv) {
|
||||||
|
MyMousePositionSetDelta(dh, dv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - video out
|
#pragma mark - video out
|
||||||
|
@ -1551,6 +1558,10 @@ LOCALPROC EnterSpeedStopped(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLOBALFUNC blnr GetSpeedStopped(void) {
|
||||||
|
return CurSpeedStopped;
|
||||||
|
}
|
||||||
|
|
||||||
GLOBALPROC SetSpeedStopped(blnr stopped) {
|
GLOBALPROC SetSpeedStopped(blnr stopped) {
|
||||||
CurSpeedStopped = stopped;
|
CurSpeedStopped = stopped;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
@interface ScreenView : UIView
|
@interface ScreenView : UIView
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) CGRect screenBounds;
|
||||||
|
@property (nonatomic, readonly) CGSize screenSize;
|
||||||
|
|
||||||
+ (instancetype)sharedScreenView;
|
+ (instancetype)sharedScreenView;
|
||||||
- (void)updateScreen:(CGImageRef)screenImage;
|
- (void)updateScreen:(CGImageRef)screenImage;
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,27 @@ static ScreenView *sharedScreenView = nil;
|
||||||
{
|
{
|
||||||
CGImageRef screenImage;
|
CGImageRef screenImage;
|
||||||
CGRect screenBounds;
|
CGRect screenBounds;
|
||||||
|
CGSize screenSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)awakeFromNib {
|
- (void)awakeFromNib {
|
||||||
[super awakeFromNib];
|
[super awakeFromNib];
|
||||||
sharedScreenView = self;
|
sharedScreenView = self;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)sharedScreenView {
|
+ (instancetype)sharedScreenView {
|
||||||
return sharedScreenView;
|
return sharedScreenView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (CGRect)screenBounds {
|
||||||
|
return screenBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)screenSize {
|
||||||
|
return screenSize;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateScreen:(CGImageRef)newScreenImage {
|
- (void)updateScreen:(CGImageRef)newScreenImage {
|
||||||
CGImageRelease(screenImage);
|
CGImageRelease(screenImage);
|
||||||
screenImage = CGImageRetain(newScreenImage);
|
screenImage = CGImageRetain(newScreenImage);
|
||||||
|
@ -33,7 +43,7 @@ static ScreenView *sharedScreenView = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)layoutSubviews {
|
- (void)layoutSubviews {
|
||||||
CGSize screenSize = CGSizeMake(vMacScreenWidth, vMacScreenHeight);
|
screenSize = CGSizeMake(vMacScreenWidth, vMacScreenHeight);
|
||||||
CGRect viewBounds = self.bounds;
|
CGRect viewBounds = self.bounds;
|
||||||
CGFloat screenScale = MAX(screenSize.width / viewBounds.size.width, screenSize.height / viewBounds.size.height);
|
CGFloat screenScale = MAX(screenSize.width / viewBounds.size.width, screenSize.height / viewBounds.size.height);
|
||||||
screenBounds = CGRectMake(0, 0, screenSize.width / screenScale, screenSize.height / screenScale);
|
screenBounds = CGRectMake(0, 0, screenSize.width / screenScale, screenSize.height / screenScale);
|
||||||
|
|
13
Mini vMac/TouchScreen.h
Normal file
13
Mini vMac/TouchScreen.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// TouchScreen.h
|
||||||
|
// Mini vMac for iOS
|
||||||
|
//
|
||||||
|
// Created by Jesús A. Álvarez on 18/04/2016.
|
||||||
|
// Copyright © 2016 namedfork. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@interface TouchScreen : UIControl
|
||||||
|
|
||||||
|
@end
|
96
Mini vMac/TouchScreen.m
Normal file
96
Mini vMac/TouchScreen.m
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
//
|
||||||
|
// TouchScreen.m
|
||||||
|
// Mini vMac for iOS
|
||||||
|
//
|
||||||
|
// Created by Jesús A. Álvarez on 18/04/2016.
|
||||||
|
// Copyright © 2016 namedfork. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TouchScreen.h"
|
||||||
|
#import "AppDelegate.h"
|
||||||
|
#import "ScreenView.h"
|
||||||
|
|
||||||
|
@implementation TouchScreen
|
||||||
|
{
|
||||||
|
// when using absolute mouse mode, button events are processed before the position is updated
|
||||||
|
NSTimeInterval mouseButtonDelay;
|
||||||
|
CGPoint previousTouchLoc;
|
||||||
|
NSTimeInterval previousTouchTime;
|
||||||
|
NSTimeInterval touchTimeThreshold;
|
||||||
|
CGFloat touchDistanceThreshold;
|
||||||
|
NSMutableSet *currentTouches;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||||||
|
if ((self = [super initWithFrame:frame])) {
|
||||||
|
mouseButtonDelay = 0.05;
|
||||||
|
touchTimeThreshold = 0.25;
|
||||||
|
touchDistanceThreshold = 16;
|
||||||
|
currentTouches = [NSMutableSet setWithCapacity:4];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (Point)mouseLocForCGPoint:(CGPoint)point {
|
||||||
|
Point mouseLoc;
|
||||||
|
CGRect screenBounds = [ScreenView sharedScreenView].screenBounds;
|
||||||
|
CGSize screenSize = [ScreenView sharedScreenView].screenSize;
|
||||||
|
mouseLoc.h = (point.x - screenBounds.origin.x) * (screenSize.width/screenBounds.size.width);
|
||||||
|
mouseLoc.v = (point.y - screenBounds.origin.y) * (screenSize.height/screenBounds.size.height);
|
||||||
|
return mouseLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseDown {
|
||||||
|
[[AppDelegate sharedInstance] setMouseButton:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseUp {
|
||||||
|
[[AppDelegate sharedInstance] setMouseButton:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGPoint)effectiveTouchPointForEvent:(UIEvent *)event {
|
||||||
|
CGPoint touchLoc = [[event touchesForView:self].anyObject locationInView:self];
|
||||||
|
if (event.timestamp - previousTouchTime < touchTimeThreshold &&
|
||||||
|
fabs(previousTouchLoc.x - touchLoc.x) < touchDistanceThreshold &&
|
||||||
|
fabs(previousTouchLoc.y - touchLoc.y) < touchDistanceThreshold)
|
||||||
|
return previousTouchLoc;
|
||||||
|
previousTouchLoc = touchLoc;
|
||||||
|
previousTouchTime = event.timestamp;
|
||||||
|
return touchLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
|
[currentTouches unionSet:touches];
|
||||||
|
if (![AppDelegate sharedInstance].emulatorRunning) return;
|
||||||
|
CGPoint touchLoc = [self effectiveTouchPointForEvent:event];
|
||||||
|
Point mouseLoc = [self mouseLocForCGPoint:touchLoc];
|
||||||
|
[[AppDelegate sharedInstance] setMouseX:mouseLoc.h Y:mouseLoc.v];
|
||||||
|
[self performSelector:@selector(mouseDown) withObject:nil afterDelay:mouseButtonDelay];
|
||||||
|
previousTouchLoc = touchLoc;
|
||||||
|
previousTouchTime = event.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
|
if (![AppDelegate sharedInstance].emulatorRunning) return;
|
||||||
|
CGPoint touchLoc = [self effectiveTouchPointForEvent:event];
|
||||||
|
Point mouseLoc = [self mouseLocForCGPoint:touchLoc];
|
||||||
|
[[AppDelegate sharedInstance] setMouseX:mouseLoc.h Y:mouseLoc.v];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
|
[currentTouches minusSet:touches];
|
||||||
|
if (![AppDelegate sharedInstance].emulatorRunning) return;
|
||||||
|
if (currentTouches.count > 0) return;
|
||||||
|
CGPoint touchLoc = [self effectiveTouchPointForEvent:event];
|
||||||
|
Point mouseLoc = [self mouseLocForCGPoint:touchLoc];
|
||||||
|
[[AppDelegate sharedInstance] setMouseX:mouseLoc.h Y:mouseLoc.v];
|
||||||
|
[self performSelector:@selector(mouseUp) withObject:nil afterDelay:mouseButtonDelay];
|
||||||
|
previousTouchLoc = touchLoc;
|
||||||
|
previousTouchTime = event.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
|
[self touchesEnded:touches withEvent:event];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -7,9 +7,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "ScreenView.h"
|
||||||
|
|
||||||
@interface ViewController : UIViewController
|
@interface ViewController : UIViewController
|
||||||
|
|
||||||
|
@property (weak, nonatomic) IBOutlet ScreenView *screenView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,34 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "ViewController.h"
|
#import "ViewController.h"
|
||||||
|
#import "TouchScreen.h"
|
||||||
|
|
||||||
@interface ViewController ()
|
@interface ViewController ()
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ViewController
|
@implementation ViewController
|
||||||
|
{
|
||||||
|
UIControl *pointingDeviceView;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)prefersStatusBarHidden {
|
- (BOOL)prefersStatusBarHidden {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
|
[super viewDidAppear:animated];
|
||||||
|
[self setUpPointingDevice];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setUpPointingDevice {
|
||||||
|
if (pointingDeviceView) {
|
||||||
|
[pointingDeviceView removeFromSuperview];
|
||||||
|
pointingDeviceView = nil;
|
||||||
|
}
|
||||||
|
pointingDeviceView = [[TouchScreen alloc] initWithFrame:self.view.bounds];
|
||||||
|
pointingDeviceView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
|
[self.view insertSubview:pointingDeviceView aboveSubview:self.screenView];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user