input2gpio: minor mod

This commit is contained in:
Takashi Toyoshima 2017-05-27 02:39:34 +00:00
parent 6bb5dd95ce
commit 1638fbeecf
3 changed files with 15 additions and 7 deletions

View File

@ -177,7 +177,8 @@ void update(enum jamma_key key, int value) {
state &= ~(1 << key);
if (value)
state |= 1 << key;
for (int i = 11; i >= 0; --i)
int i;
for (i = 11; i >= 0; --i)
fprintf(stderr, "%d", (state >> i) & 1);
fprintf(stderr, "\n");
//#endif
@ -201,7 +202,8 @@ void do_bridge(int fd) {
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
struct gamepad* detected_gamepad = NULL;
for (int i = 0; i < sizeof(gamepads) / sizeof(struct gamepad); ++i) {
int i;
for (i = 0; i < sizeof(gamepads) / sizeof(struct gamepad); ++i) {
if (0 == strcmp(name, gamepads[i].name)) {
detected_gamepad = &gamepads[i];
fprintf(stderr, "known devide detected: %s\n", name);
@ -221,7 +223,8 @@ void do_bridge(int fd) {
if (detected_gamepad) {
int consumed = 0;
if (e.type == EV_KEY) {
for (int i = 0; i < sizeof(detected_gamepad->buttons) / sizeof(struct button); ++i) {
int i;
for (i = 0; i < sizeof(detected_gamepad->buttons) / sizeof(struct button); ++i) {
if (detected_gamepad->buttons[i].code != e.code)
continue;
consumed = 1;
@ -229,7 +232,8 @@ void do_bridge(int fd) {
break;
}
} else if (e.type == EV_ABS) {
for (int i = 0; i < sizeof(detected_gamepad->dpads) / sizeof(struct dpad); ++i) {
int i;
for (i = 0; i < sizeof(detected_gamepad->dpads) / sizeof(struct dpad); ++i) {
if (detected_gamepad->dpads[i].code != e.code)
continue;
consumed = 1;
@ -245,7 +249,7 @@ void do_bridge(int fd) {
}
break;
}
for (int i = 0; i < sizeof(detected_gamepad->buttons) / sizeof(struct button); ++i) {
for (i = 0; i < sizeof(detected_gamepad->buttons) / sizeof(struct button); ++i) {
if (detected_gamepad->buttons[i].code != e.code)
continue;
consumed = 1;
@ -257,7 +261,7 @@ void do_bridge(int fd) {
continue;
}
if (e.type == EV_KEY || e.type == EV_ABS)
printf("%04x: %04x, %d\n", e.type, e.code, e.value);
fprintf(stderr, "%04x: %04x, %d\n", e.type, e.code, e.value);
}
}

View File

@ -5,7 +5,7 @@ Before=sysinit.target
Conflicts=shutdown.target
[Service]
ExecStart=/opt/opipad/input2gpio
ExecStart=/opt/opipad/input2gpio.sh
ExecStop=killall input2gpio
Type=onshot
RemainAfterExit=yes

4
input2gpio.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
#/opt/opipad/input2gpio 2> /opt/opipad/input2gpio.log
/opt/opipad/input2gpio 2> /dev/null