Skip to content

Commit ede90c5

Browse files
committed
Fixed right and center (wheel) mouse buttons chaos
Sometimes right was recognized as center buttor and vice versa
1 parent 96a90c4 commit ede90c5

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
@@ -300,29 +300,28 @@ bool CMainMenu::IsActive() { return !!m_Flags.test(flActive); }
300300
bool CMainMenu::CanSkipSceneRendering() { return IsActive() && !m_Flags.test(flGameSaveScreenshot); }
301301

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

309-
IR_OnKeyboardPress(mouse_button_2_key[btn]);
308+
IR_OnKeyboardPress(MouseButtonToKey[btn]);
310309
};
311310

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

317-
IR_OnKeyboardRelease(mouse_button_2_key[btn]);
316+
IR_OnKeyboardRelease(MouseButtonToKey[btn]);
318317
};
319318

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

325-
IR_OnKeyboardHold(mouse_button_2_key[btn]);
324+
IR_OnKeyboardHold(MouseButtonToKey[btn]);
326325
};
327326

328327
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)