8424752c |
1 | /* |
2 | * GINGE - GINGE Is Not Gp2x Emulator |
3 | * (C) notaz, 2010-2011,2015 |
4 | * |
5 | * This work is licensed under the MAME license, see COPYING file for details. |
6 | */ |
15a2d3ea |
7 | #define _GNU_SOURCE 1 // for plat.c |
ad439e71 |
8 | #include <stdio.h> |
9 | #include <stdarg.h> |
8424752c |
10 | #include <linux/input.h> |
11 | |
12 | #include "../common/libpicofe/input.h" |
13 | #include "../common/libpicofe/linux/in_evdev.h" |
ad439e71 |
14 | |
15 | #include "header.h" |
16 | #include "realfuncs.h" |
17 | |
ad439e71 |
18 | #ifdef PND |
19 | #include "host_pnd.c" |
20 | #elif defined(WIZ) |
21 | #include "host_wiz.c" |
22 | #endif |
23 | |
24 | // for plat.c |
25 | char **g_argv; |
26 | |
27 | int host_init(void) |
28 | { |
29 | in_init(); |
8424752c |
30 | host_init_input(); |
ad439e71 |
31 | in_probe(); |
32 | |
33 | return 0; |
34 | } |
35 | |
36 | int host_read_btns(void) |
37 | { |
38 | int actions[IN_BINDTYPE_COUNT] = { 0, }; |
39 | |
40 | in_update(actions); |
41 | host_actions(actions); |
42 | |
43 | return actions[IN_BINDTYPE_PLAYER12]; |
44 | } |
45 | |
46 | void host_forced_exit(void) |
47 | { |
48 | // exit() might not be enough because loader and app data is out of sync, |
49 | // and other threads (which are really processes on this old glibc used) |
50 | // might not exit properly. |
7d4e5f81 |
51 | char cmd[64]; |
52 | |
53 | printf("forced exit...\n"); |
54 | |
55 | snprintf(cmd, sizeof(cmd), "killall %s", g_argv[0]); |
56 | system(cmd); |
ad439e71 |
57 | usleep(300000); |
7d4e5f81 |
58 | snprintf(cmd, sizeof(cmd), "killall -9 %s", g_argv[0]); |
59 | system(cmd); |
ad439e71 |
60 | exit(1); |
61 | } |
8424752c |
62 | |
63 | // vim:shiftwidth=2:expandtab |