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.
This commit is contained in:
Arusekk
2020-11-23 12:21:17 -08:00
committed by GitHub
parent 6a645b4710
commit 95d782d3fc
+3 -6
View File
@@ -187,7 +187,8 @@ void InputHandler_X11::Update()
&event) ) &event) )
{ {
const bool bKeyPress = event.type == KeyPress; 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 ) if( event.type == MotionNotify )
{ {
@@ -216,7 +217,7 @@ void InputHandler_X11::Update()
} }
// Get the first defined keysym for this event's key // 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 ) if( lastDB == DeviceButton_Invalid )
continue; continue;
@@ -225,10 +226,8 @@ void InputHandler_X11::Update()
{ {
RegisterKeyEvent( event.xkey.time, true, lastDB ); RegisterKeyEvent( event.xkey.time, true, lastDB );
} }
/*
else if( bMousePress ) else if( bMousePress )
ButtonPressed( DeviceInput(DEVICE_MOUSE, lastDB, 1) ); ButtonPressed( DeviceInput(DEVICE_MOUSE, lastDB, 1) );
*/
else else
lastEvent = event; lastEvent = event;
} }
@@ -240,10 +239,8 @@ void InputHandler_X11::Update()
{ {
RegisterKeyEvent( event.xkey.time, false, lastDB ); RegisterKeyEvent( event.xkey.time, false, lastDB );
} }
/*
if( lastEvent.type == (ButtonPress|ButtonRelease) ) if( lastEvent.type == (ButtonPress|ButtonRelease) )
ButtonPressed( DeviceInput(DEVICE_MOUSE, lastDB, 0) ); ButtonPressed( DeviceInput(DEVICE_MOUSE, lastDB, 0) );
*/
} }
InputHandler::UpdateTimer(); InputHandler::UpdateTimer();