mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(GLX) Implement mouse wheel up/down for GLX context driver
This commit is contained in:
parent
dd0d81eba8
commit
74332fbd14
@ -25,7 +25,6 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
|
||||
static int (*g_pglSwapInterval)(int);
|
||||
static void (*g_pglSwapIntervalEXT)(Display*, GLXDrawable, int);
|
||||
|
||||
@ -113,6 +112,8 @@ static void gfx_ctx_glx_swap_interval(void *data, unsigned interval)
|
||||
}
|
||||
}
|
||||
|
||||
void x_input_poll_wheel(void *data, XButtonEvent *event, bool latch);
|
||||
|
||||
static void gfx_ctx_glx_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
||||
{
|
||||
@ -160,6 +161,7 @@ static void gfx_ctx_glx_check_window(void *data, bool *quit,
|
||||
glx->g_has_focus = false;
|
||||
break;
|
||||
case ButtonPress:
|
||||
x_input_poll_wheel(driver.input_data, &event.xbutton, true);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
break;
|
||||
|
@ -132,9 +132,17 @@ static int16_t x_mouse_state(x11_input_t *x11, unsigned id)
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
return x11->mouse_r;
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||
return x11->mouse_wu;
|
||||
{
|
||||
int16_t ret = x11->mouse_wu;
|
||||
x11->mouse_wu = 0;
|
||||
return ret;
|
||||
}
|
||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||
return x11->mouse_wd;
|
||||
{
|
||||
int16_t ret = x11->mouse_wd;
|
||||
x11->mouse_wd = 0;
|
||||
return ret;
|
||||
}
|
||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||
return x11->mouse_m;
|
||||
default:
|
||||
@ -277,8 +285,6 @@ static void x_input_poll_mouse(x11_input_t *x11)
|
||||
x11->mouse_l = mask & Button1Mask;
|
||||
x11->mouse_m = mask & Button2Mask;
|
||||
x11->mouse_r = mask & Button3Mask;
|
||||
x11->mouse_wu = mask & Button4Mask;
|
||||
x11->mouse_wd = mask & Button5Mask;
|
||||
|
||||
/* Somewhat hacky, but seem to do the job. */
|
||||
if (x11->grab_mouse && driver.video->focus(driver.video_data))
|
||||
@ -301,6 +307,24 @@ static void x_input_poll_mouse(x11_input_t *x11)
|
||||
}
|
||||
}
|
||||
|
||||
void x_input_poll_wheel(void *data, XButtonEvent *event, bool latch)
|
||||
{
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
|
||||
if (!x11)
|
||||
return;
|
||||
|
||||
switch (event->button)
|
||||
{
|
||||
case 4:
|
||||
x11->mouse_wu = 1;
|
||||
break;
|
||||
case 5:
|
||||
x11->mouse_wd = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void x_input_poll(void *data)
|
||||
{
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
|
@ -578,6 +578,10 @@ static int mouse_iterate(unsigned *action)
|
||||
wheel_is_down = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN);
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("wheel up: %d, wheel down: %d\n", wheel_is_up, wheel_is_down);
|
||||
#endif
|
||||
|
||||
menu->mouse.dx = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||
menu->mouse.dy = driver.input->input_state(driver.input_data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user