Skip to content

Commit

Permalink
Add button combination to quit streaming for gamepads
Browse files Browse the repository at this point in the history
  • Loading branch information
irtimmer committed Jun 11, 2017
1 parent cbf31be commit cdca4c1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/README.pod
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/input/evdev.c
Expand Up @@ -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*);

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/input/sdl.c
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Expand Up @@ -171,7 +171,7 @@ static void help() {
printf("\t-input <device>\t\tUse <device> as input. Can be used multiple times\n");
printf("\t-audio <device>\t\tUse <device> 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);
}

Expand Down

0 comments on commit cdca4c1

Please sign in to comment.