-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevdevtest.c
75 lines (55 loc) · 1.85 KB
/
evdevtest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "pnd_device.h"
#include "pnd_io_evdev.h"
int main ( void ) {
if ( ! pnd_evdev_open ( pnd_evdev_dpads ) ) {
printf ( "Couldn't open dpads\n" );
exit ( 0 );
}
if ( ! pnd_evdev_open ( pnd_evdev_nub1 ) ) {
printf ( "Couldn't open nub1\n" );
exit ( 0 );
}
if ( ! pnd_evdev_open ( pnd_evdev_nub2 ) ) {
printf ( "Couldn't open nub2\n" );
exit ( 0 );
}
while ( 1 ) {
// poll and process
if ( ! pnd_evdev_catchup ( 1 /* block */ ) ) {
printf ( "Couldn't catch up events\n" );
exit ( 0 );
}
// check state
int s;
s = pnd_evdev_dpad_state ( pnd_evdev_dpads );
if ( s & pnd_evdev_up ) { printf ( "d-pad up\n" ); }
if ( s & pnd_evdev_down ) { printf ( "d-pad down\n" ); }
if ( s & pnd_evdev_left ) { printf ( "d-pad left\n" ); }
if ( s & pnd_evdev_right ) { printf ( "d-pad right\n" ); }
if ( s & pnd_evdev_x ) { printf ( "d-pad x\n" ); }
if ( s & pnd_evdev_y ) { printf ( "d-pad y\n" ); }
if ( s & pnd_evdev_a ) { printf ( "d-pad a\n" ); }
if ( s & pnd_evdev_b ) { printf ( "d-pad b\n" ); }
if ( s & pnd_evdev_ltrigger ) { printf ( "d-pad ltrigger\n" ); }
if ( s & pnd_evdev_rtrigger ) { printf ( "d-pad rtrigger\n" ); }
if ( s & pnd_evdev_start ) { printf ( "d-pad start\n" ); }
if ( s & pnd_evdev_select ) { printf ( "d-pad select\n" ); }
if ( s & pnd_evdev_pandora ) { printf ( "d-pad pandora\n" ); }
pnd_nubstate_t ns;
pnd_evdev_nub_state ( pnd_evdev_nub1, &ns );
if ( ns.x || ns.y ) {
printf ( "ns1 x / y: %d / %d\n", ns.x, ns.y );
}
pnd_evdev_nub_state ( pnd_evdev_nub2, &ns );
if ( ns.x || ns.y ) {
printf ( "ns2 x / y: %d / %d\n", ns.x, ns.y );
}
// sleep
//usleep ( 500000 );
} // while
pnd_evdev_closeall();
return ( 0 );
}