diff --git a/docs/README.pod b/docs/README.pod index 48ff6e2..52608b7 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -152,6 +152,10 @@ Send quit app request to remote after quitting session Disable all input processing (view-only mode) +=item B<-nomouseemulation> + +Disable gamepad mouse emulation (activated by long pressing Start button) + =item B<-verbose> Enable verbose output diff --git a/src/config.c b/src/config.c index 30f4a64..f65f236 100644 --- a/src/config.c +++ b/src/config.c @@ -71,6 +71,7 @@ static struct option long_options[] = { {"rotate", required_argument, NULL, '3'}, {"verbose", no_argument, NULL, 'z'}, {"debug", no_argument, NULL, 'Z'}, + {"nomouseemulation", no_argument, NULL, '4'}, {0, 0, 0, 0}, }; @@ -240,6 +241,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { case 'Z': config->debug_level = 2; break; + case '4': + config->mouse_emulation = false; + break; case 1: if (config->action == NULL) config->action = value; @@ -357,6 +361,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->unsupported = true; config->quitappafter = false; config->viewonly = false; + config->mouse_emulation = true; config->rotate = 0; config->codec = CODEC_UNSPECIFIED; @@ -376,7 +381,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { } else { int option_index = 0; int c; - while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:s:tu:v:w:xy", long_options, &option_index)) != -1) { + while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:s:tu:v:w:xy4", long_options, &option_index)) != -1) { parse_argument(c, optarg, config); } } diff --git a/src/config.h b/src/config.h index c56c1db..ed236ce 100644 --- a/src/config.h +++ b/src/config.h @@ -43,6 +43,7 @@ typedef struct _CONFIGURATION { bool unsupported; bool quitappafter; bool viewonly; + bool mouse_emulation; char* inputs[MAX_INPUTS]; int inputsCount; enum codecs codec; diff --git a/src/input/evdev.c b/src/input/evdev.c index 64a34be..7c8d05b 100644 --- a/src/input/evdev.c +++ b/src/input/evdev.c @@ -116,6 +116,7 @@ static short* currentAbs; static bool* currentReverse; static bool grabbingDevices; +static bool mouseEmulationEnabled; static bool waitingToExitOnModifiersUp = false; @@ -422,7 +423,7 @@ static bool evdev_handle_event(struct input_event *ev, struct input_device *dev) } else dev->buttonFlags &= ~gamepadCode; - if (gamepadCode == PLAY_FLAG && ev->value == 0) { + if (mouseEmulationEnabled && gamepadCode == PLAY_FLAG && ev->value == 0) { struct timeval elapsedTime; timersub(&ev->time, &dev->btnDownTime, &elapsedTime); int holdTimeMs = elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000; @@ -982,8 +983,9 @@ void evdev_stop() { evdev_drain(); } -void evdev_init() { +void evdev_init(bool mouse_emulation_enabled) { handler = evdev_handle_event; + mouseEmulationEnabled = mouse_emulation_enabled; } static struct input_device* evdev_get_input_device(unsigned short controller_id) { diff --git a/src/input/evdev.h b/src/input/evdev.h index 5f4761b..1239fb0 100644 --- a/src/input/evdev.h +++ b/src/input/evdev.h @@ -24,7 +24,7 @@ extern int evdev_gamepads; void evdev_create(const char* device, struct mapping* mappings, bool verbose, int rotate); void evdev_loop(); -void evdev_init(); +void evdev_init(bool mouse_emulation_enabled); void evdev_start(); void evdev_stop(); void evdev_map(char* device); diff --git a/src/main.c b/src/main.c index 22aeba5..3c11002 100644 --- a/src/main.c +++ b/src/main.c @@ -209,6 +209,7 @@ static void help() { printf("\t-nounsupported\t\tDon't stream if resolution is not officially supported by the server\n"); printf("\t-quitappafter\t\tSend quit app request to remote after quitting session\n"); printf("\t-viewonly\t\tDisable all input processing (view-only mode)\n"); + printf("\t-nomouseemulation\t\tDisable gamepad mouse emulation support (long pressing Start button)\n"); #if defined(HAVE_SDL) || defined(HAVE_X11) printf("\n WM options (SDL and X11 only)\n\n"); printf("\t-windowed\t\tDisplay screen in a window\n"); @@ -346,7 +347,7 @@ int main(int argc, char* argv[]) { } udev_init(!inputAdded, mappings, config.debug_level > 0, config.rotate); - evdev_init(); + evdev_init(config.mouse_emulation); rumble_handler = evdev_rumble; #ifdef HAVE_LIBCEC cec_init();