+#ifdef FAKE_IN_GP2X
+static int in_gp2x_get_fake_bits(void)
+{
+ extern int current_keys;
+ return current_keys;
+}
+#endif
+
+static void in_gp2x_probe(void)
+{
+ gp2x_soc_t soc;
+
+ soc = soc_detect();
+ switch (soc)
+ {
+ case SOCID_MMSP2:
+ in_gp2x_get_bits = in_gp2x_get_mmsp2_bits;
+ break;
+ case SOCID_POLLUX:
+ gpiodev = open("/dev/GPIO", O_RDONLY);
+ if (gpiodev < 0) {
+ perror("in_gp2x: couldn't open /dev/GPIO");
+ return;
+ }
+ in_gp2x_get_bits = in_gp2x_get_wiz_bits;
+ break;
+ default:
+#ifdef FAKE_IN_GP2X
+ in_gp2x_get_bits = in_gp2x_get_fake_bits;
+ break;
+#endif
+ return;
+ }
+
+ in_register(IN_PREFIX "GP2X pad", IN_DRVID_GP2X, -1, (void *)1, 1);
+}
+
+static void in_gp2x_free(void *drv_data)
+{
+ if (gpiodev >= 0) {
+ close(gpiodev);
+ gpiodev = -1;
+ }
+}
+
+static int in_gp2x_get_bind_count(void)
+{
+ return IN_GP2X_NBUTTONS;
+}
+