Skip to content

Latest commit

 

History

History
95 lines (83 loc) · 2.56 KB

test_manymouse_stdio.c

File metadata and controls

95 lines (83 loc) · 2.56 KB
 
Jun 27, 2005
Jun 27, 2005
2
* A test file for ManyMouse that dumps input data to stdout.
Jul 28, 2008
Jul 28, 2008
4
* Please see the file LICENSE.txt in the source's root directory.
5
6
7
8
9
10
11
12
*
* This file written by Ryan C. Gordon.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Jun 27, 2005
Jun 27, 2005
13
#include "manymouse.h"
14
15
16
int main(int argc, char **argv)
{
Jun 27, 2005
Jun 27, 2005
17
18
ManyMouseEvent event;
int available_mice = ManyMouse_Init();
Mar 24, 2006
Mar 24, 2006
19
20
21
22
23
24
if (available_mice < 0)
{
printf("Error initializing ManyMouse!\n");
return(2);
}
else if (available_mice == 0)
25
26
27
28
29
30
31
{
printf("No mice detected!\n");
return(1);
}
else
{
int i;
Apr 26, 2011
Apr 26, 2011
32
printf("ManyMouse driver: %s\n", ManyMouse_DriverName());
33
for (i = 0; i < available_mice; i++)
Jun 27, 2005
Jun 27, 2005
34
printf("#%d: %s\n", i, ManyMouse_DeviceName(i));
35
36
37
38
39
40
}
printf("\n");
printf("Use your mice, CTRL-C to exit.\n");
while (1)
{
Jun 27, 2005
Jun 27, 2005
41
while (ManyMouse_PollEvent(&event))
Jun 27, 2005
Jun 27, 2005
43
if (event.type == MANYMOUSE_EVENT_RELMOTION)
44
45
46
47
48
{
printf("Mouse #%u relative motion %s %d\n", event.device,
event.item == 0 ? "X" : "Y", event.value);
}
Jun 27, 2005
Jun 27, 2005
49
else if (event.type == MANYMOUSE_EVENT_ABSMOTION)
50
51
52
53
54
{
printf("Mouse #%u absolute motion %s %d\n", event.device,
event.item == 0 ? "X" : "Y", event.value);
}
Jun 27, 2005
Jun 27, 2005
55
else if (event.type == MANYMOUSE_EVENT_BUTTON)
56
57
58
59
60
{
printf("Mouse #%u button %u %s\n", event.device,
event.item, event.value ? "down" : "up");
}
Jun 27, 2005
Jun 27, 2005
61
else if (event.type == MANYMOUSE_EVENT_SCROLL)
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
const char *wheel;
const char *direction;
if (event.item == 0)
{
wheel = "vertical";
direction = ((event.value > 0) ? "up" : "down");
}
else
{
wheel = "horizontal";
direction = ((event.value > 0) ? "right" : "left");
}
printf("Mouse #%u wheel %s %s\n", event.device,
wheel, direction);
}
Jun 27, 2005
Jun 27, 2005
79
else if (event.type == MANYMOUSE_EVENT_DISCONNECT)
80
81
82
83
84
85
86
87
88
89
printf("Mouse #%u disconnect\n", event.device);
else
{
printf("Mouse #%u unhandled event type %d\n", event.device,
event.type);
}
}
}
Jun 27, 2005
Jun 27, 2005
90
ManyMouse_Quit();
91
92
93
return(0);
}
Jun 27, 2005
Jun 27, 2005
94
/* end of test_manymouse_stdio.c ... */