mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-18 14:41:14 +00:00
Avoid blocking the main thread when delaying for button presses
This commit is contained in:
@@ -180,6 +180,9 @@
|
|||||||
if (controller != NULL) {
|
if (controller != NULL) {
|
||||||
controller.controllerPausedHandler = ^(GCController *controller) {
|
controller.controllerPausedHandler = ^(GCController *controller) {
|
||||||
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
||||||
|
|
||||||
|
// Get off the main thread
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
[self setButtonFlag:limeController flags:PLAY_FLAG];
|
[self setButtonFlag:limeController flags:PLAY_FLAG];
|
||||||
[self updateFinished:limeController];
|
[self updateFinished:limeController];
|
||||||
|
|
||||||
@@ -188,6 +191,7 @@
|
|||||||
|
|
||||||
[self clearButtonFlag:limeController flags:PLAY_FLAG];
|
[self clearButtonFlag:limeController flags:PLAY_FLAG];
|
||||||
[self updateFinished:limeController];
|
[self updateFinished:limeController];
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (controller.extendedGamepad != NULL) {
|
if (controller.extendedGamepad != NULL) {
|
||||||
|
|||||||
@@ -132,6 +132,7 @@
|
|||||||
}
|
}
|
||||||
else if (!touchMoved) {
|
else if (!touchMoved) {
|
||||||
if ([[event allTouches] count] == 2) {
|
if ([[event allTouches] count] == 2) {
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
Log(LOG_D, @"Sending right mouse button press");
|
Log(LOG_D, @"Sending right mouse button press");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||||
@@ -140,8 +141,10 @@
|
|||||||
usleep(100 * 1000);
|
usleep(100 * 1000);
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!isDragging){
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
|
if (!self->isDragging){
|
||||||
Log(LOG_D, @"Sending left mouse button press");
|
Log(LOG_D, @"Sending left mouse button press");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
@@ -149,8 +152,9 @@
|
|||||||
// Wait 100 ms to simulate a real button press
|
// Wait 100 ms to simulate a real button press
|
||||||
usleep(100 * 1000);
|
usleep(100 * 1000);
|
||||||
}
|
}
|
||||||
isDragging = false;
|
self->isDragging = false;
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user