mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-23 16:57:02 +00:00
@@ -17,6 +17,9 @@
|
|||||||
BOOL touchMoved;
|
BOOL touchMoved;
|
||||||
OnScreenControls* onScreenControls;
|
OnScreenControls* onScreenControls;
|
||||||
|
|
||||||
|
BOOL isDragging;
|
||||||
|
NSTimer* dragTimer;
|
||||||
|
|
||||||
float xDeltaFactor;
|
float xDeltaFactor;
|
||||||
float yDeltaFactor;
|
float yDeltaFactor;
|
||||||
float screenFactor;
|
float screenFactor;
|
||||||
@@ -49,11 +52,27 @@
|
|||||||
UITouch *touch = [[event allTouches] anyObject];
|
UITouch *touch = [[event allTouches] anyObject];
|
||||||
touchLocation = [touch locationInView:self];
|
touchLocation = [touch locationInView:self];
|
||||||
touchMoved = false;
|
touchMoved = false;
|
||||||
|
if ([[event allTouches] count] == 1 && !isDragging) {
|
||||||
|
dragTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
|
||||||
|
target:self
|
||||||
|
selector:@selector(onDragStart:)
|
||||||
|
userInfo:nil
|
||||||
|
repeats:NO];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)onDragStart:(NSTimer*)timer {
|
||||||
|
if (!touchMoved && !isDragging){
|
||||||
|
isDragging = true;
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
if (![onScreenControls handleTouchMovedEvent:touches]) {
|
if (![onScreenControls handleTouchMovedEvent:touches]) {
|
||||||
|
[dragTimer invalidate];
|
||||||
|
dragTimer = nil;
|
||||||
if ([[event allTouches] count] == 1) {
|
if ([[event allTouches] count] == 1) {
|
||||||
UITouch *touch = [[event allTouches] anyObject];
|
UITouch *touch = [[event allTouches] anyObject];
|
||||||
CGPoint currentLocation = [touch locationInView:self];
|
CGPoint currentLocation = [touch locationInView:self];
|
||||||
@@ -91,6 +110,8 @@
|
|||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
Log(LOG_D, @"Touch up");
|
Log(LOG_D, @"Touch up");
|
||||||
if (![onScreenControls handleTouchUpEvent:touches]) {
|
if (![onScreenControls handleTouchUpEvent:touches]) {
|
||||||
|
[dragTimer invalidate];
|
||||||
|
dragTimer = nil;
|
||||||
if (!touchMoved) {
|
if (!touchMoved) {
|
||||||
if ([[event allTouches] count] == 2) {
|
if ([[event allTouches] count] == 2) {
|
||||||
Log(LOG_D, @"Sending right mouse button press");
|
Log(LOG_D, @"Sending right mouse button press");
|
||||||
@@ -104,13 +125,15 @@
|
|||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log(LOG_D, @"Sending left mouse button press");
|
if (!isDragging){
|
||||||
|
Log(LOG_D, @"Sending left mouse button press");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
|
||||||
// Wait 100 ms to simulate a real button press
|
|
||||||
usleep(100 * 1000);
|
|
||||||
|
|
||||||
|
// Wait 100 ms to simulate a real button press
|
||||||
|
usleep(100 * 1000);
|
||||||
|
}
|
||||||
|
isDragging = false;
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user