Added a driver name to the API.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 Apr 2011 17:31:36 -0400
changeset 99 e6870ef5f9ea
parent 98 140608fa2200
child 100 daf6e389e4ee
Added a driver name to the API.
README.txt
example/detect_mice.c
example/manymousepong.c
example/mmpong.c
example/test_manymouse_sdl.c
example/test_manymouse_stdio.c
linux_evdev.c
macosx_hidmanager.c
macosx_hidutilities.c
manymouse.c
manymouse.h
windows_wminput.c
x11_xinput2.c
--- a/README.txt	Tue Apr 26 17:17:41 2011 -0400
+++ b/README.txt	Tue Apr 26 17:31:36 2011 -0400
@@ -25,6 +25,11 @@
  - Call ManyMouse_Init() once before using anything else in the library,
    usually at program startup time. If it returns > 0, it found mice it can
    use.
+ - Call ManyMouse_DriverName() if you want to know the human-readable
+   name of the driver that handles devices behind the scenes. Some platforms
+   have different drivers depending on the system being used. This is for
+   debugging purposes only: it is not localized and we don't promise they
+   won't change. The string is in UTF-8 format. Don't free this string.
  - Call ManyMouse_DeviceName() if you want to know the human-readable
    name of each device ("Logitech USB mouse", etc).
  - Read input from the mice with ManyMouse_PollEvent() in a loop until the
--- a/example/detect_mice.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/example/detect_mice.c	Tue Apr 26 17:31:36 2011 -0400
@@ -23,6 +23,7 @@
     else
     {
         int i;
+        printf("ManyMouse driver: %s\n", ManyMouse_DriverName());
         for (i = 0; i < available_mice; i++)
             printf("#%d: %s\n", i, ManyMouse_DeviceName(i));
     }
--- a/example/manymousepong.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/example/manymousepong.c	Tue Apr 26 17:31:36 2011 -0400
@@ -178,6 +178,7 @@
     else
     {
         int i;
+        printf("ManyMouse driver: %s\n", ManyMouse_DriverName());
         for (i = 0; i < available_mice; i++)
         {
             const char *name = ManyMouse_DeviceName(i);
--- a/example/mmpong.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/example/mmpong.c	Tue Apr 26 17:31:36 2011 -0400
@@ -114,6 +114,7 @@
     else
     {
         int i;
+        printf("ManyMouse driver: %s\n", ManyMouse_DriverName());
         for (i = 0; i < available_mice; i++)
         {
             const char *name = ManyMouse_DeviceName(i);
--- a/example/test_manymouse_sdl.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/example/test_manymouse_sdl.c	Tue Apr 26 17:31:36 2011 -0400
@@ -196,6 +196,7 @@
     else
     {
         int i;
+        printf("ManyMouse driver: %s\n", ManyMouse_DriverName());
         for (i = 0; i < available_mice; i++)
         {
             const char *name = ManyMouse_DeviceName(i);
--- a/example/test_manymouse_stdio.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/example/test_manymouse_stdio.c	Tue Apr 26 17:31:36 2011 -0400
@@ -29,6 +29,7 @@
     else
     {
         int i;
+        printf("ManyMouse driver: %s\n", ManyMouse_DriverName());
         for (i = 0; i < available_mice; i++)
             printf("#%d: %s\n", i, ManyMouse_DeviceName(i));
     }
--- a/linux_evdev.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/linux_evdev.c	Tue Apr 26 17:31:36 2011 -0400
@@ -324,6 +324,7 @@
 
 static const ManyMouseDriver ManyMouseDriver_interface =
 {
+    "Linux /dev/input/event interface",
     linux_evdev_init,
     linux_evdev_quit,
     linux_evdev_name,
--- a/macosx_hidmanager.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/macosx_hidmanager.c	Tue Apr 26 17:31:36 2011 -0400
@@ -410,6 +410,7 @@
 
 static const ManyMouseDriver ManyMouseDriver_interface =
 {
+    "Mac OS X 10.5+ HID Manager",
     macosx_hidmanager_init,
     macosx_hidmanager_quit,
     macosx_hidmanager_name,
--- a/macosx_hidutilities.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/macosx_hidutilities.c	Tue Apr 26 17:31:36 2011 -0400
@@ -1658,6 +1658,7 @@
 
 static const ManyMouseDriver ManyMouseDriver_interface =
 {
+    "Mac OS X Legacy HID Utilities",
     macosx_hidutilities_init,
     macosx_hidutilities_quit,
     macosx_hidutilities_name,
--- a/manymouse.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/manymouse.c	Tue Apr 26 17:31:36 2011 -0400
@@ -79,6 +79,10 @@
     driver = NULL;
 } /* ManyMouse_Quit */
 
+const char *ManyMouse_DriverName(void)
+{
+    return ((driver) ? driver->driver_name : NULL);
+} /* ManyMouse_DriverName */
 
 const char *ManyMouse_DeviceName(unsigned int index)
 {
--- a/manymouse.h	Tue Apr 26 17:17:41 2011 -0400
+++ b/manymouse.h	Tue Apr 26 17:31:36 2011 -0400
@@ -39,6 +39,7 @@
 /* internal use only. */
 typedef struct
 {
+    const char *driver_name;
     int (*init)(void);
     void (*quit)(void);
     const char *(*name)(unsigned int index);
@@ -47,6 +48,7 @@
 
 
 int ManyMouse_Init(void);
+const char *ManyMouse_DriverName(void);
 void ManyMouse_Quit(void);
 const char *ManyMouse_DeviceName(unsigned int index);
 int ManyMouse_PollEvent(ManyMouseEvent *event);
--- a/windows_wminput.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/windows_wminput.c	Tue Apr 26 17:31:36 2011 -0400
@@ -698,6 +698,7 @@
 
 static const ManyMouseDriver ManyMouseDriver_interface =
 {
+    "Windows XP and later WM_INPUT interface",
     windows_wminput_init,
     windows_wminput_quit,
     windows_wminput_name,
--- a/x11_xinput2.c	Tue Apr 26 17:17:41 2011 -0400
+++ b/x11_xinput2.c	Tue Apr 26 17:31:36 2011 -0400
@@ -513,6 +513,7 @@
 
 static const ManyMouseDriver ManyMouseDriver_interface =
 {
+    "X11 XInput2 extension",
     x11_xinput2_init,
     x11_xinput2_quit,
     x11_xinput2_name,