don't send ev_joystick and ev_mouse if menu is open (#1460)

This commit is contained in:
Roman Fomin 2024-02-11 16:04:26 +07:00 committed by GitHub
parent f3c4e29e9a
commit f3b9f69ba5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 13 deletions

View File

@ -98,14 +98,31 @@ void I_UpdateJoystick(boolean axis_buttons)
if (axis_buttons)
{
AxisToButtons(&ev);
ev.type = ev_joystick_state;
D_PostEvent(&ev);
}
ev.type = ev_joystick;
D_PostEvent(&ev);
}
void I_UpdateJoystickMenu(void)
{
static event_t ev;
if (controller == NULL)
{
return;
}
ev.data1 = GetAxisState(SDL_CONTROLLER_AXIS_LEFTX);
ev.data2 = GetAxisState(SDL_CONTROLLER_AXIS_LEFTY);
ev.data3 = GetAxisState(SDL_CONTROLLER_AXIS_RIGHTX);
ev.data4 = GetAxisState(SDL_CONTROLLER_AXIS_RIGHTY);
AxisToButtons(&ev);
ev.type = ev_joystick_state;
D_PostEvent(&ev);
}
static void UpdateJoystickButtonState(unsigned int button, boolean on)
{
static event_t event;

View File

@ -26,6 +26,7 @@ void I_CloseController(int which);
double I_AccelerateMouse(int val);
void I_ReadMouse(void);
void I_UpdateJoystick(boolean axis_buttons);
void I_UpdateJoystickMenu(void);
void I_DelayEvent(void);
void I_HandleJoystickEvent(SDL_Event *sdlevent);

View File

@ -196,7 +196,15 @@ void I_ShowMouseCursor(boolean on)
state = on;
}
SDL_ShowCursor(on ? SDL_ENABLE : SDL_DISABLE);
if (on)
{
SDL_ShowCursor(SDL_ENABLE);
}
else
{
SDL_ShowCursor(SDL_DISABLE);
SDL_GetRelativeMouseState(NULL, NULL);
}
}
// [FG] window event handling from Chocolate Doom 3.0
@ -458,18 +466,13 @@ void I_StartTic (void)
{
I_GetEvent();
if (window_focused)
{
I_ReadMouse();
}
if (I_UseController())
{
I_UpdateJoystick(true);
}
if (menuactive)
{
if (I_UseController())
{
I_UpdateJoystickMenu();
}
static event_t ev;
static int oldx, oldy;
static SDL_Rect old_rect;
@ -515,6 +518,17 @@ void I_StartTic (void)
ev.data3 = y;
D_PostEvent(&ev);
return;
}
if (window_focused)
{
I_ReadMouse();
}
if (I_UseController())
{
I_UpdateJoystick(true);
}
}