libSDL: different IDs for two USB-mouses?

Hello,

I have two USB mouses connected to my linux box. Is there
a way to check inside a SDL application which mouse was
pressed? (may be under the win32 version of SDL?)

When I trace down the code of src/video/x11/SDL_x11events.c
and add two lines at line 278 like:

         XDeviceButtonEvent *be = &xevent;
         printf ("dev=%d\n", be->deviceid);

I allways see the same deviceID!?

So, for me it looks like even in the X11 core routines there
is no way to figure out which mouse was pressed, isn’t it!

thx + cu
rasca–


| Triad Berlin Projektgesellschaft mbH | http://www.triad.de/ |

So, for me it looks like even in the X11 core routines there
is no way to figure out which mouse was pressed, isn’t it!

Chances are, you’re using /dev/input/mice, which blends all USB mouse
input into one logical device (partially so that mouse input in the X
server continues to work as you plug and unplug mice).

I don’t know if there’s a better solution for this under X11 at the
moment. Someone else might know, though.

–ryan.

Well, it’s obviously possible, since for example the Gimp is able to
automagically change tool and settings based on what input device is
active (ie each mouse, tablet device, etc has its own settings). In
multiple-device ignorant apps, everything just works as a regular mouse.

For this to work, X has to be aware of all input devices you want to
use, so you’ve got to have an InputDevice section for each input device
in XF86Config or xorg.conf. I’ve got mouse on /dev/input/mouse0, and
tablet devices (cursor, stylus and mouse) on /dev/input/event2, for
example. Even though three of these are on event2, this gives me 4
different device IDs that can be used independently in the Gimp, so it
seems the ID doesn’t actually rely on device.

I don’t know how to use this, but since GTK+ seems to do it right, that
might be a good place to start looking.

Funny someone should bring this up now, I just thought about the
possibilities of using two mice in a game yesterday =).

Btw, anyone know if there’s any plans for multiple device support in SDL
1.3 or 2 ?

  • Gerry

Hi,

Gerry wrote:

Well, it’s obviously possible, since for example the Gimp is able to
automagically change tool and settings based on what input device is
active (ie each mouse, tablet device, etc has its own settings). In
multiple-device ignorant apps, everything just works as a regular mouse.

That are good news. Just in general: same situation in the Win32
(Win2K, …) OSes?

For this to work, X has to be aware of all input devices you want to
use, so you’ve got to have an InputDevice section for each input device
in XF86Config or xorg.conf. I’ve got mouse on /dev/input/mouse0, and
tablet devices (cursor, stylus and mouse) on /dev/input/event2, for
example. Even though three of these are on event2, this gives me 4
different device IDs that can be used independently in the Gimp, so it
seems the ID doesn’t actually rely on device.

Here I had no success: a mouse definition with /dev/input/event2
fails, cause the mouse is not recognized.

Then I tried three mouse section in the XF86Config:

Mouse[0] with /dev/mouse (ps2)
Mouse[1] with /dev/mouse0 (usb)
Mouse[2] with /dev/mouse1 (usb)

The there mouses are recogniced and are working but all of them
have the same ID (here: 72). Any ideas?

I don’t know how to use this, but since GTK+ seems to do it right, that
might be a good place to start looking.

That are not good news. Gtk+/Gimp is not a small application
which I can use to browse and understand the source code…

Funny someone should bring this up now, I just thought about the
possibilities of using two mice in a game yesterday =).

That’s what I’m working on… but without success until now :frowning:

Btw, anyone know if there’s any plans for multiple device support in SDL
1.3 or 2 ?

As long as I see there is at least a field in the
SDL_MouseButtonEvent structure (SDL_events.h:
event->which /* the mouse device index */).

May be someone can fill it with live :slight_smile:

cu
rasca–


| Triad Berlin Projektgesellschaft mbH | http://www.triad.de/ |

Rasca wrote:

I have two USB mouses connected to my linux box. Is there
a way to check inside a SDL application which mouse was
pressed? (may be under the win32 version of SDL?)

Can somone tell me which part of the source is the
one which is used under Windows 2000?
src/video/win???

And: is there a way to get the deviceID under
windows out of these strange wParm / lParm…!?

Last but not least: What’s the best way to keep
compatibility with older apps when changing
the lib? Adding a new function? - like:

SDL_PrivateMouseButtonExt (…, … ,… int id);

cu
rasca–


| Triad Berlin Projektgesellschaft mbH | http://www.triad.de/ |