Skip to content

Latest commit

 

History

History
87 lines (67 loc) · 2.09 KB

manymouse.c

File metadata and controls

87 lines (67 loc) · 2.09 KB
 
Jun 27, 2005
Jun 27, 2005
1
/*
Jun 27, 2005
Jun 27, 2005
2
* ManyMouse foundation code; apps talks to this and it talks to the lowlevel
Jun 27, 2005
Jun 27, 2005
3
4
5
6
7
8
* code for various platforms.
*
* Please see the file LICENSE in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
Jun 26, 2005
Jun 26, 2005
10
#include <stdlib.h>
Jun 27, 2005
Jun 27, 2005
11
#include "manymouse.h"
Jun 28, 2005
Jun 28, 2005
13
static const char *manymouse_copyright =
Jul 27, 2007
Jul 27, 2007
14
"ManyMouse " MANYMOUSE_VERSION " copyright (c) 2005-2007 Ryan C. Gordon.";
Jun 28, 2005
Jun 28, 2005
15
Jul 27, 2007
Jul 27, 2007
16
17
18
19
extern const ManyMouseDriver *ManyMouseDriver_windows;
extern const ManyMouseDriver *ManyMouseDriver_evdev;
extern const ManyMouseDriver *ManyMouseDriver_hidmanager;
extern const ManyMouseDriver *ManyMouseDriver_xinput;
Jul 27, 2007
Jul 27, 2007
21
static const ManyMouseDriver **mice_drivers[] =
Jun 27, 2005
Jun 27, 2005
23
24
&ManyMouseDriver_xinput,
&ManyMouseDriver_evdev,
Mar 24, 2006
Mar 24, 2006
25
&ManyMouseDriver_windows,
Jun 27, 2005
Jun 27, 2005
26
&ManyMouseDriver_hidmanager,
Jun 27, 2005
Jun 27, 2005
30
static const ManyMouseDriver *driver = NULL;
Jun 27, 2005
Jun 27, 2005
32
int ManyMouse_Init(void)
Jul 27, 2007
Jul 27, 2007
34
const int upper = (sizeof (mice_drivers) / sizeof (mice_drivers[0]));
Mar 24, 2006
Mar 24, 2006
36
int retval = -1;
Jun 28, 2005
Jun 28, 2005
38
/* impossible test to keep manymouse_copyright linked into the binary. */
Mar 24, 2006
Mar 24, 2006
39
if (manymouse_copyright == NULL)
Jun 28, 2005
Jun 28, 2005
40
41
return(-1);
42
43
44
if (driver != NULL)
return(-1);
Jul 27, 2007
Jul 27, 2007
45
for (i = 0; (i < upper) && (driver == NULL); i++)
Jul 27, 2007
Jul 27, 2007
47
48
const ManyMouseDriver *this_driver = *(mice_drivers[i]);
if (this_driver != NULL) /* if not built for this platform, skip it. */
Jul 27, 2007
Jul 27, 2007
50
51
52
53
54
55
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;
56
57
58
} /* if */
} /* for */
Mar 24, 2006
Mar 24, 2006
59
return(retval);
Jun 27, 2005
Jun 27, 2005
60
} /* ManyMouse_Init */
Jun 27, 2005
Jun 27, 2005
63
void ManyMouse_Quit(void)
64
65
66
67
{
if (driver != NULL)
driver->quit();
driver = NULL;
Jun 27, 2005
Jun 27, 2005
68
} /* ManyMouse_Quit */
Jun 27, 2005
Jun 27, 2005
71
const char *ManyMouse_DeviceName(unsigned int index)
Jun 26, 2005
Jun 26, 2005
72
73
74
75
{
if (driver != NULL)
return(driver->name(index));
return(NULL);
Jun 27, 2005
Jun 27, 2005
76
} /* ManyMouse_PollEvent */
Jun 26, 2005
Jun 26, 2005
77
78
Jun 27, 2005
Jun 27, 2005
79
int ManyMouse_PollEvent(ManyMouseEvent *event)
80
81
82
83
{
if (driver != NULL)
return(driver->poll(event));
return(0);
Jun 27, 2005
Jun 27, 2005
84
} /* ManyMouse_PollEvent */
Jun 27, 2005
Jun 27, 2005
86
/* end of manymouse.c ... */