From 566d89df296d6eeb2ce5cb5ac8db26f9251d80c9 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 20 Dec 2023 14:35:46 +0100 Subject: [PATCH] Allow the user to disable gamepad rumble and leds control --- allynone.c | 2 ++ config.cfg.default | 4 +++- dev_out.c | 8 ++++++-- settings.c | 14 ++++++++++++++ settings.h | 2 ++ stray_ally.c | 2 ++ 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/allynone.c b/allynone.c index fd0e324..8172706 100644 --- a/allynone.c +++ b/allynone.c @@ -110,6 +110,8 @@ int main(int argc, char ** argv) { .settings = { .default_gamepad = 0, .nintendo_layout = false, + .gamepad_leds_control = true, + .gamepad_rumble_control = true, } }; diff --git a/config.cfg.default b/config.cfg.default index e9940b9..a932f9a 100644 --- a/config.cfg.default +++ b/config.cfg.default @@ -2,4 +2,6 @@ enable_qam = true; ff_gain = 255; nintendo_layout = false; default_gamepad = 1; -rumble_on_mode_switch = true; \ No newline at end of file +rumble_on_mode_switch = true; +gamepad_rumble_control = true; +gamepad_leds_control = true; \ No newline at end of file diff --git a/dev_out.c b/dev_out.c index ef4687f..1fb944e 100644 --- a/dev_out.c +++ b/dev_out.c @@ -581,7 +581,9 @@ void *dev_out_thread_func(void *ptr) { } }; - out_msgs[out_msgs_count++] = msg; + if (dev_out_data->settings.gamepad_leds_control) { + out_msgs[out_msgs_count++] = msg; + } } if (current_motors_events_count != prev_motors_events_count) { @@ -595,7 +597,9 @@ void *dev_out_thread_func(void *ptr) { } }; - out_msgs[out_msgs_count++] = msg; + if (dev_out_data->settings.gamepad_rumble_control) { + out_msgs[out_msgs_count++] = msg; + } } // send out game-generated events to sockets diff --git a/settings.c b/settings.c index 609923c..6442215 100644 --- a/settings.c +++ b/settings.c @@ -67,6 +67,20 @@ void load_out_config(dev_out_settings_t *const out_conf, const char* const filep fprintf(stderr, "default_gamepad (int) configuration not found. Default value will be used.\n"); } + int gamepad_leds_control; + if (config_lookup_bool(&cfg, "gamepad_leds_control", &gamepad_leds_control) != CONFIG_FALSE) { + out_conf->gamepad_leds_control = gamepad_leds_control; + } else { + fprintf(stderr, "gamepad_leds_control (bool) configuration not found. Default value will be used.\n"); + } + + int gamepad_rumble_control; + if (config_lookup_bool(&cfg, "gamepad_rumble_control", &gamepad_rumble_control) != CONFIG_FALSE) { + out_conf->gamepad_rumble_control = gamepad_rumble_control; + } else { + fprintf(stderr, "gamepad_rumble_control (bool) configuration not found. Default value will be used.\n"); + } + config_destroy(&cfg); load_out_config_err: diff --git a/settings.h b/settings.h index 6e13d12..3d32878 100644 --- a/settings.h +++ b/settings.h @@ -13,6 +13,8 @@ void load_in_config(dev_in_settings_t *const out_conf, const char* const filepat typedef struct dev_out_settings { bool nintendo_layout; uint8_t default_gamepad; + bool gamepad_leds_control; + bool gamepad_rumble_control; } dev_out_settings_t; void load_out_config(dev_out_settings_t *const out_conf, const char* const filepath); \ No newline at end of file diff --git a/stray_ally.c b/stray_ally.c index 3ab735a..fb165e2 100644 --- a/stray_ally.c +++ b/stray_ally.c @@ -45,6 +45,8 @@ int main(int argc, char ** argv) { .settings = { .default_gamepad = 0, .nintendo_layout = false, + .gamepad_leds_control = true, + .gamepad_rumble_control = true, } };