Mercurial > remote-gamepad-server
comparison ds.c @ 0:e70ea46d6073
Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 22 Feb 2015 01:38:06 +0100 |
parents | |
children | f362b20de51e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e70ea46d6073 |
---|---|
1 #include "ds.h" | |
2 #include "uinput.h" | |
3 #include <stdint.h> | |
4 #include <string.h> | |
5 | |
6 | |
7 #include <stdio.h> | |
8 | |
9 | |
10 /* | |
11 Throws events according to ds keys status | |
12 */ | |
13 void ds_process_evt(ds_t* ds, int uinput_fd){ | |
14 | |
15 static ds_t previous; | |
16 | |
17 /* Fear the evil copy/paste!! */ | |
18 | |
19 | |
20 /* BUTTONS: */ | |
21 if( !previous.A && ds->A ) /* pressed */ | |
22 do_uinput(uinput_fd, BTN_A, 1, EV_KEY); | |
23 else if( previous.A && !ds->A ) /* released */ | |
24 do_uinput(uinput_fd, BTN_A, 0, EV_KEY); | |
25 | |
26 | |
27 if( !previous.B && ds->B ) | |
28 do_uinput(uinput_fd, BTN_B, 1, EV_KEY); | |
29 else if( previous.B && !ds->B ) | |
30 do_uinput(uinput_fd, BTN_B, 0, EV_KEY); | |
31 | |
32 | |
33 if( !previous.X && ds->X ) | |
34 do_uinput(uinput_fd, BTN_X, 1, EV_KEY); | |
35 else if( previous.X && !ds->X ) | |
36 do_uinput(uinput_fd, BTN_X, 0, EV_KEY); | |
37 | |
38 | |
39 if( !previous.Y && ds->Y ) | |
40 do_uinput(uinput_fd, BTN_Y, 1, EV_KEY); | |
41 else if( previous.Y && !ds->Y ) | |
42 do_uinput(uinput_fd, BTN_Y, 0, EV_KEY); | |
43 | |
44 | |
45 if( !previous.L && ds->L ) | |
46 do_uinput(uinput_fd, BTN_TL, 1, EV_KEY); | |
47 else if( (previous.L) && !(ds->L) ) | |
48 do_uinput(uinput_fd, BTN_TL, 0, EV_KEY); | |
49 | |
50 | |
51 if( !previous.R && ds->R ) | |
52 do_uinput(uinput_fd, BTN_TR, 1, EV_KEY); | |
53 else if( previous.R && !ds->R ) | |
54 do_uinput(uinput_fd, BTN_TR, 0, EV_KEY); | |
55 | |
56 | |
57 if( !previous.Start && ds->Start ) | |
58 do_uinput(uinput_fd, BTN_START, 1, EV_KEY); | |
59 else if( previous.Start && !ds->Start ) | |
60 do_uinput(uinput_fd, BTN_START, 0, EV_KEY); | |
61 | |
62 | |
63 if( !previous.Select && ds->Select ) | |
64 do_uinput(uinput_fd, BTN_SELECT, 1, EV_KEY); | |
65 else if( previous.Select && !ds->Select ) | |
66 do_uinput(uinput_fd, BTN_SELECT, 0, EV_KEY); | |
67 | |
68 | |
69 /* DIRECTIONS */ | |
70 | |
71 if(previous.aX != ds->aX) | |
72 do_uinput(uinput_fd, ABS_X, ds->aX, EV_ABS); | |
73 | |
74 if(previous.aY != ds->aY) | |
75 do_uinput(uinput_fd, ABS_Y, ds->aY, EV_ABS); | |
76 | |
77 memcpy(&previous, ds, sizeof(ds_t)); | |
78 | |
79 return; | |
80 } |