2024-03-09 12:36:54 -08:00
|
|
|
From c984dc72cccf9ca667bad9b1c334204fb45ad851 Mon Sep 17 00:00:00 2001
|
2019-12-23 01:03:44 -08:00
|
|
|
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
|
|
|
Date: Thu, 19 Dec 2019 22:34:44 +0100
|
2024-03-09 12:36:54 -08:00
|
|
|
Subject: [PATCH] winex11: Keep track of mouse device and pointer button
|
2019-12-23 01:03:44 -08:00
|
|
|
mappings.
|
|
|
|
|
|
|
|
We are going to receive raw button events and we will need to apply the
|
|
|
|
correct button mappings ourselves.
|
|
|
|
|
|
|
|
Original patch by Andrew Eikum <aeikum@codeweavers.com>.
|
|
|
|
---
|
2024-03-08 15:46:02 -08:00
|
|
|
configure.ac | 1 +
|
|
|
|
dlls/winex11.drv/keyboard.c | 24 +++++++--
|
|
|
|
dlls/winex11.drv/mouse.c | 93 +++++++++++++++++++++++++++++++++-
|
2019-12-23 01:03:44 -08:00
|
|
|
dlls/winex11.drv/x11drv.h | 1 +
|
|
|
|
dlls/winex11.drv/x11drv_main.c | 1 +
|
2024-03-08 15:46:02 -08:00
|
|
|
5 files changed, 114 insertions(+), 6 deletions(-)
|
2019-12-23 01:03:44 -08:00
|
|
|
|
2024-03-08 15:46:02 -08:00
|
|
|
diff --git a/configure.ac b/configure.ac
|
2024-03-09 12:36:54 -08:00
|
|
|
index 0b8d37fa21b..425a20d73c9 100644
|
2024-03-08 15:46:02 -08:00
|
|
|
--- a/configure.ac
|
|
|
|
+++ b/configure.ac
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -1203,6 +1203,7 @@ then
|
2024-03-08 15:46:02 -08:00
|
|
|
|
|
|
|
dnl *** All of the following tests require X11/Xlib.h
|
|
|
|
AC_CHECK_HEADERS([X11/extensions/shape.h \
|
|
|
|
+ X11/extensions/XInput.h \
|
|
|
|
X11/extensions/XInput2.h \
|
|
|
|
X11/extensions/XShm.h \
|
|
|
|
X11/extensions/Xfixes.h \
|
2019-12-23 01:03:44 -08:00
|
|
|
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
|
2024-03-08 15:46:02 -08:00
|
|
|
index 23f07b851a7..130b7e516a2 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/keyboard.c
|
|
|
|
+++ b/dlls/winex11.drv/keyboard.c
|
2024-03-08 15:46:02 -08:00
|
|
|
@@ -1838,11 +1838,7 @@ BOOL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
-/***********************************************************************
|
|
|
|
- * X11DRV_MappingNotify
|
|
|
|
- */
|
|
|
|
-BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event )
|
|
|
|
+static BOOL X11DRV_KeyboardMappingNotify( HWND dummy, XEvent *event )
|
2019-12-23 01:03:44 -08:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
2024-03-08 15:46:02 -08:00
|
|
|
@@ -1856,6 +1852,24 @@ BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event )
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/***********************************************************************
|
|
|
|
+ * X11DRV_MappingNotify
|
|
|
|
+ */
|
|
|
|
+BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event )
|
|
|
|
+{
|
2019-12-23 01:03:44 -08:00
|
|
|
+ switch (event->xmapping.request)
|
|
|
|
+ {
|
|
|
|
+ case MappingModifier:
|
|
|
|
+ case MappingKeyboard:
|
2024-03-08 15:46:02 -08:00
|
|
|
+ return X11DRV_KeyboardMappingNotify( dummy, event );
|
2019-12-23 01:03:44 -08:00
|
|
|
+ case MappingPointer:
|
|
|
|
+ X11DRV_InitMouse( event->xmapping.display );
|
|
|
|
+ break;
|
|
|
|
+ }
|
2024-03-08 15:46:02 -08:00
|
|
|
+
|
|
|
|
+ return TRUE;
|
|
|
|
+}
|
|
|
|
+
|
2019-12-23 01:03:44 -08:00
|
|
|
|
2024-03-08 15:46:02 -08:00
|
|
|
/***********************************************************************
|
|
|
|
* VkKeyScanEx (X11DRV.@)
|
2019-12-23 01:03:44 -08:00
|
|
|
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
|
2024-03-09 12:36:54 -08:00
|
|
|
index d3c97468fdb..5a5ec51e370 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/mouse.c
|
|
|
|
+++ b/dlls/winex11.drv/mouse.c
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -31,6 +31,9 @@
|
2019-12-23 01:03:44 -08:00
|
|
|
#include <X11/cursorfont.h>
|
|
|
|
#include <stdarg.h>
|
2024-03-09 12:36:54 -08:00
|
|
|
#include <stdint.h>
|
2019-12-23 01:03:44 -08:00
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+#include <X11/extensions/XInput.h>
|
|
|
|
+#endif
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#endif
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -142,6 +145,14 @@ MAKE_FUNCPTR(XISelectEvents);
|
2019-12-23 01:03:44 -08:00
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
|
|
|
+MAKE_FUNCPTR(XOpenDevice);
|
|
|
|
+MAKE_FUNCPTR(XCloseDevice);
|
|
|
|
+MAKE_FUNCPTR(XGetDeviceButtonMapping);
|
|
|
|
+#undef MAKE_FUNCPTR
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_Xcursor_Init
|
|
|
|
*
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -229,6 +240,75 @@ void set_window_cursor( Window window, HCURSOR handle )
|
2023-06-13 17:59:42 -07:00
|
|
|
XFlush( gdi_display );
|
2019-12-23 01:03:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
+struct mouse_button_mapping
|
|
|
|
+{
|
|
|
|
+ int deviceid;
|
|
|
|
+ unsigned int button_count;
|
|
|
|
+ unsigned char buttons[256];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct mouse_button_mapping *pointer_mapping;
|
|
|
|
+static struct mouse_button_mapping *device_mapping;
|
|
|
|
+
|
2024-03-08 15:46:02 -08:00
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+
|
2019-12-23 01:03:44 -08:00
|
|
|
+static void update_pointer_mapping( Display *display )
|
|
|
|
+{
|
|
|
|
+ struct mouse_button_mapping *tmp;
|
|
|
|
+
|
2022-04-23 15:57:41 -07:00
|
|
|
+ if (!(tmp = malloc( sizeof(*tmp) )))
|
2019-12-23 01:03:44 -08:00
|
|
|
+ {
|
|
|
|
+ WARN("Unable to allocate device mapping.\n");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmp->button_count = ARRAY_SIZE( tmp->buttons );
|
|
|
|
+ tmp->button_count = XGetPointerMapping( display, tmp->buttons, tmp->button_count );
|
|
|
|
+
|
2024-03-08 15:46:02 -08:00
|
|
|
+ free( InterlockedExchangePointer( (void**)&pointer_mapping, tmp ) );
|
2019-12-23 01:03:44 -08:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void update_device_mapping( Display *display, int deviceid )
|
|
|
|
+{
|
|
|
|
+ struct mouse_button_mapping *tmp;
|
|
|
|
+ XDevice *device;
|
|
|
|
+
|
|
|
|
+ if (!(device = pXOpenDevice( display, deviceid )))
|
|
|
|
+ {
|
|
|
|
+ WARN( "Unable to open cursor device %d\n", deviceid );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
2022-04-23 15:57:41 -07:00
|
|
|
+ if (!(tmp = malloc( sizeof(*tmp) )))
|
2019-12-23 01:03:44 -08:00
|
|
|
+ {
|
|
|
|
+ WARN( "Unable to allocate device mapping.\n" );
|
|
|
|
+ pXCloseDevice( display, device );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmp->deviceid = deviceid;
|
|
|
|
+ tmp->button_count = ARRAY_SIZE( tmp->buttons );
|
|
|
|
+ tmp->button_count = pXGetDeviceButtonMapping( display, device, tmp->buttons, tmp->button_count );
|
|
|
|
+
|
2024-03-08 15:46:02 -08:00
|
|
|
+ free( InterlockedExchangePointer( (void**)&device_mapping, tmp ) );
|
2019-12-23 01:03:44 -08:00
|
|
|
+
|
|
|
|
+ pXCloseDevice( display, device );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void X11DRV_InitMouse( Display *display )
|
|
|
|
+{
|
|
|
|
+ update_pointer_mapping( display );
|
|
|
|
+}
|
2024-03-08 15:46:02 -08:00
|
|
|
+
|
|
|
|
+#else /* HAVE_X11_EXTENSIONS_XINPUT_H */
|
|
|
|
+
|
|
|
|
+void X11DRV_InitMouse( Display *display )
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif /* HAVE_X11_EXTENSIONS_XINPUT_H */
|
|
|
|
+
|
2019-12-23 01:03:44 -08:00
|
|
|
+
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
/***********************************************************************
|
|
|
|
* update_relative_valuators
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -1674,6 +1754,8 @@ static BOOL X11DRV_DeviceChanged( XGenericEventCookie *xev )
|
2019-12-23 01:03:44 -08:00
|
|
|
|
2024-03-08 15:46:02 -08:00
|
|
|
if (event->deviceid != data->xinput2_pointer) return FALSE;
|
2019-12-23 01:03:44 -08:00
|
|
|
update_relative_valuators( event->classes, event->num_classes );
|
|
|
|
+ update_device_mapping( event->display, event->sourceid );
|
|
|
|
+
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -1822,7 +1904,7 @@ static BOOL X11DRV_TouchEvent( HWND hwnd, XGenericEventCookie *xev )
|
2019-12-23 01:03:44 -08:00
|
|
|
*/
|
2024-03-08 15:46:02 -08:00
|
|
|
void x11drv_xinput2_load(void)
|
2019-12-23 01:03:44 -08:00
|
|
|
{
|
|
|
|
-#if defined(SONAME_LIBXI) && defined(HAVE_X11_EXTENSIONS_XINPUT2_H)
|
|
|
|
+#if defined(SONAME_LIBXI)
|
|
|
|
int event, error;
|
2020-04-07 16:15:39 -07:00
|
|
|
void *libxi_handle = dlopen( SONAME_LIBXI, RTLD_NOW );
|
2019-12-23 01:03:44 -08:00
|
|
|
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -1838,11 +1920,20 @@ void x11drv_xinput2_load(void)
|
2019-12-23 01:03:44 -08:00
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
LOAD_FUNCPTR(XIGetClientPointer);
|
|
|
|
LOAD_FUNCPTR(XIFreeDeviceInfo);
|
|
|
|
LOAD_FUNCPTR(XIQueryDevice);
|
|
|
|
LOAD_FUNCPTR(XIQueryVersion);
|
|
|
|
LOAD_FUNCPTR(XISelectEvents);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#ifdef HAVE_X11_EXTENSIONS_XINPUT_H
|
|
|
|
+ LOAD_FUNCPTR(XOpenDevice);
|
|
|
|
+ LOAD_FUNCPTR(XCloseDevice);
|
|
|
|
+ LOAD_FUNCPTR(XGetDeviceButtonMapping);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
xinput2_available = XQueryExtension( gdi_display, "XInputExtension", &xinput2_opcode, &event, &error );
|
|
|
|
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
|
2024-03-09 12:36:54 -08:00
|
|
|
index 2f5721d2b8b..05ae23dcfdb 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv.h
|
|
|
|
+++ b/dlls/winex11.drv/x11drv.h
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -688,6 +688,7 @@ extern void retry_grab_clipping_window(void);
|
2023-11-29 16:35:48 -08:00
|
|
|
extern void ungrab_clipping_window(void);
|
|
|
|
extern void move_resize_window( HWND hwnd, int dir );
|
|
|
|
extern void X11DRV_InitKeyboard( Display *display );
|
|
|
|
+extern void X11DRV_InitMouse( Display *display );
|
|
|
|
extern BOOL X11DRV_ProcessEvents( DWORD mask );
|
|
|
|
extern HWND *build_hwnd_list(void);
|
2023-02-22 13:34:37 -08:00
|
|
|
|
2019-12-23 01:03:44 -08:00
|
|
|
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
|
2024-03-09 12:36:54 -08:00
|
|
|
index 19419644940..32f23e64378 100644
|
2019-12-23 01:03:44 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv_main.c
|
|
|
|
+++ b/dlls/winex11.drv/x11drv_main.c
|
2024-03-09 12:36:54 -08:00
|
|
|
@@ -700,6 +700,7 @@ static NTSTATUS x11drv_init( void *arg )
|
2023-02-28 15:05:20 -08:00
|
|
|
|
|
|
|
XkbUseExtension( gdi_display, NULL, NULL );
|
2019-12-23 01:03:44 -08:00
|
|
|
X11DRV_InitKeyboard( gdi_display );
|
|
|
|
+ X11DRV_InitMouse( gdi_display );
|
2023-04-03 17:40:07 -07:00
|
|
|
if (use_xim) use_xim = xim_init( input_style );
|
2019-12-23 01:03:44 -08:00
|
|
|
|
2021-11-30 15:27:42 -08:00
|
|
|
init_user_driver();
|
2019-12-23 01:03:44 -08:00
|
|
|
--
|
2024-03-08 15:46:02 -08:00
|
|
|
2.43.0
|
2019-12-23 01:03:44 -08:00
|
|
|
|