4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
11 #include <sys/types.h>
14 #include <sys/ioctl.h>
16 #include <linux/input.h>
19 #include "common/input.h"
20 #include "plugin_lib.h"
24 static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
25 [0 ... KEY_MAX] = NULL,
28 [KEY_RIGHT] = "Right",
31 [KEY_PAGEDOWN] = "(X)",
34 [KEY_RIGHTSHIFT]= "(L)",
35 [KEY_RIGHTCTRL] = "(R)",
36 [KEY_LEFTALT] = "Start",
37 [KEY_LEFTCTRL] = "Select",
38 [KEY_MENU] = "Pandora",
41 static const struct in_default_bind in_evdev_defbinds[] = {
42 { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
43 { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
44 { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
45 { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
46 { KEY_PAGEUP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
47 { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
48 { KEY_END, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
49 { KEY_HOME, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
50 { KEY_LEFTALT, IN_BINDTYPE_PLAYER12, DKEY_START },
51 { KEY_LEFTCTRL, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
52 { KEY_RIGHTSHIFT,IN_BINDTYPE_PLAYER12, DKEY_L1 },
53 { KEY_RIGHTCTRL, IN_BINDTYPE_PLAYER12, DKEY_R1 },
54 { KEY_Q, IN_BINDTYPE_PLAYER12, DKEY_L2 },
55 { KEY_P, IN_BINDTYPE_PLAYER12, DKEY_R2 },
56 { KEY_TAB, IN_BINDTYPE_EMU, SACTION_MINIMIZE },
57 { KEY_SPACE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
58 { KEY_1, IN_BINDTYPE_EMU, SACTION_SAVE_STATE },
59 { KEY_2, IN_BINDTYPE_EMU, SACTION_LOAD_STATE },
60 { KEY_3, IN_BINDTYPE_EMU, SACTION_PREV_SSLOT },
61 { KEY_4, IN_BINDTYPE_EMU, SACTION_NEXT_SSLOT },
62 { KEY_5, IN_BINDTYPE_EMU, SACTION_TOGGLE_FSKIP },
63 { KEY_6, IN_BINDTYPE_EMU, SACTION_SCREENSHOT },
67 int plat_pandora_init(void)
69 in_evdev_init(in_evdev_defbinds);
71 in_set_config(in_name_to_id("evdev:gpio-keys"), IN_CFG_KEY_NAMES,
72 pandora_gpio_keys, sizeof(pandora_gpio_keys));
73 in_adev[0] = in_name_to_id("evdev:nub0");
74 in_adev[1] = in_name_to_id("evdev:nub1");
79 static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
81 int plat_cpu_clock_get(void)
85 f = fopen("/proc/pandora/cpu_mhz_max", "r");
87 fscanf(f, "%d", &ret);
93 int plat_cpu_clock_apply(int cpu_clock)
97 if (cpu_clock != 0 && cpu_clock != plat_cpu_clock_get()) {
98 snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",
99 pnd_script_base, cpu_clock);
105 int plat_get_bat_capacity(void)
109 f = fopen("/sys/class/power_supply/bq27500-0/capacity", "r");
111 fscanf(f, "%d", &ret);