Skip to content

Commit

Permalink
Cleaned up the backend interface a little, so you don't have to expor…
Browse files Browse the repository at this point in the history
…t stub

 functions for all platforms, just a single NULL pointer for each.
  • Loading branch information
icculus committed Jul 27, 2007
1 parent 993bcf6 commit 70369ff
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 58 deletions.
17 changes: 7 additions & 10 deletions linux_evdev.c
Expand Up @@ -322,22 +322,19 @@ static int linux_evdev_poll(ManyMouseEvent *event)
return(0); /* no new events */
} /* linux_evdev_poll */

#else

static int linux_evdev_init(void) { return(-1); }
static void linux_evdev_quit(void) {}
static const char *linux_evdev_name(unsigned int index) { return(0); }
static int linux_evdev_poll(ManyMouseEvent *event) { return(0); }

#endif /* defined __linux__ */

ManyMouseDriver ManyMouseDriver_evdev =
static const ManyMouseDriver ManyMouseDriver_interface =
{
linux_evdev_init,
linux_evdev_quit,
linux_evdev_name,
linux_evdev_poll
};

const ManyMouseDriver *ManyMouseDriver_evdev = &ManyMouseDriver_interface;

#else
const ManyMouseDriver *ManyMouseDriver_evdev = 0;
#endif /* ifdef Linux blocker */

/* end of linux_evdev.c ... */

17 changes: 7 additions & 10 deletions macosx_hidmanager.c
Expand Up @@ -1649,22 +1649,19 @@ static int macosx_hidmanager_poll(ManyMouseEvent *event)
return(0); /* no new events */
} /* macosx_hidmanager_poll */

#else

static int macosx_hidmanager_init(void) { return(-1); }
static void macosx_hidmanager_quit(void) {}
static const char *macosx_hidmanager_name(unsigned int index) { return(0); }
static int macosx_hidmanager_poll(ManyMouseEvent *event) { return(0); }

#endif /* MacOSX blocker */

ManyMouseDriver ManyMouseDriver_hidmanager =
static const ManyMouseDriver ManyMouseDriver_interface =
{
macosx_hidmanager_init,
macosx_hidmanager_quit,
macosx_hidmanager_name,
macosx_hidmanager_poll
};

const ManyMouseDriver *ManyMouseDriver_hidmanager = &ManyMouseDriver_interface;

#else
const ManyMouseDriver *ManyMouseDriver_hidmanager = 0;
#endif /* ifdef Mac OS X blocker */

/* end of macosx_hidmanager.c ... */

32 changes: 16 additions & 16 deletions manymouse.c
Expand Up @@ -11,27 +11,27 @@
#include "manymouse.h"

static const char *manymouse_copyright =
"ManyMouse " MANYMOUSE_VERSION " (c) 2005 Ryan C. Gordon.";
"ManyMouse " MANYMOUSE_VERSION " copyright (c) 2005-2007 Ryan C. Gordon.";

extern const ManyMouseDriver ManyMouseDriver_windows;
extern const ManyMouseDriver ManyMouseDriver_evdev;
extern const ManyMouseDriver ManyMouseDriver_hidmanager;
extern const ManyMouseDriver ManyMouseDriver_xinput;
extern const ManyMouseDriver *ManyMouseDriver_windows;
extern const ManyMouseDriver *ManyMouseDriver_evdev;
extern const ManyMouseDriver *ManyMouseDriver_hidmanager;
extern const ManyMouseDriver *ManyMouseDriver_xinput;

static const ManyMouseDriver *mice_drivers[] =
static const ManyMouseDriver **mice_drivers[] =
{
&ManyMouseDriver_xinput,
&ManyMouseDriver_evdev,
&ManyMouseDriver_windows,
&ManyMouseDriver_hidmanager,
NULL
};


static const ManyMouseDriver *driver = NULL;

int ManyMouse_Init(void)
{
const int upper = (sizeof (mice_drivers) / sizeof (mice_drivers[0]));
int i;
int retval = -1;

Expand All @@ -42,17 +42,17 @@ int ManyMouse_Init(void)
if (driver != NULL)
return(-1);

for (i = 0; mice_drivers[i]; i++)
for (i = 0; (i < upper) && (driver == NULL); i++)
{
int mice = mice_drivers[i]->init();

if (mice > retval)
retval = mice; /* may just move from "error" to "no mice found". */

if (mice > 0)
const ManyMouseDriver *this_driver = *(mice_drivers[i]);
if (this_driver != NULL) /* if not built for this platform, skip it. */
{
driver = mice_drivers[i];
break;
const int mice = this_driver->init();
if (mice > retval)
retval = mice; /* may move from "error" to "no mice found". */

if (mice > 0)
driver = this_driver;
} /* if */
} /* for */

Expand Down
17 changes: 7 additions & 10 deletions windows_wminput.c
Expand Up @@ -719,22 +719,19 @@ static int windows_wminput_poll(ManyMouseEvent *ev)
return(found);
} /* windows_wminput_poll */

#else

static int windows_wminput_init(void) { return(-1); }
static void windows_wminput_quit(void) {}
static const char *windows_wminput_name(unsigned int index) { return(0); }
static int windows_wminput_poll(ManyMouseEvent *event) { return(0); }

#endif /* ifdef WINDOWS blocker */

ManyMouseDriver ManyMouseDriver_windows =
static const ManyMouseDriver ManyMouseDriver_interface =
{
windows_wminput_init,
windows_wminput_quit,
windows_wminput_name,
windows_wminput_poll
};

const ManyMouseDriver *ManyMouseDriver_windows = &ManyMouseDriver_interface;

#else
const ManyMouseDriver *ManyMouseDriver_windows = 0;
#endif /* ifdef Windows blocker */

/* end of windows_wminput.c ... */

19 changes: 7 additions & 12 deletions x11_xinput.c
Expand Up @@ -313,24 +313,19 @@ static int x11_xinput_poll(ManyMouseEvent *event)
return(0); /* !!! FIXME */
} /* x11_xinput_poll */


#else

static int x11_xinput_init(void) { return(-1); }
static void x11_xinput_quit(void) {}
static const char *x11_xinput_name(unsigned int index) { return(0); }
static int x11_xinput_poll(ManyMouseEvent *event) { return(0); }

#endif /* SUPPORT_XINPUT blocker */


ManyMouseDriver ManyMouseDriver_xinput =
static const ManyMouseDriver ManyMouseDriver_interface =
{
x11_xinput_init,
x11_xinput_quit,
x11_xinput_name,
x11_xinput_poll
};

const ManyMouseDriver *ManyMouseDriver_xinput = &ManyMouseDriver_interface;

#else
const ManyMouseDriver *ManyMouseDriver_xinput = 0;
#endif /* SUPPORT_XINPUT blocker */

/* end of x11_xinput.c ... */

0 comments on commit 70369ff

Please sign in to comment.