Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit 6f25f44

Browse files
committed
fix Y axis overflow
1 parent 86cb2c9 commit 6f25f44

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/JoystickControl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ BOOL JoystickControl::get_position(HWND hwnd, int* x, int* y)
327327
}
328328
if (y)
329329
{
330-
*y = (int)std::round(remap(ctx->y, 1.0, -1.0, -127, 128));
330+
*y = (int)std::round(remap(ctx->y, 1.0, -1.0, -128, 127));
331331
}
332332

333333
return TRUE;
@@ -338,7 +338,7 @@ BOOL JoystickControl::set_position(HWND hwnd, int x, int y)
338338
WITH_VALID_CTX()
339339

340340
ctx->x = remap(x, -128, 127, -1.0, 1.0);
341-
ctx->y = -remap(y, -127, 128, -1.0, 1.0);
341+
ctx->y = -remap(y, -128, 127, -1.0, 1.0);
342342

343343
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE);
344344
SendMessage(GetParent(hwnd), WM_JOYSTICK_POSITION_CHANGED, 1, 0);

src/TASInput.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ INT_PTR CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
586586
int x{}, y{};
587587
JoystickControl::get_position(ctx->joy_hwnd, &x, &y);
588588

589-
ctx->current_input.x = x;
590-
ctx->current_input.y = y;
591-
589+
ctx->current_input.x = (int8_t)x;
590+
ctx->current_input.y = (int8_t)y;
591+
592592
if (!wparam)
593593
{
594594
ctx->set_visuals(ctx->current_input);
@@ -890,7 +890,7 @@ INT_PTR CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
890890
case IDC_Y_UP:
891891
{
892892
int increment = get_joystick_increment(LOWORD(wparam) == IDC_Y_UP);
893-
ctx->current_input.y = wrapping_clamp(ctx->current_input.y + increment, -127, 128);
893+
ctx->current_input.y = wrapping_clamp(ctx->current_input.y + increment, -128, 127);
894894
ctx->set_visuals(ctx->current_input);
895895
}
896896
break;

0 commit comments

Comments
 (0)