Skip to content

Commit 4412375

Browse files
committed
Fixed right and center (wheel) mouse buttons chaos
Sometimes right was recognized as center buttor and vice versa
1 parent 9a8eccb commit 4412375

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/xrGame/Level_input.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ void CLevel::IR_OnMouseWheel(int x, int y)
7171
}
7272
}
7373

74-
static int mouse_button_2_key[] = {SDL_NUM_SCANCODES, MOUSE_1, MOUSE_2, MOUSE_3};
75-
76-
void CLevel::IR_OnMousePress(int btn) {IR_OnKeyboardPress(mouse_button_2_key[btn]); }
77-
void CLevel::IR_OnMouseRelease(int btn) {IR_OnKeyboardRelease(mouse_button_2_key[btn]); }
78-
void CLevel::IR_OnMouseHold(int btn) {IR_OnKeyboardHold(mouse_button_2_key[btn]); }
74+
void CLevel::IR_OnMousePress(int btn) {IR_OnKeyboardPress(MouseButtonToKey[btn]); }
75+
void CLevel::IR_OnMouseRelease(int btn) {IR_OnKeyboardRelease(MouseButtonToKey[btn]); }
76+
void CLevel::IR_OnMouseHold(int btn) {IR_OnKeyboardHold(MouseButtonToKey[btn]); }
7977
void CLevel::IR_OnMouseMove(int dx, int dy)
8078
{
8179
if (g_bDisableAllInput)

src/xrGame/MainMenu.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,29 +302,28 @@ bool CMainMenu::IsActive() { return !!m_Flags.test(flActive); }
302302
bool CMainMenu::CanSkipSceneRendering() { return IsActive() && !m_Flags.test(flGameSaveScreenshot); }
303303

304304
// IInputReceiver
305-
static int mouse_button_2_key[] = { MOUSE_1, MOUSE_2, MOUSE_3, MOUSE_4, MOUSE_5, MOUSE_6, MOUSE_7, MOUSE_8 };
306305
void CMainMenu::IR_OnMousePress(int btn)
307306
{
308307
if (!IsActive())
309308
return;
310309

311-
IR_OnKeyboardPress(mouse_button_2_key[btn]);
310+
IR_OnKeyboardPress(MouseButtonToKey[btn]);
312311
};
313312

314313
void CMainMenu::IR_OnMouseRelease(int btn)
315314
{
316315
if (!IsActive())
317316
return;
318317

319-
IR_OnKeyboardRelease(mouse_button_2_key[btn]);
318+
IR_OnKeyboardRelease(MouseButtonToKey[btn]);
320319
};
321320

322321
void CMainMenu::IR_OnMouseHold(int btn)
323322
{
324323
if (!IsActive())
325324
return;
326325

327-
IR_OnKeyboardHold(mouse_button_2_key[btn]);
326+
IR_OnKeyboardHold(MouseButtonToKey[btn]);
328327
};
329328

330329
void CMainMenu::IR_OnMouseMove(int x, int y)

src/xrGame/UIDialogHolder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool CDialogHolder::IR_UIOnKeyboardPress(SDL_Scancode dik)
251251
{
252252
Fvector2 cp = GetUICursor().GetCursorPosition();
253253
EUIMessages action =
254-
(dik == MOUSE_1) ? WINDOW_LBUTTON_DOWN : (dik == MOUSE_2) ? WINDOW_CBUTTON_DOWN : WINDOW_RBUTTON_DOWN;
254+
(dik == MOUSE_1) ? WINDOW_LBUTTON_DOWN : (dik == MOUSE_2) ? WINDOW_RBUTTON_DOWN : WINDOW_CBUTTON_DOWN;
255255
if (TIR->OnMouseAction(cp.x, cp.y, action))
256256
return true;
257257
}

src/xrGame/xr_level_controller.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,5 @@ extern ConsoleBindCmds bindConsoleCmds;
172172
#define MOUSE_6 (SDL_NUM_SCANCODES + 6)
173173
#define MOUSE_7 (SDL_NUM_SCANCODES + 7)
174174
#define MOUSE_8 (SDL_NUM_SCANCODES + 8)
175+
176+
constexpr int MouseButtonToKey[] = { MOUSE_1, MOUSE_3, MOUSE_2, MOUSE_4, MOUSE_5, MOUSE_6, MOUSE_7, MOUSE_8 };

0 commit comments

Comments
 (0)