diff --git a/Limelight/Input/ControllerSupport.m b/Limelight/Input/ControllerSupport.m index 8acda13..fcd74ba 100644 --- a/Limelight/Input/ControllerSupport.m +++ b/Limelight/Input/ControllerSupport.m @@ -180,14 +180,18 @@ if (controller != NULL) { controller.controllerPausedHandler = ^(GCController *controller) { Controller* limeController = [self->_controllers objectForKey:[NSNumber numberWithInteger:controller.playerIndex]]; - [self setButtonFlag:limeController flags:PLAY_FLAG]; - [self updateFinished:limeController]; - // Pause for 100 ms - usleep(100 * 1000); - - [self clearButtonFlag:limeController flags:PLAY_FLAG]; - [self updateFinished:limeController]; + // Get off the main thread + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + [self setButtonFlag:limeController flags:PLAY_FLAG]; + [self updateFinished:limeController]; + + // Pause for 100 ms + usleep(100 * 1000); + + [self clearButtonFlag:limeController flags:PLAY_FLAG]; + [self updateFinished:limeController]; + }); }; if (controller.extendedGamepad != NULL) { diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index d12a95b..fc35c58 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -132,25 +132,29 @@ } else if (!touchMoved) { if ([[event allTouches] count] == 2) { - Log(LOG_D, @"Sending right mouse button press"); - - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); - - // Wait 100 ms to simulate a real button press - usleep(100 * 1000); - - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); - } else { - if (!isDragging){ - Log(LOG_D, @"Sending left mouse button press"); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + Log(LOG_D, @"Sending right mouse button press"); - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); // 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_RIGHT); + }); + } else { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + if (!self->isDragging){ + Log(LOG_D, @"Sending left mouse button press"); + + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); + + // Wait 100 ms to simulate a real button press + usleep(100 * 1000); + } + self->isDragging = false; + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); + }); } }