Skip to content

Commit

Permalink
Merge pull request #29 from RobertDaleSmith/fix-nuon-inverted-analog-y
Browse files Browse the repository at this point in the history
fix(nuon): inverts analog y-axis values correctly for all controller types
  • Loading branch information
RobertDaleSmith authored Jan 30, 2024
2 parents 9604263 + ec50156 commit 795f36d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/console/nuon/nuon.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ void __not_in_flash_func(post_globals)(
}

if (analog_1x) players[player_index].output_analog_1x = analog_1x;
if (analog_1y) players[player_index].output_analog_1y = analog_1y;
if (analog_1y) players[player_index].output_analog_1y = 256 - analog_1y;
if (analog_2x) players[player_index].output_analog_2x = analog_2x;
if (analog_2y) players[player_index].output_analog_2y = analog_2y;
if (analog_2y) players[player_index].output_analog_2y = 256 - analog_2y;
if (quad_x) players[player_index].output_quad_x = quad_x;
update_output();
}
Expand Down
4 changes: 2 additions & 2 deletions src/xinput_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ void tuh_xinput_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t c
#ifdef CONFIG_NUON
float max_thresh = 32768;
float left1X = (128 * (p->sThumbLX / max_thresh)) + ((p->sThumbLX >= 0) ? 127 : 128);
float left1Y = (128 * (-1 * p->sThumbLY / max_thresh)) + ((-1 * p->sThumbLY >= 0) ? 127 : 128);
float left1Y = (128 * (p->sThumbLY / max_thresh)) + ((p->sThumbLY >= 0) ? 127 : 128);
float left2X = (128 * (p->sThumbRX / max_thresh)) + ((p->sThumbRX >= 0) ? 127 : 128);
float left2Y = (128 * (-1 * p->sThumbRY / max_thresh)) + ((-1 * p->sThumbRY >= 0) ? 127 : 128);
float left2Y = (128 * (p->sThumbRY / max_thresh)) + ((p->sThumbRY >= 0) ? 127 : 128);

if (p->sThumbLX == 0) left1X = 127;
if (p->sThumbLY == 0) left1Y = 127;
Expand Down

0 comments on commit 795f36d

Please sign in to comment.