controller over bluetooth settings parameter added

This commit is contained in:
Denis 2024-01-03 04:05:34 +01:00
parent eec5cadf8c
commit 778082077c
No known key found for this signature in database
GPG key ID: DD9B63F805CF5C03
6 changed files with 14 additions and 3 deletions

View file

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

View file

@ -5,4 +5,5 @@ default_gamepad = 1;
rumble_on_mode_switch = true;
gamepad_rumble_control = true;
gamepad_leds_control = true;
m1m2_mode = 1;
m1m2_mode = 1;
controller_bluetooth = false;

View file

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

View file

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

View file

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

View file

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