Add parameter to disable gamepad mouse emulation

This commit is contained in:
Cameron Gutman 2021-08-08 12:03:56 -05:00
parent 3611f1dd89
commit 81a49e4564
6 changed files with 18 additions and 5 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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();