(Mouse) Start adding preliminary horizontal mouse wheel up/down

This commit is contained in:
twinaphex 2015-03-12 05:38:37 +01:00
parent ea66f9d79d
commit e366a6eaa2
4 changed files with 44 additions and 9 deletions

View File

@ -99,7 +99,7 @@ struct udev_input
int16_t mouse_x;
int16_t mouse_y;
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd, mouse_whu, mouse_whd;
};
#ifdef HAVE_XKBCOMMON
@ -238,7 +238,13 @@ static void udev_handle_mouse(udev_input_t *udev,
else if (event->value == -1)
udev->mouse_wd = 1;
break;
case REL_HWHEEL:
if (event->value == 1)
udev->mouse_whu = 1;
else if (event->value == -1)
udev->mouse_whd = 1;
break;
break;
default:
break;
}
@ -409,6 +415,7 @@ static void udev_input_poll(void *data)
udev->mouse_x = udev->mouse_y = 0;
udev->mouse_wu = udev->mouse_wd = 0;
udev->mouse_whu = udev->mouse_whd = 0;
while (udev_input_hotplug_available(udev))
udev_input_handle_hotplug(udev);
@ -454,6 +461,10 @@ static int16_t udev_mouse_state(udev_input_t *udev, unsigned id)
return udev->mouse_wu;
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
return udev->mouse_wd;
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
return udev->mouse_whu;
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
return udev->mouse_whd;
}
return 0;

View File

@ -165,13 +165,15 @@ extern "C" {
#define RETRO_DEVICE_ID_ANALOG_Y 1
/* Id values for MOUSE. */
#define RETRO_DEVICE_ID_MOUSE_X 0
#define RETRO_DEVICE_ID_MOUSE_Y 1
#define RETRO_DEVICE_ID_MOUSE_LEFT 2
#define RETRO_DEVICE_ID_MOUSE_RIGHT 3
#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
#define RETRO_DEVICE_ID_MOUSE_X 0
#define RETRO_DEVICE_ID_MOUSE_Y 1
#define RETRO_DEVICE_ID_MOUSE_LEFT 2
#define RETRO_DEVICE_ID_MOUSE_RIGHT 3
#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7
#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8
/* Id values for LIGHTGUN types. */
#define RETRO_DEVICE_ID_LIGHTGUN_X 0

View File

@ -165,6 +165,8 @@ typedef struct
bool oldright;
bool wheelup;
bool wheeldown;
bool hwheelup;
bool hwheeldown;
bool scrollup;
bool scrolldown;
unsigned ptr;

View File

@ -212,6 +212,7 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path,
if (menu->mouse.wheelup)
menu_navigation_decrement(&menu->navigation, 1);
return 0;
}
@ -578,6 +579,20 @@ static int mouse_iterate(unsigned *action)
if (!menu->mouse.enable)
return 0;
if (menu->mouse.hwheeldown)
{
*action = MENU_ACTION_LEFT;
menu->mouse.hwheeldown = false;
return 0;
}
if (menu->mouse.hwheelup)
{
*action = MENU_ACTION_RIGHT;
menu->mouse.hwheelup = false;
return 0;
}
menu->mouse.left = driver.input->input_state(driver.input_data,
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
menu->mouse.right = driver.input->input_state(driver.input_data,
@ -586,6 +601,10 @@ static int mouse_iterate(unsigned *action)
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP);
menu->mouse.wheeldown = driver.input->input_state(driver.input_data,
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN);
menu->mouse.hwheelup = driver.input->input_state(driver.input_data,
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP);
menu->mouse.hwheeldown = driver.input->input_state(driver.input_data,
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN);
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,
@ -608,6 +627,7 @@ static int mouse_iterate(unsigned *action)
if (menu->mouse.dx != 0 || menu->mouse.dy !=0 || menu->mouse.left
|| menu->mouse.wheelup || menu->mouse.wheeldown
|| menu->mouse.hwheelup || menu->mouse.hwheeldown
|| menu->mouse.scrollup || menu->mouse.scrolldown)
g_runloop.frames.video.current.menu.animation.is_active = true;