From 778082077cc03f64b60f5dd48bb505973c28ac8f Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 3 Jan 2024 04:05:34 +0100 Subject: [PATCH] controller over bluetooth settings parameter added --- allynone.c | 1 + config.cfg.default | 3 ++- dev_out.c | 4 ++-- settings.c | 7 +++++++ settings.h | 1 + stray_ally.c | 1 + 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/allynone.c b/allynone.c index ba343d1..218d089 100644 --- a/allynone.c +++ b/allynone.c @@ -31,6 +31,7 @@ int main(int argc, char ** argv) { .nintendo_layout = false, .gamepad_leds_control = true, .gamepad_rumble_control = true, + .controller_bluetooth = false, }; load_out_config(&out_settings, configuration_file); diff --git a/config.cfg.default b/config.cfg.default index 2297cb6..2049acd 100644 --- a/config.cfg.default +++ b/config.cfg.default @@ -5,4 +5,5 @@ default_gamepad = 1; rumble_on_mode_switch = true; gamepad_rumble_control = true; gamepad_leds_control = true; -m1m2_mode = 1; \ No newline at end of file +m1m2_mode = 1; +controller_bluetooth = false; \ No newline at end of file diff --git a/dev_out.c b/dev_out.c index 721737c..c5fd3a1 100644 --- a/dev_out.c +++ b/dev_out.c @@ -434,7 +434,7 @@ void *dev_out_thread_func(void *ptr) { const int64_t gamepad_report_timing_us = 1250; if (current_gamepad == GAMEPAD_DUALSENSE) { - const int ds5_init_res = virt_dualsense_init(&controller_data.ds5, true); + const int ds5_init_res = virt_dualsense_init(&controller_data.ds5, dev_out_data->settings.controller_bluetooth); if (ds5_init_res != 0) { fprintf(stderr, "Unable to initialize the DualSense device: %d\n", ds5_init_res); } else { @@ -442,7 +442,7 @@ void *dev_out_thread_func(void *ptr) { printf("DualSense initialized: fd=%d\n", current_gamepad_fd); } } else if (current_gamepad == GAMEPAD_DUALSHOCK) { - const int ds4_init_res = virt_dualshock_init(&controller_data.ds4, false); + const int ds4_init_res = virt_dualshock_init(&controller_data.ds4, dev_out_data->settings.controller_bluetooth); if (ds4_init_res != 0) { fprintf(stderr, "Unable to initialize the DualShock device: %d\n", ds4_init_res); } else { diff --git a/settings.c b/settings.c index 7efab3c..15f0c7b 100644 --- a/settings.c +++ b/settings.c @@ -99,6 +99,13 @@ void load_out_config(dev_out_settings_t *const out_conf, const char* const filep fprintf(stderr, "gamepad_rumble_control (bool) configuration not found. Default value will be used.\n"); } + int controller_bluetooth; + if (config_lookup_bool(&cfg, "controller_bluetooth", &controller_bluetooth) != CONFIG_FALSE) { + out_conf->controller_bluetooth = controller_bluetooth; + } else { + fprintf(stderr, "controller_bluetooth (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 4ab4f63..8a9af80 100644 --- a/settings.h +++ b/settings.h @@ -17,6 +17,7 @@ typedef struct dev_out_settings { uint8_t default_gamepad; bool gamepad_leds_control; bool gamepad_rumble_control; + bool controller_bluetooth; } 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 0af98a3..bf395db 100644 --- a/stray_ally.c +++ b/stray_ally.c @@ -17,6 +17,7 @@ int main(int argc, char ** argv) { .nintendo_layout = false, .gamepad_leds_control = true, .gamepad_rumble_control = true, + .controller_bluetooth = false, }; load_out_config(&out_settings, configuration_file);