Skip to content

Commit

Permalink
Added a driver name to the API.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 26, 2011
1 parent 3496eec commit 8287149
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.txt
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions example/detect_mice.c
Expand Up @@ -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));
}
Expand Down
1 change: 1 addition & 0 deletions example/manymousepong.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions example/mmpong.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions example/test_manymouse_sdl.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions example/test_manymouse_stdio.c
Expand Up @@ -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));
}
Expand Down
1 change: 1 addition & 0 deletions linux_evdev.c
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions macosx_hidmanager.c
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions macosx_hidutilities.c
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions manymouse.c
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions manymouse.h
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions windows_wminput.c
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions x11_xinput2.c
Expand Up @@ -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,
Expand Down

0 comments on commit 8287149

Please sign in to comment.