Compare commits
4 commits
793f9e7e56
...
628e803834
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
628e803834 | ||
|
|
566d89df29 | ||
|
|
646ed984de | ||
|
|
9aa38f416c |
7 changed files with 79 additions and 16 deletions
|
|
@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
enable_qam = true;
|
||||
ff_gain = 100;
|
||||
ff_gain = 255;
|
||||
nintendo_layout = false;
|
||||
gamepad_output_device = 1;
|
||||
rumble_dedicated_thread = false;
|
||||
default_gamepad = 1;
|
||||
rumble_on_mode_switch = true;
|
||||
gamepad_rumble_control = true;
|
||||
gamepad_leds_control = true;
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -4,20 +4,57 @@ modprobe iio-trig-sysfs
|
|||
modprobe iio-trig-hrtimer
|
||||
|
||||
# hrtimer
|
||||
if [! -d "/home/config"]; then
|
||||
if [ ! -d "/home/config" ]; then
|
||||
mkdir -p /home/config
|
||||
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
|
||||
# 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
|
||||
|
|
|
|||
14
settings.c
14
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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue