From 9aa38f416cf4e5c1d8135833fd3705b45848fee3 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 19 Dec 2023 22:23:19 +0100 Subject: [PATCH 1/4] Change default configuration --- config.cfg.default | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.cfg.default b/config.cfg.default index a6ff041..e9940b9 100644 --- a/config.cfg.default +++ b/config.cfg.default @@ -1,5 +1,5 @@ enable_qam = true; -ff_gain = 100; +ff_gain = 255; nintendo_layout = false; -gamepad_output_device = 1; -rumble_dedicated_thread = false; \ No newline at end of file +default_gamepad = 1; +rumble_on_mode_switch = true; \ No newline at end of file From 646ed984debd260fb54d6c7865e95e38fed4323c Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 19 Dec 2023 22:54:57 +0100 Subject: [PATCH 2/4] wrong if statement --- rogue-enemy_iio_buffer_on.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rogue-enemy_iio_buffer_on.sh b/rogue-enemy_iio_buffer_on.sh index 1f9e7f6..2f71ab5 100644 --- a/rogue-enemy_iio_buffer_on.sh +++ b/rogue-enemy_iio_buffer_on.sh @@ -4,7 +4,7 @@ modprobe iio-trig-sysfs modprobe iio-trig-hrtimer # hrtimer -if [! -d "/home/config"]; then +if [ ! -d "/home/config" ]; then mkdir -p /home/config fi From 566d89df296d6eeb2ce5cb5ac8db26f9251d80c9 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 20 Dec 2023 14:35:46 +0100 Subject: [PATCH 3/4] 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, } }; From 628e803834d5d97ea789b58ccc147279bdb5e5ff Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 20 Dec 2023 15:32:43 +0100 Subject: [PATCH 4/4] better imu startup --- rogue-enemy_iio_buffer_on.sh | 57 +++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/rogue-enemy_iio_buffer_on.sh b/rogue-enemy_iio_buffer_on.sh index 2f71ab5..bc64b9a 100644 --- a/rogue-enemy_iio_buffer_on.sh +++ b/rogue-enemy_iio_buffer_on.sh @@ -11,13 +11,50 @@ fi mount -t configfs none /home/config mkdir -p /home/config/iio/triggers/hrtimer/rogue -cd /sys/bus/iio/devices/iio\:device0 -echo 1 > scan_elements/in_accel_x_en -echo 1 > scan_elements/in_accel_y_en -echo 1 > scan_elements/in_accel_z_en -echo 1 > scan_elements/in_anglvel_x_en -echo 1 > scan_elements/in_anglvel_y_en -echo 1 > scan_elements/in_anglvel_z_en -echo 1 > scan_elements/in_timestamp_en -echo "rogue" > trigger/current_trigger -echo 1 > buffer0/enable \ No newline at end of file +# set sampling frequency for rogue +for i in /sys/bus/iio/devices/* ; do + if [ -d "$i" ]; then + if [ -f "$i/name" ]; then + name=$(cat "$i/name") + if [ "$name" = "rogue" ]; then + echo "800" > "$i/sampling_frequency" + fi + fi + fi +done + +# set the gyroscope +for i in /sys/bus/iio/devices/* ; do + if [ -d "$i" ]; then + if [ -f "$i/name" ]; then + name=$(cat "$i/name") + if [ "$name" = "bmi323-imu" ]; then + + # change chip sampling frequency + echo "800.000000" > "$i/in_accel_sampling_frequency" + echo "800.000000" > "$i/in_anglvel_sampling_frequency" + + # enable accel data acquisition + echo 1 > "$i/scan_elements/in_accel_x_en" + echo 1 > "$i/scan_elements/in_accel_y_en" + echo 1 > "$i/scan_elements/in_accel_z_en" + + # enable gyroscope data acquisition + echo 1 > "$i/scan_elements/in_anglvel_x_en" + echo 1 > "$i/scan_elements/in_anglvel_y_en" + echo 1 > "$i/scan_elements/in_anglvel_z_en" + + # enable timestamp reporting + echo 1 > "$i/scan_elements/in_timestamp_en" + + # bind rogue hrtimer to to the iio device + echo "rogue" > "$i/trigger/current_trigger" + + # enable the buffer + echo 1 > "$i/buffer0/enable" + + echo "bmi323-imu buffer started" + fi + fi + fi +done