I found some information in the development version of the XInput
extension documentation
(
http://cgit.freedesktop.org/xorg/lib/libXi/tree/man/XI.xml):“A master pointer is a virtual pointer device that does not
represent a physical device. It is visually represented through a
cursor. A master keyboard is a virtual keyboard device that does
not represent a physical device. It is virtually representd
through a keyboard focus. A master pointer and a master keyboard
are always paired (i.e. if shift is pressed on the master
keyboard, a pointer click would be a shift-click). Multiple master
pointer/keyboard pairs can exist.
Physical devices (so-called slave devices) are attached to either
a master pointer or a master keyboard, depending on their
capabilities. If a slave device generates an event, the event is
also generated by the respective master device. Multiple slave
devices can be attached to a single master device.”
This is what I had roughly guessed. The attached patch should fix
the problem for Xorg 7.3. The returned value is the number of buttons
found by the X server and written in /var/log/Xorg.0.log. By the way,
this number is too big: 9 for a three button mouse and 11 for a five
button one. I suppose the wheel is seen as two buttons, but there is
still an excess of four buttons.
--
Jocelyn Fréchot
Index: src/freeglut_state.c
===================================================================
--- src/freeglut_state.c (révision 741)
+++ src/freeglut_state.c (copie de travail)
@@ -583,19 +583,83 @@
return 1 ;
case GLUT_NUM_MOUSE_BUTTONS:
- /* We should be able to pass NULL when the last argument is zero,
- * but at least one X server has a bug where this causes a segfault.
- *
- * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
- * rather than an Axis; "freeglut_main.c" expects this when
- * checking for a wheel event.
- */
- {
- unsigned char map;
- int nbuttons = XGetPointerMapping(fgDisplay.Display, &map,0);
- return nbuttons;
- }
+ /*
+ * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
+ * rather than an Axis; "freeglut_main.c" expects this when
+ * checking for a wheel event.
+ */
+ {
+ XExtensionVersion * version;
+ /*
+ * To be checked in future release: XGetExtensionVersion() seems to be
+ * replaced by XQueryInputVersion() in development version of
+ * XInputExtension.
+ */
+ version = XGetExtensionVersion(fgDisplay.Display, "XInputExtension");
+
+ if ((version->present == True) &&
+ (version->major_version == 1) &&
+ (version->minor_version >= 4))
+ {
+ XDeviceInfo * device_infos;
+ int num_devices;
+ int num_buttons;
+ size_t i, j;
+
+
+ device_infos = XListInputDevices(fgDisplay.Display, &num_devices);
+
+ num_buttons = -1;
+ for (i = 0u; i < num_devices; i++)
+ {
+ XDeviceInfo * current_info = device_infos + i;
+
+ if (current_info->use == IsXExtensionPointer)
+ {
+ for (j = 0u; j < current_info->num_classes; j++)
+ {
+ if (current_info->inputclassinfo[j].class
+ == ButtonClass)
+ {
+ const XButtonInfo * button_info =
+ (XButtonInfo *) current_info->inputclassinfo + j;
+
+ num_buttons = button_info->num_buttons;
+
+ break;
+ }
+ }
+
+ if (num_buttons > -1)
+ {
+ break;
+ }
+ }
+ }
+
+ XFreeDeviceList(device_infos);
+
+ if (num_buttons > -1)
+ {
+ return num_buttons;
+ }
+ }
+ else
+ {
+ /*
+ * We should be able to pass NULL when the last argument is zero,
+ * but at least one X server has a bug where this causes a segfault.
+ */
+ unsigned char map;
+ int nbuttons = XGetPointerMapping(fgDisplay.Display, &map, 0);
+ return nbuttons;
+ }
+
+ XFree(version);
+ }
+ break;
+
#elif TARGET_HOST_MS_WINDOWS
case GLUT_HAS_MOUSE:
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer