From 95d782d3fce7b962984446ca226856042b819b09 Mon Sep 17 00:00:00 2001 From: Arusekk Date: Mon, 23 Nov 2020 21:21:17 +0100 Subject: [PATCH] input: Low-effort X11 mouse support (#2042) A simple wrapper around XLookupKeysym, which does not return expected XK_Pointer_* for button events. Tested on Gentoo Linux. --- src/arch/InputHandler/InputHandler_X11.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/arch/InputHandler/InputHandler_X11.cpp b/src/arch/InputHandler/InputHandler_X11.cpp index 917c019364..ceeefa717a 100644 --- a/src/arch/InputHandler/InputHandler_X11.cpp +++ b/src/arch/InputHandler/InputHandler_X11.cpp @@ -187,7 +187,8 @@ void InputHandler_X11::Update() &event) ) { const bool bKeyPress = event.type == KeyPress; - //const bool bMousePress = event.type == ButtonPress; + const bool bMousePress = event.type == ButtonPress; + const bool isMouse = bMousePress || event.type == ButtonRelease; if( event.type == MotionNotify ) { @@ -216,7 +217,7 @@ void InputHandler_X11::Update() } // Get the first defined keysym for this event's key - lastDB = XSymToDeviceButton( XLookupKeysym(&event.xkey, 0) ); + lastDB = XSymToDeviceButton( isMouse ? XK_Pointer_Button_Dflt + event.xbutton.button : XLookupKeysym(&event.xkey, 0) ); if( lastDB == DeviceButton_Invalid ) continue; @@ -225,10 +226,8 @@ void InputHandler_X11::Update() { RegisterKeyEvent( event.xkey.time, true, lastDB ); } - /* else if( bMousePress ) ButtonPressed( DeviceInput(DEVICE_MOUSE, lastDB, 1) ); - */ else lastEvent = event; } @@ -240,10 +239,8 @@ void InputHandler_X11::Update() { RegisterKeyEvent( event.xkey.time, false, lastDB ); } - /* if( lastEvent.type == (ButtonPress|ButtonRelease) ) ButtonPressed( DeviceInput(DEVICE_MOUSE, lastDB, 0) ); - */ } InputHandler::UpdateTimer();