SDL, X.org and multiple mice

Hi,

I’m trying to use multiple, distinct mice in an SDL program.
In SDL_MouseMotionEvent, there is an entry
Uint8 which; /* The mouse device index */
that makes me believe that there is a way to support multiple mice.

When I setup my second mouse to send coreevents in xorg.conf, both mice
control the same pointer and ‘which’ is 0 for both mice (which I think is
correct but which I don’t want :-)).
If I omit the “SendCoreEvents” option, no mouse events seem to be generated
for the second mouse.
Has anyone tried something like this before and is able to tell me if I’m
doing something wrong, or if SDL simply does not support multiple mice?

Thanks in advance,
Flo----
xorg.conf:

Section "InputDevice"
Identifier "PS2Mouse"
Driver "mouse"
Option “Protocol” "PS/2"
Option “Device” "/dev/input/mouse0"
Option “ZAxisMapping” "4 5"
EndSection

Section "InputDevice"
Identifier "USBMouse"
Driver "mouse"
Option “Protocol” "IMPS/2"
Option “Device” "/dev/input/mouse1"
Option “ZAxisMapping” "4 5"
EndSection

Section "ServerLayout"
InputDevice “PS2Mouse” "CorePointer"
InputDevice “USBMouse” #"SendCoreEvents"
EndSection

Heh, I have asked very similar questions in the past. If you’d have
only googled this mailing list for “multiple distinct mice” you
probably would have found my posts. Alas, SDL supports this, but no OS
known to man does :(On Jun 22, 2005, at 10:06 AM, Florian Niebling wrote:

Hi,

I’m trying to use multiple, distinct mice in an SDL program.
In SDL_MouseMotionEvent, there is an entry
Uint8 which; /* The mouse device index */
that makes me believe that there is a way to support multiple mice.

When I setup my second mouse to send coreevents in xorg.conf, both mice
control the same pointer and ‘which’ is 0 for both mice (which I think
is
correct but which I don’t want :-)).
If I omit the “SendCoreEvents” option, no mouse events seem to be
generated
for the second mouse.
Has anyone tried something like this before and is able to tell me if
I’m
doing something wrong, or if SDL simply does not support multiple mice?

Thanks in advance,
Flo


xorg.conf:

Section "InputDevice"
Identifier "PS2Mouse"
Driver "mouse"
Option “Protocol” "PS/2"
Option “Device” "/dev/input/mouse0"
Option “ZAxisMapping” "4 5"
EndSection

Section "InputDevice"
Identifier "USBMouse"
Driver "mouse"
Option “Protocol” "IMPS/2"
Option “Device” "/dev/input/mouse1"
Option “ZAxisMapping” "4 5"
EndSection

Section "ServerLayout"
InputDevice “PS2Mouse” "CorePointer"
InputDevice “USBMouse” #"SendCoreEvents"
EndSection


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I beg to differ. Using the Linux input event interface (ie.
/dev/input/eventX), one can poll all input devices independently,
including keyboards and mice. I’ve never seen anything using it though
(which is sad, because since 2.6 it’s basically the official way to
probe input devices, everything else should be deprecated). An SDL
backend would be nice, I thought about it once but never got the time
to try and work on it.On 6/22/05, Donny Viszneki wrote:

Heh, I have asked very similar questions in the past. If you’d have
only googled this mailing list for “multiple distinct mice” you
probably would have found my posts. Alas, SDL supports this, but no OS
known to man does :frowning:

Heh, I have asked very similar questions in the past. If you’d have
only googled this mailing list for “multiple distinct mice” you
probably would have found my posts. Alas, SDL supports this, but no OS
known to man does :frowning:

Funny, I just asked this on IRC last week. Popular topic, apparently. :slight_smile:

Here’s my understanding after some research. This is a whole brain dump
for those that are deeply interested. The short of it is “you can’t do
it at all now, and with a lot of fighting, you can sorta do it”.

  1. If the Linux user is using /dev/input/mice for his mouse device in
    XFree/x.org, even if he’s got five USB mice plugged in, all his mouse
    input will be interpolated into one virtual IMPS/2 mouse by the kernel,
    and the X server won’t know the difference. Most distros are doing this
    out of the box now, since for all normal cases it makes a lot of sense,
    but it makes assuming you can get multiple mice by default on Linux
    basically wrong.

  2. Even if you can coerce the X server into noticing multiple mice, you
    lose the functionality on Linux with fbcon, etc.

  3. Actually, as far as X11 goes, it’s worse than that: read on.

Eventually, after getting a mouse motion event from the
OS/Xserver/whatever, all SDL targets call SDL_PrivateMouseMotion(),
which does not let them specify a device index. Here’s the exact code in
SDL_PrivateMouseMotion that sends the SDL_MOUSEMOTION event to your app:

SDL_Event event;
memset(&event, 0, sizeof(event));
event.type = SDL_MOUSEMOTION;
event.motion.state = buttonstate;
event.motion.x = X;
event.motion.y = Y;
event.motion.xrel = Xrel;
event.motion.yrel = Yrel;
if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
    posted = 1;
    SDL_PushEvent(&event);
}

…as you can see, no platform, or target on any platform currently
supports multiple mice, since the point where we pass these to the app
never sets the field to anything but zero.

And, while we’re at it, here’s the structure that backs the X11
"MotionNotify" event, which SDL uses to make SDL_MOUSEMOTION on X11.

typedef struct {
int type; /* MotionNotify /
unsigned long serial; /
# of last request processed /
Bool send_event; /
true if this came from a SendEvent */
Display display; / Display the event was read from /
Window window; /
``event’’ window reported relative to /
Window root; /
root window that the event occurred on /
Window subwindow; /
child window /
Time time; /
milliseconds /
int x, y; /
x, y coordinates in event win /
int x_root, y_root; /
coordinates relative to root /
unsigned int state; /
key or button mask /
char is_hint; /
detail /
Bool same_screen; /
same screen flag */
} XMotionEvent;

So, the X11 protocol won’t send you a device ID.

The WinDib target uses standard Windows messages, which don’t specify a
device id. Theoretically, the windx5 target can enumerate multiple mice
via DirectInput, but it doesn’t try, probably because the MSDN reference
page for IDirectInput8::EnumDevices() says this:

“On Microsoft Windows XP, Microsoft DirectInput enumerates only one
mouse and one keyboard device, referred to as the system mouse and the
system keyboard.”

MacOS X just doesn’t do this at all at the Cocoa layer (although, in
10.4 (“Tiger”), you can have multiple Tablet devices)…quartz target is
out of luck.

This is probably true on all the other platforms SDL supports too.

So, here’s the good news.

Windows, Linux, and MacOS can all support multiple, distinct mice, but
they don’t in the standard event interfaces.

On Windows, you have to enable the WM_INPUT event and then parse out raw
mouse packets.

On MacOS X, you can use HID Manager to get raw HID packets (despite the
name, this works with non-USB things, like the Powerbook’s trackpad). If
you use the “HID Utilities” source layered over HID Manager, this is
surprisingly little code, considering how low-level it is. WM_INPUT
isn’t much worse on Windows.

On Linux, you can cat “/dev/input/eventX” and see binary crap stream to
the xterm while you wiggle the mouse cursor in the X server…which
means you can read mouse input seperately and directly without
interfering with the X server. I think the “event” device nodes have a
standard interface that is abstracted from the specific hardware
involved. This would also let you handle multiple USB keyboards (etc) if
you were so inclined. More importantly, it’d work from both X11 and
fbcon, but it obviously is useless for remote X11.

My understanding is that using these approaches on these three platforms
will get you support for multiple mice in a generic way, and not just
USB ones (or whatever the next popular standard is).

None of this is written, but I did just have to implement this directly
in application code of an SDL-based game on MacOS, so I know a little
about it. :slight_smile:

Some notes:

  1. You would have to have SDL ignore normal mouse input when travelling
    this path, since you’ll still get MOUSEMOTION events for the system
    cursor even though you’re moving five mice.

  2. Since many apps expect you to move the system cursor, multiple mice
    are arguably useless unless you have the input bound to your window and
    the system cursor hidden. I can’t see a reasonably way for SDL to
    provide multiple mice input without that condition. Since MacOS 10.3
    (“Panther”), you can tell the HID Manager to decouple a given mouse from
    the system cursor, and, assuming that x.org is only bound to one device,
    you can work around it there, too…arguably both issues make this
    difficult to assume the end user will have a proper configuration. I
    don’t know about Windows for this.

  3. Assuming a Linux kernel character device interface will never change
    is asking for trouble. :slight_smile:

–ryan.

I’m coming into this of late, but this might prove useful:

http://www.cs.princeton.edu/omnimedia/papers/multicursor.pdf

I’ve tried the multi-cursor WM on my machine and it works. There are a
couple of caveats, however:

  1. I have not successful tested multiple mice inputs with the system

  2. I have not successful implemented several X displays forwarding to
    X :0 using vfsb

This post may not have meaning for you as I must confess I deleted the
original post and am going only by the replies. I thought it better to
share this risking not correctly identifying the subject matter of the
post rather than not contributing at all.

-CoopOn Wed, 2005-06-22 at 15:12 -0400, Ryan C. Gordon wrote:

Heh, I have asked very similar questions in the past. If you’d have
only googled this mailing list for “multiple distinct mice” you
probably would have found my posts. Alas, SDL supports this, but no OS
known to man does :frowning:

Funny, I just asked this on IRC last week. Popular topic, apparently. :slight_smile:

Here’s my understanding after some research. This is a whole brain dump
for those that are deeply interested. The short of it is “you can’t do
it at all now, and with a lot of fighting, you can sorta do it”.

  1. If the Linux user is using /dev/input/mice for his mouse device in
    XFree/x.org, even if he’s got five USB mice plugged in, all his mouse
    input will be interpolated into one virtual IMPS/2 mouse by the kernel,
    and the X server won’t know the difference. Most distros are doing this
    out of the box now, since for all normal cases it makes a lot of sense,
    but it makes assuming you can get multiple mice by default on Linux
    basically wrong.

  2. Even if you can coerce the X server into noticing multiple mice, you
    lose the functionality on Linux with fbcon, etc.

  3. Actually, as far as X11 goes, it’s worse than that: read on.

Eventually, after getting a mouse motion event from the
OS/Xserver/whatever, all SDL targets call SDL_PrivateMouseMotion(),
which does not let them specify a device index. Here’s the exact code in
SDL_PrivateMouseMotion that sends the SDL_MOUSEMOTION event to your app:

SDL_Event event;
memset(&event, 0, sizeof(event));
event.type = SDL_MOUSEMOTION;
event.motion.state = buttonstate;
event.motion.x = X;
event.motion.y = Y;
event.motion.xrel = Xrel;
event.motion.yrel = Yrel;
if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
    posted = 1;
    SDL_PushEvent(&event);
}

…as you can see, no platform, or target on any platform currently
supports multiple mice, since the point where we pass these to the app
never sets the field to anything but zero.

And, while we’re at it, here’s the structure that backs the X11
"MotionNotify" event, which SDL uses to make SDL_MOUSEMOTION on X11.

typedef struct {
int type; /* MotionNotify /
unsigned long serial; /
# of last request processed /
Bool send_event; /
true if this came from a SendEvent */
Display display; / Display the event was read from /
Window window; /
``event’’ window reported relative to /
Window root; /
root window that the event occurred on /
Window subwindow; /
child window /
Time time; /
milliseconds /
int x, y; /
x, y coordinates in event win /
int x_root, y_root; /
coordinates relative to root /
unsigned int state; /
key or button mask /
char is_hint; /
detail /
Bool same_screen; /
same screen flag */
} XMotionEvent;

So, the X11 protocol won’t send you a device ID.

The WinDib target uses standard Windows messages, which don’t specify a
device id. Theoretically, the windx5 target can enumerate multiple mice
via DirectInput, but it doesn’t try, probably because the MSDN reference
page for IDirectInput8::EnumDevices() says this:

“On Microsoft Windows XP, Microsoft DirectInput enumerates only one
mouse and one keyboard device, referred to as the system mouse and the
system keyboard.”

MacOS X just doesn’t do this at all at the Cocoa layer (although, in
10.4 (“Tiger”), you can have multiple Tablet devices)…quartz target is
out of luck.

This is probably true on all the other platforms SDL supports too.

So, here’s the good news.

Windows, Linux, and MacOS can all support multiple, distinct mice, but
they don’t in the standard event interfaces.

On Windows, you have to enable the WM_INPUT event and then parse out raw
mouse packets.

On MacOS X, you can use HID Manager to get raw HID packets (despite the
name, this works with non-USB things, like the Powerbook’s trackpad). If
you use the “HID Utilities” source layered over HID Manager, this is
surprisingly little code, considering how low-level it is. WM_INPUT
isn’t much worse on Windows.

On Linux, you can cat “/dev/input/eventX” and see binary crap stream to
the xterm while you wiggle the mouse cursor in the X server…which
means you can read mouse input seperately and directly without
interfering with the X server. I think the “event” device nodes have a
standard interface that is abstracted from the specific hardware
involved. This would also let you handle multiple USB keyboards (etc) if
you were so inclined. More importantly, it’d work from both X11 and
fbcon, but it obviously is useless for remote X11.

My understanding is that using these approaches on these three platforms
will get you support for multiple mice in a generic way, and not just
USB ones (or whatever the next popular standard is).

None of this is written, but I did just have to implement this directly
in application code of an SDL-based game on MacOS, so I know a little
about it. :slight_smile:

Some notes:

  1. You would have to have SDL ignore normal mouse input when travelling
    this path, since you’ll still get MOUSEMOTION events for the system
    cursor even though you’re moving five mice.

  2. Since many apps expect you to move the system cursor, multiple mice
    are arguably useless unless you have the input bound to your window and
    the system cursor hidden. I can’t see a reasonably way for SDL to
    provide multiple mice input without that condition. Since MacOS 10.3
    (“Panther”), you can tell the HID Manager to decouple a given mouse from
    the system cursor, and, assuming that x.org is only bound to one device,
    you can work around it there, too…arguably both issues make this
    difficult to assume the end user will have a proper configuration. I
    don’t know about Windows for this.

  3. Assuming a Linux kernel character device interface will never change
    is asking for trouble. :slight_smile:

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Here’s my understanding after some research. This is a whole brain dump
for those that are deeply interested. The short of it is “you can’t do
it at all now, and with a lot of fighting, you can sorta do it”.

Actually, rambling aside, here’s an example program to do this from a
Linux SDL app without changes to SDL.

  1. Make sure the evdev, input, and mouse kernel modules are loaded
    (maybe others?)

  2. Plug in as many USB mice as you can (up to 32).

  3. Compile:
    g++ -o test_evdev test_evdev sdl-config --cflags sdl-config --libs

  4. Run the program, move the mice around the screen.

  5. If you plug in a new mouse, hit ‘R’ to redetect them without
    restarting the program. Unplugging a mouse is okay, but you’ll need to
    redetect to get it back if you plug it back in…

  6. Hit the Escape key to quit.

I didn’t do anything with the mouse buttons, just the motion events.
There’s a lot of FIXMEs, but this is what 2.5 hour’s work gets you with
no sleep. :slight_smile:

–ryan.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: test_evdev.cpp
Type: text/x-c++src
Size: 7078 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050622/b6e01797/attachment.cpp

Ryan C. Gordon wrote:

Here’s my understanding after some research. This is a whole brain dump
for those that are deeply interested. The short of it is “you can’t do
it at all now, and with a lot of fighting, you can sorta do it”.

Actually, rambling aside, here’s an example program to do this from a
Linux SDL app without changes to SDL.
(…)

Hm, it doesn’t seem to work here. That’s probably because I didn’t
strictly follow step 2, though; in stead of just USB mice I’ve got one
PS/2 mouse (on /dev/input/event1) and one USB tablet w/mouse (on
/dev/input/event2). Your example program picks up the PS/2 mouse, but
not the tablet mouse (or the pen, for that matter).

Are you sure there’s no way to do this in X, though ? The Gimp (via
GTK, I suspect) supports multiple distinct input devices. Each device
has its own settings (brush, etc), which gets switched to automatically
whenever you use the associated device. This has always worked fine,
even though only root had read access to /dev/input/event* until I tried
your program just now and had to fix the permissions. I obviously never
run Gimp as root, so it must get its multiple device information from X
somehow ?

  • Gerry

Hm, it doesn’t seem to work here. That’s probably because I didn’t
strictly follow step 2, though; in stead of just USB mice I’ve got one
PS/2 mouse (on /dev/input/event1) and one USB tablet w/mouse (on
/dev/input/event2). Your example program picks up the PS/2 mouse, but
not the tablet mouse (or the pen, for that matter).

The tablet probably reports absolute values instead of relative ones, so
I ingore it. There isn’t any way that I could see to ask “is this a
mouse” so I look for devices that report position with relative
movement. Otherwise, it picks up keyboards and joysticks, too.

It could be made to work, but in this case, that’s the expected result
from that code snippet.

–ryan.

Heh, I have asked very similar questions in the past. If you’d have
only googled this mailing list for “multiple distinct mice” you
probably would have found my posts. Alas, SDL supports this, but no OS
known to man does :frowning:

The X protocol and the core X server has had support for multiple
pointer devices since the beginning of X11, and maybe farther back than
that… Of course, there have not been that many X servers that actually
supported them. I worked on one 18? 19? years ago and that is the only I
ever saw. :slight_smile:

My best bet is that while there is a slot in the event for a device ID
the underlying code in SDL always sets it to 0. A quick grep -ir seems
to confirm that the which slot in events is only set in the joystick
code.

This looks like a case where the SDL developers saw a need for a device
ID in an event, but didn’t have a way to test with multiple devices and
therefore didn’t implement it. I suppose now that systems with more than
one pointer device are becoming more widely available, someone will
hopefully volunteer to add this functionality to SDL. X “should” be
passing pointer device IDs to SDL.

	Bob PendletonOn Wed, 2005-06-22 at 12:33 -0400, Donny Viszneki wrote:

On Jun 22, 2005, at 10:06 AM, Florian Niebling wrote:

Hi,

I’m trying to use multiple, distinct mice in an SDL program.
In SDL_MouseMotionEvent, there is an entry
Uint8 which; /* The mouse device index */
that makes me believe that there is a way to support multiple mice.

When I setup my second mouse to send coreevents in xorg.conf, both mice
control the same pointer and ‘which’ is 0 for both mice (which I think
is
correct but which I don’t want :-)).
If I omit the “SendCoreEvents” option, no mouse events seem to be
generated
for the second mouse.
Has anyone tried something like this before and is able to tell me if
I’m
doing something wrong, or if SDL simply does not support multiple mice?

Thanks in advance,
Flo


xorg.conf:

Section "InputDevice"
Identifier "PS2Mouse"
Driver "mouse"
Option “Protocol” "PS/2"
Option “Device” "/dev/input/mouse0"
Option “ZAxisMapping” "4 5"
EndSection

Section "InputDevice"
Identifier "USBMouse"
Driver "mouse"
Option “Protocol” "IMPS/2"
Option “Device” "/dev/input/mouse1"
Option “ZAxisMapping” "4 5"
EndSection

Section "ServerLayout"
InputDevice “PS2Mouse” "CorePointer"
InputDevice “USBMouse” #"SendCoreEvents"
EndSection


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

Heh, I have asked very similar questions in the past. If you’d have
only googled this mailing list for “multiple distinct mice” you
probably would have found my posts. Alas, SDL supports this, but no OS
known to man does :frowning:

Funny, I just asked this on IRC last week. Popular topic, apparently. :slight_smile:

Here’s my understanding after some research. This is a whole brain dump
for those that are deeply interested. The short of it is “you can’t do
it at all now, and with a lot of fighting, you can sorta do it”.

  1. If the Linux user is using /dev/input/mice for his mouse device in
    XFree/x.org, even if he’s got five USB mice plugged in, all his mouse
    input will be interpolated into one virtual IMPS/2 mouse by the kernel,
    and the X server won’t know the difference. Most distros are doing this
    out of the box now, since for all normal cases it makes a lot of sense,
    but it makes assuming you can get multiple mice by default on Linux
    basically wrong.

  2. Even if you can coerce the X server into noticing multiple mice, you
    lose the functionality on Linux with fbcon, etc.

  3. Actually, as far as X11 goes, it’s worse than that: read on.

Eventually, after getting a mouse motion event from the
OS/Xserver/whatever, all SDL targets call SDL_PrivateMouseMotion(),
which does not let them specify a device index. Here’s the exact code in
SDL_PrivateMouseMotion that sends the SDL_MOUSEMOTION event to your app:

SDL_Event event;
memset(&event, 0, sizeof(event));
event.type = SDL_MOUSEMOTION;
event.motion.state = buttonstate;
event.motion.x = X;
event.motion.y = Y;
event.motion.xrel = Xrel;
event.motion.yrel = Yrel;
if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
    posted = 1;
    SDL_PushEvent(&event);
}

…as you can see, no platform, or target on any platform currently
supports multiple mice, since the point where we pass these to the app
never sets the field to anything but zero.

And, while we’re at it, here’s the structure that backs the X11
"MotionNotify" event, which SDL uses to make SDL_MOUSEMOTION on X11.

typedef struct {
int type; /* MotionNotify /
unsigned long serial; /
# of last request processed /
Bool send_event; /
true if this came from a SendEvent */
Display display; / Display the event was read from /
Window window; /
``event’’ window reported relative to /
Window root; /
root window that the event occurred on /
Window subwindow; /
child window /
Time time; /
milliseconds /
int x, y; /
x, y coordinates in event win /
int x_root, y_root; /
coordinates relative to root /
unsigned int state; /
key or button mask /
char is_hint; /
detail /
Bool same_screen; /
same screen flag */
} XMotionEvent;

So, the X11 protocol won’t send you a device ID.

You’re looking at the wrong part of the X protocol. You need to look at
the X input extension. It was introduced around 20 years ago (back when
I had just started porting X servers :slight_smile: and it supports a way to probe
for devices and receive input events from the device. I think it also
supports a way to change core input devices, but I’m not sure about
that. It was a looong time ago.

	Bob PendletonOn Wed, 2005-06-22 at 15:12 -0400, Ryan C. Gordon wrote:

The WinDib target uses standard Windows messages, which don’t specify a
device id. Theoretically, the windx5 target can enumerate multiple mice
via DirectInput, but it doesn’t try, probably because the MSDN reference
page for IDirectInput8::EnumDevices() says this:

“On Microsoft Windows XP, Microsoft DirectInput enumerates only one
mouse and one keyboard device, referred to as the system mouse and the
system keyboard.”

MacOS X just doesn’t do this at all at the Cocoa layer (although, in
10.4 (“Tiger”), you can have multiple Tablet devices)…quartz target is
out of luck.

This is probably true on all the other platforms SDL supports too.

So, here’s the good news.

Windows, Linux, and MacOS can all support multiple, distinct mice, but
they don’t in the standard event interfaces.

On Windows, you have to enable the WM_INPUT event and then parse out raw
mouse packets.

On MacOS X, you can use HID Manager to get raw HID packets (despite the
name, this works with non-USB things, like the Powerbook’s trackpad). If
you use the “HID Utilities” source layered over HID Manager, this is
surprisingly little code, considering how low-level it is. WM_INPUT
isn’t much worse on Windows.

On Linux, you can cat “/dev/input/eventX” and see binary crap stream to
the xterm while you wiggle the mouse cursor in the X server…which
means you can read mouse input seperately and directly without
interfering with the X server. I think the “event” device nodes have a
standard interface that is abstracted from the specific hardware
involved. This would also let you handle multiple USB keyboards (etc) if
you were so inclined. More importantly, it’d work from both X11 and
fbcon, but it obviously is useless for remote X11.

My understanding is that using these approaches on these three platforms
will get you support for multiple mice in a generic way, and not just
USB ones (or whatever the next popular standard is).

None of this is written, but I did just have to implement this directly
in application code of an SDL-based game on MacOS, so I know a little
about it. :slight_smile:

Some notes:

  1. You would have to have SDL ignore normal mouse input when travelling
    this path, since you’ll still get MOUSEMOTION events for the system
    cursor even though you’re moving five mice.

  2. Since many apps expect you to move the system cursor, multiple mice
    are arguably useless unless you have the input bound to your window and
    the system cursor hidden. I can’t see a reasonably way for SDL to
    provide multiple mice input without that condition. Since MacOS 10.3
    (“Panther”), you can tell the HID Manager to decouple a given mouse from
    the system cursor, and, assuming that x.org is only bound to one device,
    you can work around it there, too…arguably both issues make this
    difficult to assume the end user will have a proper configuration. I
    don’t know about Windows for this.

  3. Assuming a Linux kernel character device interface will never change
    is asking for trouble. :slight_smile:

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

You’re looking at the wrong part of the X protocol. You need to look at
the X input extension. It was introduced around 20 years ago (back when
I had just started porting X servers :slight_smile: and it supports a way to probe
for devices and receive input events from the device. I think it also
supports a way to change core input devices, but I’m not sure about
that. It was a looong time ago.

Ah, ok.

This is also how Gimp supports tablets, apparently, although SDL doesn’t
appear to use the extension at this point.

However, it doesn’t get around the fact that most boxes aren’t
configured for multiple mice in the X server itself (the ones that need
a tablet are the exception, and go out of their way to configure it), so
in many ways, XInput wouldn’t be reliably for this (although, it would
no doubt be a more reliable method than trying to use /dev/input/event*
on a non-Linux box, or probably even kernel 12.7.15).

Obviously, this continues to be a mess. :slight_smile:

–ryan.

You’re looking at the wrong part of the X protocol. You need to look at
the X input extension. It was introduced around 20 years ago (back when
I had just started porting X servers :slight_smile: and it supports a way to probe
for devices and receive input events from the device. I think it also
supports a way to change core input devices, but I’m not sure about
that. It was a looong time ago.

Ah, ok.

This is also how Gimp supports tablets, apparently, although SDL doesn’t
appear to use the extension at this point.

However, it doesn’t get around the fact that most boxes aren’t
configured for multiple mice in the X server itself (the ones that need
a tablet are the exception, and go out of their way to configure it), so
in many ways, XInput wouldn’t be reliably for this (although, it would
no doubt be a more reliable method than trying to use /dev/input/event*
on a non-Linux box, or probably even kernel 12.7.15).

You are correct. XInput is not well supported by kernel no matter the
OS. But, until USB came along, there wasn’t much need for it either.
Now, we need to push, or help, the device driver developers and the X
server developers to add full support for XInput. Then we can add
support in SDL. We need a way to enumerate the devices that are attached
to a box, to configure them, and to get input from them. And in an X
based world XInput is the way to do that. IIRC, its API has the ability
to support just about any kind of input device you can connect to a
computer. But, the OS has to provide a way to make it work.

	Bob PendletonOn Thu, 2005-06-23 at 12:17 -0400, Ryan C. Gordon wrote:

Obviously, this continues to be a mess. :slight_smile:

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

Here’s shot two at this…I don’t have a tablet or touchpad on a Linux
box, so the math might be off.

–ryan.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: test_evdev.cpp
Type: text/x-c++src
Size: 10058 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050624/a74aca86/attachment.cpp

Ryan C. Gordon wrote:

Here’s shot two at this…I don’t have a tablet or touchpad on a Linux
box, so the math might be off.

It works fine! (after fixing permissions again – this version just
failed silently when the event devices were unreadable, btw, and started
with no pointers). Now I’m getting one pointer for the PS/2 mouse, and
one pointer for the tablet.

Not to complain, but … It’d be nice to have one pointer for each
tablet “subdevice” (mouse, pen, eraser, etc), in stead of one for all
tablet subdevices combined. I guess there’s no way to do that without a
tablet-specific driver ?

Also, it’d be nice if the tablet mouse input was converted to relative.
I guess there’s no reliable way of automatically detecting whether a
device is “usually” relative, though, so we’ll probably need a manual
config for setting absolute/relative (like X needs).

By the way, where can I find info about the event ioctls ? I looked in
the kernel Documentation dir (2.6.10), but found nothing. Google wasn’t
too helpful, either.

  • Gerry

Also, it’d be nice if the tablet mouse input was converted to relative.
I guess there’s no reliable way of automatically detecting whether a
device is “usually” relative, though, so we’ll probably need a manual
config for setting absolute/relative (like X needs).

Theoretically, we know this is a tablet/touchpad if it’s giving absolute
values, and can interpret that differently than, say, a joystick’s
absolute values…it might not be unreasonable to convert it to deltas
between the current and last event, and throw out large values (user is
still travelling “left”, but moved back to the right side of the device
so they can keep travelling).

I have a Wacom tablet in Philadelphia, so I’ll experiment with that when
I get back there in a few days. Then I’m probably done with this until
we can talk about how to sanely implement this in SDL (and if not, at
least we have a good answer to a mailing list FAQ for the future).

By the way, where can I find info about the event ioctls ? I looked in
the kernel Documentation dir (2.6.10), but found nothing. Google wasn’t
too helpful, either.

I started with an XFree86 tablet driver’s source code, and found this later:

http://www.frogmouth.net/hid-doco/c537.html

–ryan.

By the way, this would be a great thing to add for SDL 1.3
Hopefully, at least for X, it should just be a matter of using XInput and
then filling in the ‘which’ field. which == 0 would always be the primary
pointing device (tied to the cursor) and the others would just be raw input
devices.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment