Skip to content

Commit

Permalink
First shot at XInput2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 18, 2011
1 parent e455e54 commit 555e96e
Show file tree
Hide file tree
Showing 5 changed files with 558 additions and 358 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -58,7 +58,7 @@ endif



BASEOBJS := linux_evdev.o macosx_hidutilities.o macosx_hidmanager.o windows_wminput.o x11_xinput.o manymouse.o
BASEOBJS := linux_evdev.o macosx_hidutilities.o macosx_hidmanager.o windows_wminput.o x11_xinput2.o manymouse.o

.PHONY: clean all

Expand Down
45 changes: 24 additions & 21 deletions README.txt
Expand Up @@ -126,28 +126,31 @@ Some general ManyMouse usage notes:
recommend using SDL's "windib" target in the meantime to avoid this
problem.

- (XInput code isn't finished yet, but in the future this note will be true.)
On Unix systems, we try to use the XInput extension if possible...currently
most users (XFree86/x.org X server) will not find this useful, since XInput
is either not included or not configured properly. In the short term, most
Linux users should favor the evdev target, below. For now, the XInput
target will refuse to work unless it sees more than one mouse, since in
those cases, the system is possibly misconfigured. XInput currently doesn't
support hotplugging, although the x.org people are planning to extend the
spec to support this. If you want to use the XInput target, make sure you
link with "-ldl", since we use dlopen() to find the X11/XInput libraries.
You do not have to link against Xlib directly, and ManyMouse will fail
gracefully (reporting no mice in the ManyMouse XInput driver) if the
libraries don't exist on the end user's system. Naturally, you'll need
the X11 headers on your system. You can build with SUPPORT_XINPUT defined
to zero to disable XInput support.

- On Linux, we first try to use the /dev/input/event* devices; this means
- On Unix systems, we try to use the XInput2 extension if possible.
ManyMouse will try to fallback to other approaches if there is no X server
available or the X server doesn't support XInput2. If you want to use the
XInput2 target, make sure you link with "-ldl", since we use dlopen() to
find the X11/XInput2 libraries. You do not have to link against Xlib
directly, and ManyMouse will fail gracefully (reporting no mice in the
ManyMouse XInput2 driver) if the libraries don't exist on the end user's
system. Naturally, you'll need the X11 headers on your system (on Ubuntu,
you would want to apt-get install libxi-dev). You can build with
SUPPORT_XINPUT2 defined to zero to disable XInput2 support completely.
Please note that the XInput2 target does not need your app to supply an X11
window. The test_manymouse_stdio app works with this target, so long as the
X server is running. Please note that you should NOT grab the mouse in your
app, though, as it will prevent XInput2 from supplying mouse events.

- On Linux, we can try to use the /dev/input/event* devices; this means
that ManyMouse can function with or without an X server. Please note that
the next major release of x.org's X server will grab the devices at the
kernel level, and will make this interface useless...eventually, their
XInput implementation will implement hotplugging and such, making it the
favorable ManyMouse target for most Linux users.
modern Linux systems only allow root access to these devices. Most users
will want XInput2, but this can be used if the device permissions allow.

- There (currently) exists a class of users that have Linux systems with
evdev device nodes forbidden to all but the root user, and no XInput2
support. These users are out of luck; they should either force the
permissions on /dev/input/events/*, or upgrade their X server. This is a
problem that will solve itself with time.

- On Mac OS X, we use IOKit's HID Manager API, which means you can use this
C-callable library from Cocoa, Carbon, and generic Unix applications, with
Expand Down
7 changes: 2 additions & 5 deletions manymouse.c
Expand Up @@ -17,7 +17,7 @@ extern const ManyMouseDriver *ManyMouseDriver_windows;
extern const ManyMouseDriver *ManyMouseDriver_evdev;
extern const ManyMouseDriver *ManyMouseDriver_hidmanager;
extern const ManyMouseDriver *ManyMouseDriver_hidutilities;
extern const ManyMouseDriver *ManyMouseDriver_xinput;
extern const ManyMouseDriver *ManyMouseDriver_xinput2;

/*
* These have to be in the favored order...obviously it doesn't matter if the
Expand All @@ -31,10 +31,7 @@ extern const ManyMouseDriver *ManyMouseDriver_xinput;
*/
static const ManyMouseDriver **mice_drivers[] =
{
#if 0 /* FIXME: re-add this when the code is written! */
&ManyMouseDriver_xinput,
#endif

&ManyMouseDriver_xinput2,
&ManyMouseDriver_evdev,
&ManyMouseDriver_windows,
&ManyMouseDriver_hidmanager,
Expand Down

0 comments on commit 555e96e

Please sign in to comment.