mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
sdl2: Fix mouse button input
This commit is contained in:
parent
d298aa8e0d
commit
be96974742
1 changed files with 69 additions and 38 deletions
|
@ -851,6 +851,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
(evt.y > (realheight/2)+(realheight/4) ) )
|
(evt.y > (realheight/2)+(realheight/4) ) )
|
||||||
{
|
{
|
||||||
//if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok)
|
//if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok)
|
||||||
|
SDL_SetWindowGrab(window, mousegrabok);
|
||||||
HalfWarpMouse(realwidth, realheight);
|
HalfWarpMouse(realwidth, realheight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,30 +860,61 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
|
||||||
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event;
|
||||||
|
|
||||||
|
SDL_memset(&event, 0, sizeof(event_t));
|
||||||
|
|
||||||
/// \todo inputEvent.button.which
|
/// \todo inputEvent.button.which
|
||||||
if (USE_MOUSEINPUT)
|
if (USE_MOUSEINPUT)
|
||||||
{
|
{
|
||||||
if (type == SDL_MOUSEBUTTONUP)
|
if (type == SDL_MOUSEBUTTONUP)
|
||||||
event.type = ev_keyup;
|
|
||||||
else if (type == SDL_MOUSEBUTTONDOWN)
|
|
||||||
event.type = ev_keydown;
|
|
||||||
else return;
|
|
||||||
#if 0
|
|
||||||
if (evt.which == SDL_BUTTON_WHEELUP || evt.which == SDL_BUTTON_WHEELDOWN)
|
|
||||||
{
|
{
|
||||||
if (type == SDL_MOUSEBUTTONUP)
|
event.type = ev_keyup;
|
||||||
event.data1 = 0; //Alam: dumb! this could be a real button with some mice
|
|
||||||
else
|
|
||||||
event.data1 = KEY_MOUSEWHEELUP + evt.which - SDL_BUTTON_WHEELUP;
|
|
||||||
}
|
}
|
||||||
#endif
|
else if (type == SDL_MOUSEBUTTONDOWN)
|
||||||
if (evt.which == SDL_BUTTON_MIDDLE)
|
{
|
||||||
|
event.type = ev_keydown;
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
if (evt.button == SDL_BUTTON_MIDDLE)
|
||||||
event.data1 = KEY_MOUSE1+2;
|
event.data1 = KEY_MOUSE1+2;
|
||||||
else if (evt.which == SDL_BUTTON_RIGHT)
|
else if (evt.button == SDL_BUTTON_RIGHT)
|
||||||
event.data1 = KEY_MOUSE1+1;
|
event.data1 = KEY_MOUSE1+1;
|
||||||
else if (evt.which <= MOUSEBUTTONS)
|
else if (evt.button == SDL_BUTTON_LEFT)
|
||||||
|
event.data1= KEY_MOUSE1;
|
||||||
|
else if (evt.button <= MOUSEBUTTONS)
|
||||||
event.data1 = KEY_MOUSE1 + evt.which - SDL_BUTTON_LEFT;
|
event.data1 = KEY_MOUSE1 + evt.which - SDL_BUTTON_LEFT;
|
||||||
if (event.data1) D_PostEvent(&event);
|
if (event.type == ev_keyup || event.type == ev_keydown)
|
||||||
|
{
|
||||||
|
CONS_Printf("Mouse button %d\n", evt.which);
|
||||||
|
D_PostEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
||||||
|
{
|
||||||
|
event_t event;
|
||||||
|
|
||||||
|
SDL_memset(&event, 0, sizeof(event_t));
|
||||||
|
|
||||||
|
if (evt.y > 0)
|
||||||
|
{
|
||||||
|
event.data1 = KEY_MOUSEWHEELUP;
|
||||||
|
event.type = ev_keydown;
|
||||||
|
}
|
||||||
|
if (evt.y < 0)
|
||||||
|
{
|
||||||
|
event.data1 = KEY_MOUSEWHEELDOWN;
|
||||||
|
event.type = ev_keydown;
|
||||||
|
}
|
||||||
|
if (evt.y == 0)
|
||||||
|
{
|
||||||
|
event.data1 = 0;
|
||||||
|
event.type = ev_keyup;
|
||||||
|
}
|
||||||
|
if (event.type == ev_keyup || event.type == ev_keydown)
|
||||||
|
{
|
||||||
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,30 +929,29 @@ void I_GetEvent(void)
|
||||||
|
|
||||||
while (SDL_PollEvent(&evt))
|
while (SDL_PollEvent(&evt))
|
||||||
{
|
{
|
||||||
if (evt.type == SDL_WINDOWEVENT)
|
switch (evt.type)
|
||||||
{
|
{
|
||||||
|
case SDL_WINDOWEVENT:
|
||||||
Impl_HandleWindowEvent(evt.window);
|
Impl_HandleWindowEvent(evt.window);
|
||||||
}
|
break;
|
||||||
|
case SDL_KEYUP:
|
||||||
if (evt.type == SDL_KEYUP || evt.type == SDL_KEYDOWN)
|
case SDL_KEYDOWN:
|
||||||
{
|
|
||||||
Impl_HandleKeyboardEvent(evt.key, evt.type);
|
Impl_HandleKeyboardEvent(evt.key, evt.type);
|
||||||
}
|
break;
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
if (evt.type == SDL_MOUSEMOTION)
|
|
||||||
{
|
|
||||||
Impl_HandleMouseMotionEvent(evt.motion);
|
Impl_HandleMouseMotionEvent(evt.motion);
|
||||||
}
|
break;
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
if (evt.type == SDL_MOUSEBUTTONUP || evt.type == SDL_MOUSEBUTTONDOWN)
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
{
|
|
||||||
Impl_HandleMouseButtonEvent(evt.button, evt.type);
|
Impl_HandleMouseButtonEvent(evt.button, evt.type);
|
||||||
}
|
break;
|
||||||
|
case SDL_MOUSEWHEEL:
|
||||||
if (evt.type == SDL_QUIT)
|
Impl_HandleMouseWheelEvent(evt.wheel);
|
||||||
{
|
break;
|
||||||
|
case SDL_QUIT:
|
||||||
I_Quit();
|
I_Quit();
|
||||||
M_QuitResponse('y');
|
M_QuitResponse('y');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
|
Loading…
Reference in a new issue