Skip to content

Commit

Permalink
boundaries check for mouse buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmanLP committed Dec 28, 2024
1 parent ee8e124 commit b1b3453
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/graphic/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ static void onkeyup(WPARAM w_param, LPARAM l_param) {
}

static void on_mouse_button_down(int btn) {
// TODO: maybe check boundaries
if (!(btn >= 0 && btn < 5)) {
return;
}
dxgi.mouse_pressed[btn] = true;
if (dxgi.on_mouse_button_down != nullptr) {
dxgi.on_mouse_button_down(btn);
Expand Down
4 changes: 3 additions & 1 deletion src/graphic/Fast3D/gfx_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ static void gfx_sdl_onkeyup(int scancode) {
}

static void gfx_sdl_on_mouse_button_down(int btn) {
// TODO: maybe check for boundaries? >= 0 & < 5
if (!(btn >= 0 && btn < LUS_MOUSE_BTN_COUNT)) {
return;
}
if (on_mouse_button_down_callback != NULL) {
on_mouse_button_down_callback(btn);
}
Expand Down

0 comments on commit b1b3453

Please sign in to comment.