Skip to content

Commit

Permalink
Use XInput2 RawMotion to generate MouseMotion events
Browse files Browse the repository at this point in the history
The current system for capturing the mouse and generating motion events on X11
has issues with inaccurate and lopsided input. This is because both
XQueryPointer and XWarpPointer work in terms of integer coordinates when the
underlying X11 input driver may be tracking the mouse using subpixel
coordinates. When warping the pointer, the fractional part of the pointer
position is discarded.

To work around this issue, the fix uses raw motion events from XInput 2. These
events report relative motion and are not affected by pointer warping.
Additionally, this means Godot is able to detect motion at a higher resolution
under X11. Because this is raw mouse input, it is not affected by the user's
pointer speed and acceleration settings. This is the same system as SDL2 uses
for its relative motion.

Multitouch input on X requires XInput 2.2. Raw motion events require
XInput 2.0. Since 2.0 is old enough, this is now the minimum requirement to
use Godot on X.
  • Loading branch information
KeyboardDanni authored and akien-mga committed Dec 14, 2018
1 parent 5f32fc8 commit cf124b1
Show file tree
Hide file tree
Showing 3 changed files with 279 additions and 127 deletions.
11 changes: 6 additions & 5 deletions platform/x11/detect.py
Expand Up @@ -48,6 +48,11 @@ def can_build():
print("xrender not found.. x11 disabled.")
return False

x11_error = os.system("pkg-config xi --modversion > /dev/null ")
if (x11_error):
print("xi not found.. Aborting.")
return False

return True

def get_opts():
Expand Down Expand Up @@ -170,13 +175,9 @@ def configure(env):
env.ParseConfig('pkg-config xinerama --cflags --libs')
env.ParseConfig('pkg-config xrandr --cflags --libs')
env.ParseConfig('pkg-config xrender --cflags --libs')
env.ParseConfig('pkg-config xi --cflags --libs')

if (env['touch']):
x11_error = os.system("pkg-config xi --modversion > /dev/null ")
if (x11_error):
print("xi not found.. cannot build with touch. Aborting.")
sys.exit(255)
env.ParseConfig('pkg-config xi --cflags --libs')
env.Append(CPPFLAGS=['-DTOUCH_ENABLED'])

# FIXME: Check for existence of the libs before parsing their flags with pkg-config
Expand Down

0 comments on commit cf124b1

Please sign in to comment.