+#if PLAT_HAVE_JOY
+static const char *joyKeyNames[32] =
+{
+ "UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4",
+ "b5", "b6", "b7", "b8", "b9", "b10", "b11", "b12",
+ "b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20",
+ "b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28"
+};
+#endif
+
+static void keys_write(FILE *fn, const char *bind_str, int dev_id, const int *binds, int no_defaults)
+{
+ char act[48];
+ int key_count, t, i;
+ const int *def_binds;
+
+ key_count = in_get_dev_bind_count(dev_id);
+ def_binds = in_get_dev_def_binds(dev_id);
+
+ for (t = 0; t < key_count; t++)
+ {
+ const char *name;
+ act[0] = act[31] = 0;
+
+ if (no_defaults && binds[t] == def_binds[t])
+ continue;
+
+ name = in_get_key_name(dev_id, t);
+#ifdef __GP2X__
+ if (strcmp(name, "SELECT") == 0) continue;
+#endif
+
+ if (binds[t] == 0 && def_binds[t] != 0) {
+ fprintf(fn, "%s %s =" NL, bind_str, name);
+ continue;
+ }
+
+ for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
+ if (me_ctrl_actions[i].mask & binds[t]) {
+ strncpy(act, me_ctrl_actions[i].name, 31);
+ fprintf(fn, "%s %s = player%i %s" NL, bind_str, name,
+ ((binds[t]>>16)&1)+1, mystrip(act));
+ }
+ }
+
+ for (i = 0; emuctrl_actions[i].name != NULL; i++) {
+ if (emuctrl_actions[i].mask & binds[t]) {
+ strncpy(act, emuctrl_actions[i].name, 31);
+ fprintf(fn, "%s %s = %s" NL, bind_str, name, mystrip(act));
+ }
+ }
+ }
+}
+
+
+static int default_var(const menu_entry *me)
+{
+ switch (me->id)
+ {
+ case MA_OPT_ACC_TIMING:
+ case MA_OPT_ACC_SPRITES:
+ case MA_OPT_ARM940_SOUND:
+ case MA_OPT_6BUTTON_PAD:
+ case MA_OPT2_ENABLE_Z80:
+ case MA_OPT2_ENABLE_YM2612:
+ case MA_OPT2_ENABLE_SN76496:
+ case MA_OPT2_SVP_DYNAREC:
+ case MA_CDOPT_CDDA:
+ case MA_CDOPT_PCM:
+ case MA_CDOPT_SAVERAM:
+ case MA_CDOPT_SCALEROT_CHIP:
+ case MA_CDOPT_BETTER_SYNC:
+ return defaultConfig.s_PicoOpt;
+
+ case MA_OPT_SHOW_FPS:
+ case MA_OPT_ENABLE_SOUND:
+ case MA_OPT_SRAM_STATES:
+ case MA_OPT2_A_SN_GAMMA:
+ case MA_OPT2_VSYNC:
+ case MA_OPT2_GZIP_STATES:
+ case MA_OPT2_NO_LAST_ROM:
+ case MA_OPT2_RAMTIMINGS:
+ case MA_CDOPT_LEDS:
+ return defaultConfig.EmuOpt;
+
+ case MA_CTRL_TURBO_RATE: return defaultConfig.turbo_rate;
+ case MA_OPT_SCALING: return defaultConfig.scaling;
+ case MA_OPT_ROTATION: return defaultConfig.rotation;
+
+ case MA_OPT_SAVE_SLOT:
+ default:
+ return 0;
+ }
+}
+