From cdca4c1b3a3453509af32d20edac1a6eefb4be9a Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Sun, 11 Jun 2017 18:32:46 +0200 Subject: [PATCH] Add button combination to quit streaming for gamepads --- docs/README.pod | 2 +- src/input/evdev.c | 4 ++++ src/input/sdl.c | 4 ++++ src/main.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/README.pod b/docs/README.pod index 3fbd621..7a6ccc3 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -181,7 +181,7 @@ A documented example configuration file can be found at /etc/moonlight/moonlight =head1 COMMENTS -Use Ctrl+Alt+Shift+Q to quit the streaming session. +Use Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to quit the streaming session. =head1 AUTHOR diff --git a/src/input/evdev.c b/src/input/evdev.c index e26fbbd..5f9706c 100644 --- a/src/input/evdev.c +++ b/src/input/evdev.c @@ -91,6 +91,7 @@ static bool grabbingDevices; #define QUIT_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL) #define QUIT_KEY KEY_Q +#define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG) static bool (*handler) (struct input_event*, struct input_device*); @@ -326,6 +327,9 @@ static bool evdev_handle_event(struct input_event *ev, struct input_device *dev) } } + if (gamepadModified && (dev->buttonFlags & QUIT_BUTTONS) == QUIT_BUTTONS) + return false; + dev->gamepadModified |= gamepadModified; return true; } diff --git a/src/input/sdl.c b/src/input/sdl.c index 950af43..b0ae29c 100644 --- a/src/input/sdl.c +++ b/src/input/sdl.c @@ -24,6 +24,7 @@ #define ACTION_MODIFIERS (MODIFIER_SHIFT|MODIFIER_ALT|MODIFIER_CTRL) #define QUIT_KEY SDLK_q +#define QUIT_BUTTONS (PLAY_FLAG|BACK_FLAG|LB_FLAG|RB_FLAG) #define FULLSCREEN_KEY SDLK_f typedef struct _GAMEPAD_STATE { @@ -232,6 +233,9 @@ int sdlinput_handle_event(SDL_Event* event) { else gamepad->buttons &= ~button; + if ((gamepad->buttons & QUIT_BUTTONS) == QUIT_BUTTONS) + return SDL_QUIT_APPLICATION; + LiSendMultiControllerEvent(gamepad->id, activeGamepadMask, gamepad->buttons, gamepad->leftTrigger, gamepad->rightTrigger, gamepad->leftStickX, gamepad->leftStickY, gamepad->rightStickX, gamepad->rightStickY); break; } diff --git a/src/main.c b/src/main.c index e565280..ebfdfe9 100644 --- a/src/main.c +++ b/src/main.c @@ -171,7 +171,7 @@ static void help() { printf("\t-input \t\tUse as input. Can be used multiple times\n"); printf("\t-audio \t\tUse as audio output device\n"); #endif - printf("\nUse Ctrl+Alt+Shift+Q to exit streaming session\n\n"); + printf("\nUse Ctrl+Alt+Shift+Q or Play+Back+LeftShoulder+RightShoulder to exit streaming session\n\n"); exit(0); }