handle another palette write
[ginge.git] / loader / host.c
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  */
7 #define _GNU_SOURCE 1 // for plat.c
8 #include <stdio.h>
9 #include <stdarg.h>
10 #include <linux/input.h>
11
12 #include "../common/libpicofe/input.h"
13 #include "../common/libpicofe/linux/in_evdev.h"
14
15 #include "header.h"
16 #include "realfuncs.h"
17
18 // must be affected by realfuncs.h
19 #include "../common/libpicofe/input.c"
20 #include "../common/libpicofe/linux/plat.c"
21 #include "../common/libpicofe/linux/in_evdev.c"
22
23 #ifdef PND
24 #include "host_pnd.c"
25 #elif defined(WIZ)
26 #include "host_wiz.c"
27 #endif
28
29 // for plat.c
30 char **g_argv;
31
32 int host_init(void)
33 {
34   in_init();
35   host_init_input();
36   in_probe();
37
38   return 0;
39 }
40
41 int host_read_btns(void)
42 {
43   int actions[IN_BINDTYPE_COUNT] = { 0, };
44
45   in_update(actions);
46   host_actions(actions);
47
48   return actions[IN_BINDTYPE_PLAYER12];
49 }
50
51 void host_forced_exit(void)
52 {
53   // exit() might not be enough because loader and app data is out of sync,
54   // and other threads (which are really processes on this old glibc used)
55   // might not exit properly.
56   char cmd[64];
57
58   printf("forced exit...\n");
59
60   snprintf(cmd, sizeof(cmd), "killall %s", g_argv[0]);
61   system(cmd);
62   usleep(300000);
63   snprintf(cmd, sizeof(cmd), "killall -9 %s", g_argv[0]);
64   system(cmd);
65   exit(1);
66 }
67
68 // vim:shiftwidth=2:expandtab