Add mouse wheel up/down support to libretro.h - also add preliminary

support for these buttons to 'some' input driver implementations
This commit is contained in:
twinaphex 2014-04-25 21:35:13 +02:00
parent 3ac1150ebc
commit 771c7e20b7
6 changed files with 41 additions and 20 deletions

View File

@ -51,7 +51,7 @@ struct dinput_input
int mouse_rel_y;
int mouse_x;
int mouse_y;
bool mouse_l, mouse_r, mouse_m;
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
struct pointer_status pointer_head; // dummy head for easier iteration
};
@ -190,6 +190,8 @@ static void dinput_poll(void *data)
di->mouse_l = mouse_state.rgbButtons[0];
di->mouse_r = mouse_state.rgbButtons[1];
di->mouse_m = mouse_state.rgbButtons[2];
di->mouse_wu = mouse_state.rgbButtons[3];
di->mouse_wd = mouse_state.rgbButtons[4];
// No simple way to get absolute coordinates for RETRO_DEVICE_POINTER. Just use Win32 APIs.
POINT point = {0};
@ -279,6 +281,10 @@ static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id)
return di->mouse_l;
case RETRO_DEVICE_ID_MOUSE_RIGHT:
return di->mouse_r;
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
return di->mouse_wu;
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
return di->mouse_wd;
default:
return 0;
}

View File

@ -30,7 +30,7 @@ typedef struct sdl_input
int mouse_x, mouse_y;
int mouse_abs_x, mouse_abs_y;
int mouse_l, mouse_r, mouse_m;
int mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
} sdl_input_t;
static void *sdl_input_init(void)
@ -120,6 +120,10 @@ static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id)
return sdl->mouse_l;
case RETRO_DEVICE_ID_MOUSE_RIGHT:
return sdl->mouse_r;
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
return sdl->mouse_wu;
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
return sdl->mouse_wd;
case RETRO_DEVICE_ID_MOUSE_X:
return sdl->mouse_x;
case RETRO_DEVICE_ID_MOUSE_Y:
@ -248,6 +252,8 @@ static void sdl_poll_mouse(sdl_input_t *sdl)
sdl->mouse_l = SDL_BUTTON(SDL_BUTTON_LEFT) & btn ? 1 : 0;
sdl->mouse_r = SDL_BUTTON(SDL_BUTTON_RIGHT) & btn ? 1 : 0;
sdl->mouse_m = SDL_BUTTON(SDL_BUTTON_MIDDLE) & btn ? 1 : 0;
sdl->mouse_wu = SDL_BUTTON(SDL_BUTTON_WHEELUP) & btn ? 1 : 0;
sdl->mouse_wd = SDL_BUTTON(SDL_BUTTON_WHEELDOWN) & btn ? 1 : 0;
}
static void sdl_input_poll(void *data)

View File

@ -98,7 +98,7 @@ struct udev_input
int16_t mouse_x;
int16_t mouse_y;
bool mouse_l, mouse_r, mouse_m;
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
};
static inline bool get_bit(const uint8_t *buf, unsigned bit)
@ -232,6 +232,7 @@ static void udev_handle_mouse(udev_input_t *udev, const struct input_event *even
switch (event->type)
{
case EV_KEY:
/* TODO: mouse wheel up/down */
switch (event->code)
{
case BTN_LEFT:
@ -245,7 +246,6 @@ static void udev_handle_mouse(udev_input_t *udev, const struct input_event *even
case BTN_MIDDLE:
udev->mouse_m = event->value;
break;
default:
break;
}

View File

@ -34,7 +34,7 @@ typedef struct x11_input
Window win;
char state[32];
bool mouse_l, mouse_r, mouse_m;
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
int mouse_x, mouse_y;
int mouse_last_x, mouse_last_y;
@ -115,6 +115,10 @@ static int16_t x_mouse_state(x11_input_t *x11, unsigned id)
return x11->mouse_l;
case RETRO_DEVICE_ID_MOUSE_RIGHT:
return x11->mouse_r;
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
return x11->mouse_wu;
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
return x11->mouse_wd;
default:
return 0;
}
@ -245,6 +249,8 @@ 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 && video_focus_func())

View File

@ -142,6 +142,8 @@ extern "C" {
#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
// Id values for LIGHTGUN types.
#define RETRO_DEVICE_ID_LIGHTGUN_X 0

View File

@ -313,6 +313,7 @@ static int16_t ps3_mouse_device_state(void *data, unsigned player, unsigned id)
switch (id)
{
/* TODO: mouse wheel up/down */
case RETRO_DEVICE_ID_MOUSE_LEFT:
return (!ps3->mice_connected ? 0 : mouse_state.buttons & CELL_MOUSE_BUTTON_1);
case RETRO_DEVICE_ID_MOUSE_RIGHT: