Skip to content

Commit

Permalink
Allow inverting x axis
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroReflex committed Jan 15, 2024
1 parent 8c8a488 commit 75c19ea
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions allynone.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ int main(int argc, char ** argv) {
.controller_bluetooth = false,
.dualsense_edge = false,
.swap_y_z = false,
.invert_x = false,
.gyro_to_analog_activation_treshold = 16,
.gyro_to_analog_mapping = 4,
};
Expand Down
1 change: 1 addition & 0 deletions config.cfg.default
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ touchbar = true;
controller_bluetooth = true;
dualsense_edge = false;
swap_y_z = true;
invert_x = false;
enable_thermal_profiles_switching = true;
default_thermal_profile = -1;
enable_leds_commands = true;
Expand Down
4 changes: 2 additions & 2 deletions dev_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ static void handle_incoming_message_gamepad_set(
}
case GAMEPAD_GYROSCOPE: {
inout_gamepad->last_gyro_motion_timestamp_ns = msg_payload->status.gyro.sample_timestamp_ns;
inout_gamepad->raw_gyro[0] = msg_payload->status.gyro.x;
inout_gamepad->raw_gyro[0] = in_settings->invert_x ? (int16_t)(-1) * msg_payload->status.gyro.x : msg_payload->status.gyro.x;
inout_gamepad->raw_gyro[1] = in_settings->swap_y_z ? msg_payload->status.gyro.z : msg_payload->status.gyro.y;
inout_gamepad->raw_gyro[2] = in_settings->swap_y_z ? msg_payload->status.gyro.y : msg_payload->status.gyro.z;
break;
}
case GAMEPAD_ACCELEROMETER: {
inout_gamepad->last_accel_motion_timestamp_ns = msg_payload->status.accel.sample_timestamp_ns;
inout_gamepad->raw_accel[0] = msg_payload->status.accel.x;
inout_gamepad->raw_accel[0] = in_settings->invert_x ? (int16_t)(-1) * msg_payload->status.accel.x : msg_payload->status.accel.x;
inout_gamepad->raw_accel[1] = in_settings->swap_y_z ? msg_payload->status.accel.z : msg_payload->status.accel.y;
inout_gamepad->raw_accel[2] = in_settings->swap_y_z ? msg_payload->status.accel.y : msg_payload->status.accel.z;
break;
Expand Down
7 changes: 7 additions & 0 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ void load_out_config(dev_out_settings_t *const out_conf, const char* const filep
fprintf(stderr, "swap_y_z (bool) configuration not found. Default value will be used.\n");
}

int invert_x;
if (config_lookup_bool(&cfg, "invert_x", &invert_x) != CONFIG_FALSE) {
out_conf->invert_x = invert_x;
} else {
fprintf(stderr, "invert_x (bool) configuration not found. Default value will be used.\n");
}

int gyro_to_analog_activation_treshold;
if (config_lookup_int(&cfg, "gyro_to_analog_activation_treshold", &gyro_to_analog_activation_treshold) != CONFIG_FALSE) {
out_conf->gyro_to_analog_activation_treshold = gyro_to_analog_activation_treshold;
Expand Down
1 change: 1 addition & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef struct dev_out_settings {
bool controller_bluetooth;
bool dualsense_edge;
bool swap_y_z;
bool invert_x;
int gyro_to_analog_activation_treshold;
int gyro_to_analog_mapping;
} dev_out_settings_t;
Expand Down
1 change: 1 addition & 0 deletions stray_ally.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ int main(int argc, char ** argv) {
.controller_bluetooth = false,
.dualsense_edge = false,
.swap_y_z = false,
.invert_x = false,
.gyro_to_analog_activation_treshold = 16,
.gyro_to_analog_mapping = 4,
};
Expand Down

0 comments on commit 75c19ea

Please sign in to comment.