mirror of
https://github.com/libretro/RetroArch
synced 2025-02-13 12:40:47 +00:00
Create input_x11_common
This commit is contained in:
parent
e35f91d0f8
commit
9fd9fd10e8
@ -507,7 +507,8 @@ ifeq ($(HAVE_XINPUT), 1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_X11), 1)
|
ifeq ($(HAVE_X11), 1)
|
||||||
OBJ += input/drivers/x11_input.o \
|
OBJ += input/common/input_x11_common.o \
|
||||||
|
input/drivers/x11_input.o \
|
||||||
gfx/common/x11_common.o \
|
gfx/common/x11_common.o \
|
||||||
input/drivers_keyboard/keyboard_event_x11.o
|
input/drivers_keyboard/keyboard_event_x11.o
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#include "x11_common.h"
|
#include "x11_common.h"
|
||||||
|
#include "../../input/common/input_x11_common.h"
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
|
|
||||||
@ -382,12 +383,9 @@ bool x11_get_metrics(void *data,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void x_input_poll_wheel(void *data, XButtonEvent *event, bool latch);
|
|
||||||
|
|
||||||
bool x11_alive(void *data)
|
bool x11_alive(void *data)
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
driver_t *driver = driver_get_ptr();
|
|
||||||
|
|
||||||
while (XPending(g_x11_dpy))
|
while (XPending(g_x11_dpy))
|
||||||
{
|
{
|
||||||
@ -421,7 +419,7 @@ bool x11_alive(void *data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
x_input_poll_wheel(driver->input_data, &event.xbutton, true);
|
x_input_poll_wheel(&event.xbutton, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
@ -320,6 +320,10 @@ INPUT
|
|||||||
#include "../tasks/task_overlay.c"
|
#include "../tasks/task_overlay.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_X11
|
||||||
|
#include "../input/common/x11_input_common.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__)
|
#if defined(__CELLOS_LV2__)
|
||||||
#include "../input/drivers/ps3_input.c"
|
#include "../input/drivers/ps3_input.c"
|
||||||
#include "../input/drivers_joypad/ps3_joypad.c"
|
#include "../input/drivers_joypad/ps3_joypad.c"
|
||||||
|
51
input/common/input_x11_common.c
Normal file
51
input/common/input_x11_common.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "input_x11_common.h"
|
||||||
|
|
||||||
|
static bool x11_mouse_wu;
|
||||||
|
static bool x11_mouse_wd;
|
||||||
|
|
||||||
|
int16_t x_mouse_state_wheel(unsigned id)
|
||||||
|
{
|
||||||
|
int16_t ret = 0;
|
||||||
|
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||||
|
ret = x11_mouse_wu;
|
||||||
|
x11_mouse_wu = 0;
|
||||||
|
return ret;
|
||||||
|
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||||
|
ret = x11_mouse_wd;
|
||||||
|
x11_mouse_wd = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void x_input_poll_wheel(XButtonEvent *event, bool latch)
|
||||||
|
{
|
||||||
|
switch (event->button)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
x11_mouse_wu = 1;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
x11_mouse_wd = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
31
input/common/input_x11_common.h
Normal file
31
input/common/input_x11_common.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INPUT_X11_COMMON_H
|
||||||
|
#define _INPUT_X11_COMMON_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#include <boolean.h>
|
||||||
|
|
||||||
|
#include "../../driver.h"
|
||||||
|
|
||||||
|
int16_t x_mouse_state_wheel(unsigned id);
|
||||||
|
|
||||||
|
void x_input_poll_wheel(XButtonEvent *event, bool latch);
|
||||||
|
|
||||||
|
#endif
|
@ -16,7 +16,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
@ -27,6 +26,7 @@
|
|||||||
#include "../input_keymaps.h"
|
#include "../input_keymaps.h"
|
||||||
|
|
||||||
#include "../../gfx/video_driver.h"
|
#include "../../gfx/video_driver.h"
|
||||||
|
#include "../common/input_x11_common.h"
|
||||||
|
|
||||||
#include "../../driver.h"
|
#include "../../driver.h"
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
@ -41,7 +41,7 @@ typedef struct x11_input
|
|||||||
Window win;
|
Window win;
|
||||||
|
|
||||||
char state[32];
|
char state[32];
|
||||||
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
|
bool mouse_l, mouse_r, mouse_m;
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
int mouse_last_x, mouse_last_y;
|
int mouse_last_x, mouse_last_y;
|
||||||
|
|
||||||
@ -150,17 +150,8 @@ static int16_t x_mouse_state(x11_input_t *x11, unsigned id)
|
|||||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||||
return x11->mouse_r;
|
return x11->mouse_r;
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
|
||||||
{
|
|
||||||
int16_t ret = x11->mouse_wu;
|
|
||||||
x11->mouse_wu = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
|
||||||
{
|
return x_mouse_state_wheel(id);
|
||||||
int16_t ret = x11->mouse_wd;
|
|
||||||
x11->mouse_wd = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||||
return x11->mouse_m;
|
return x11->mouse_m;
|
||||||
}
|
}
|
||||||
@ -342,23 +333,6 @@ 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)
|
static void x_input_poll(void *data)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user