mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-22 18:30:27 +01:00
Fix mouse wheel for switching weapons
This fixes #32. Strictly follows the Win32 version.
This commit is contained in:
parent
b6d54121a5
commit
4db3022cbd
|
@ -251,6 +251,10 @@ static int _iMouseZ = 0;
|
||||||
static BOOL _bWheelUp = FALSE;
|
static BOOL _bWheelUp = FALSE;
|
||||||
static BOOL _bWheelDn = FALSE;
|
static BOOL _bWheelDn = FALSE;
|
||||||
|
|
||||||
|
// emulate Win32: A single mouse wheel rotation
|
||||||
|
// is +120 (upwards) or -120 (downwards)
|
||||||
|
#define MOUSE_SCROLL_INTERVAL 120
|
||||||
|
|
||||||
CTCriticalSection csInput;
|
CTCriticalSection csInput;
|
||||||
|
|
||||||
// which keys are pressed, as recorded by message interception (by KIDs)
|
// which keys are pressed, as recorded by message interception (by KIDs)
|
||||||
|
@ -319,10 +323,7 @@ static void sdl_event_handler(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
if (event->wheel.y > 0)
|
_iMouseZ += event->wheel.y * MOUSE_SCROLL_INTERVAL;
|
||||||
_abKeysPressed[KID_MOUSEWHEELUP] = TRUE;
|
|
||||||
else if (event->wheel.y < 0)
|
|
||||||
_abKeysPressed[KID_MOUSEWHEELDOWN] = TRUE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
@ -744,10 +745,6 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset this every frame (since we explicitly ignore the button-up events).
|
|
||||||
_abKeysPressed[KID_MOUSEWHEELUP] = FALSE;
|
|
||||||
_abKeysPressed[KID_MOUSEWHEELDOWN] = FALSE;
|
|
||||||
|
|
||||||
// read mouse position
|
// read mouse position
|
||||||
#ifdef USE_MOUSEWARP
|
#ifdef USE_MOUSEWARP
|
||||||
int iMx, iMy;
|
int iMx, iMy;
|
||||||
|
@ -816,17 +813,16 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
// if not pre-scanning
|
// if not pre-scanning
|
||||||
if (!bPreScan) {
|
if (!bPreScan) {
|
||||||
// detect wheel up/down movement
|
// detect wheel up/down movement
|
||||||
_bWheelDn = FALSE;
|
|
||||||
if (_iMouseZ>0) {
|
if (_iMouseZ>0) {
|
||||||
if (_bWheelUp) {
|
if (_bWheelUp) {
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00;
|
||||||
} else {
|
} else {
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF;
|
||||||
_iMouseZ = ClampDn(_iMouseZ-120, 0);
|
_iMouseZ = ClampDn(_iMouseZ-MOUSE_SCROLL_INTERVAL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP];
|
_bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP];
|
||||||
|
@ -835,12 +831,11 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00;
|
||||||
} else {
|
} else {
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF;
|
||||||
_iMouseZ = ClampUp(_iMouseZ+120, 0);
|
_iMouseZ = ClampUp(_iMouseZ+MOUSE_SCROLL_INTERVAL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN];
|
_bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
inp_bLastPrescan = bPreScan;
|
inp_bLastPrescan = bPreScan;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user