From 8287149d9d35df96dedd83872fcc7e793ba26d98 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 26 Apr 2011 17:31:36 -0400 Subject: [PATCH] Added a driver name to the API. --- README.txt | 5 +++++ example/detect_mice.c | 1 + example/manymousepong.c | 1 + example/mmpong.c | 1 + example/test_manymouse_sdl.c | 1 + example/test_manymouse_stdio.c | 1 + linux_evdev.c | 1 + macosx_hidmanager.c | 1 + macosx_hidutilities.c | 1 + manymouse.c | 4 ++++ manymouse.h | 2 ++ windows_wminput.c | 1 + x11_xinput2.c | 1 + 13 files changed, 21 insertions(+) diff --git a/README.txt b/README.txt index 4788bf6..aee2051 100644 --- a/README.txt +++ b/README.txt @@ -25,6 +25,11 @@ Basic usage: - 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 diff --git a/example/detect_mice.c b/example/detect_mice.c index 82f6f65..cdcd755 100644 --- a/example/detect_mice.c +++ b/example/detect_mice.c @@ -23,6 +23,7 @@ int main(int argc, char **argv) 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)); } diff --git a/example/manymousepong.c b/example/manymousepong.c index 6203f94..add9a0f 100644 --- a/example/manymousepong.c +++ b/example/manymousepong.c @@ -178,6 +178,7 @@ static int initMice(void) else { int i; + printf("ManyMouse driver: %s\n", ManyMouse_DriverName()); for (i = 0; i < available_mice; i++) { const char *name = ManyMouse_DeviceName(i); diff --git a/example/mmpong.c b/example/mmpong.c index f0fc89c..7fd3ff6 100644 --- a/example/mmpong.c +++ b/example/mmpong.c @@ -114,6 +114,7 @@ static void init_mice(void) else { int i; + printf("ManyMouse driver: %s\n", ManyMouse_DriverName()); for (i = 0; i < available_mice; i++) { const char *name = ManyMouse_DeviceName(i); diff --git a/example/test_manymouse_sdl.c b/example/test_manymouse_sdl.c index 1948cd7..f118573 100644 --- a/example/test_manymouse_sdl.c +++ b/example/test_manymouse_sdl.c @@ -196,6 +196,7 @@ static void init_mice(void) else { int i; + printf("ManyMouse driver: %s\n", ManyMouse_DriverName()); for (i = 0; i < available_mice; i++) { const char *name = ManyMouse_DeviceName(i); diff --git a/example/test_manymouse_stdio.c b/example/test_manymouse_stdio.c index 665c1a6..c81b32e 100644 --- a/example/test_manymouse_stdio.c +++ b/example/test_manymouse_stdio.c @@ -29,6 +29,7 @@ int main(int argc, char **argv) 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)); } diff --git a/linux_evdev.c b/linux_evdev.c index d3e6a5e..01c065f 100644 --- a/linux_evdev.c +++ b/linux_evdev.c @@ -324,6 +324,7 @@ static int linux_evdev_poll(ManyMouseEvent *event) static const ManyMouseDriver ManyMouseDriver_interface = { + "Linux /dev/input/event interface", linux_evdev_init, linux_evdev_quit, linux_evdev_name, diff --git a/macosx_hidmanager.c b/macosx_hidmanager.c index be4dbfd..8dba860 100644 --- a/macosx_hidmanager.c +++ b/macosx_hidmanager.c @@ -410,6 +410,7 @@ static int macosx_hidmanager_poll(ManyMouseEvent *event) static const ManyMouseDriver ManyMouseDriver_interface = { + "Mac OS X 10.5+ HID Manager", macosx_hidmanager_init, macosx_hidmanager_quit, macosx_hidmanager_name, diff --git a/macosx_hidutilities.c b/macosx_hidutilities.c index bfcda4f..f6618f2 100644 --- a/macosx_hidutilities.c +++ b/macosx_hidutilities.c @@ -1658,6 +1658,7 @@ static int macosx_hidutilities_poll(ManyMouseEvent *event) static const ManyMouseDriver ManyMouseDriver_interface = { + "Mac OS X Legacy HID Utilities", macosx_hidutilities_init, macosx_hidutilities_quit, macosx_hidutilities_name, diff --git a/manymouse.c b/manymouse.c index c8ce7c5..9ca20ca 100644 --- a/manymouse.c +++ b/manymouse.c @@ -79,6 +79,10 @@ void ManyMouse_Quit(void) driver = NULL; } /* ManyMouse_Quit */ +const char *ManyMouse_DriverName(void) +{ + return ((driver) ? driver->driver_name : NULL); +} /* ManyMouse_DriverName */ const char *ManyMouse_DeviceName(unsigned int index) { diff --git a/manymouse.h b/manymouse.h index 338acae..0e7259c 100644 --- a/manymouse.h +++ b/manymouse.h @@ -39,6 +39,7 @@ typedef struct /* 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 @@ typedef struct 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); diff --git a/windows_wminput.c b/windows_wminput.c index ef0f5b3..085ee3d 100644 --- a/windows_wminput.c +++ b/windows_wminput.c @@ -698,6 +698,7 @@ static int windows_wminput_poll(ManyMouseEvent *ev) static const ManyMouseDriver ManyMouseDriver_interface = { + "Windows XP and later WM_INPUT interface", windows_wminput_init, windows_wminput_quit, windows_wminput_name, diff --git a/x11_xinput2.c b/x11_xinput2.c index 8df143d..7337e9f 100644 --- a/x11_xinput2.c +++ b/x11_xinput2.c @@ -513,6 +513,7 @@ static int x11_xinput2_poll(ManyMouseEvent *event) static const ManyMouseDriver ManyMouseDriver_interface = { + "X11 XInput2 extension", x11_xinput2_init, x11_xinput2_quit, x11_xinput2_name,