mirror of
https://github.com/toyoshim/opipad.git
synced 2024-11-29 07:03:02 +00:00
input2gpio: minor mod
This commit is contained in:
parent
6bb5dd95ce
commit
1638fbeecf
16
input2gpio.c
16
input2gpio.c
@ -177,7 +177,8 @@ void update(enum jamma_key key, int value) {
|
|||||||
state &= ~(1 << key);
|
state &= ~(1 << key);
|
||||||
if (value)
|
if (value)
|
||||||
state |= 1 << key;
|
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, "%d", (state >> i) & 1);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
//#endif
|
//#endif
|
||||||
@ -201,7 +202,8 @@ void do_bridge(int fd) {
|
|||||||
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
|
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
|
||||||
|
|
||||||
struct gamepad* detected_gamepad = NULL;
|
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)) {
|
if (0 == strcmp(name, gamepads[i].name)) {
|
||||||
detected_gamepad = &gamepads[i];
|
detected_gamepad = &gamepads[i];
|
||||||
fprintf(stderr, "known devide detected: %s\n", name);
|
fprintf(stderr, "known devide detected: %s\n", name);
|
||||||
@ -221,7 +223,8 @@ void do_bridge(int fd) {
|
|||||||
if (detected_gamepad) {
|
if (detected_gamepad) {
|
||||||
int consumed = 0;
|
int consumed = 0;
|
||||||
if (e.type == EV_KEY) {
|
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)
|
if (detected_gamepad->buttons[i].code != e.code)
|
||||||
continue;
|
continue;
|
||||||
consumed = 1;
|
consumed = 1;
|
||||||
@ -229,7 +232,8 @@ void do_bridge(int fd) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (e.type == EV_ABS) {
|
} 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)
|
if (detected_gamepad->dpads[i].code != e.code)
|
||||||
continue;
|
continue;
|
||||||
consumed = 1;
|
consumed = 1;
|
||||||
@ -245,7 +249,7 @@ void do_bridge(int fd) {
|
|||||||
}
|
}
|
||||||
break;
|
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)
|
if (detected_gamepad->buttons[i].code != e.code)
|
||||||
continue;
|
continue;
|
||||||
consumed = 1;
|
consumed = 1;
|
||||||
@ -257,7 +261,7 @@ void do_bridge(int fd) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (e.type == EV_KEY || e.type == EV_ABS)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ Before=sysinit.target
|
|||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/opt/opipad/input2gpio
|
ExecStart=/opt/opipad/input2gpio.sh
|
||||||
ExecStop=killall input2gpio
|
ExecStop=killall input2gpio
|
||||||
Type=onshot
|
Type=onshot
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
4
input2gpio.sh
Executable file
4
input2gpio.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#/opt/opipad/input2gpio 2> /opt/opipad/input2gpio.log
|
||||||
|
/opt/opipad/input2gpio 2> /dev/null
|
Loading…
Reference in New Issue
Block a user