+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, k, i;
+ const int *def_binds;
+
+ key_count = in_get_dev_info(dev_id, IN_INFO_BIND_COUNT);
+ def_binds = in_get_dev_def_binds(dev_id);
+
+ for (k = 0; k < key_count; k++)
+ {
+ const char *name;
+ int t, mask;
+ act[0] = act[31] = 0;
+
+ for (t = 0; t < IN_BINDTYPE_COUNT; t++)
+ if (binds[IN_BIND_OFFS(k, t)] != def_binds[IN_BIND_OFFS(k, t)])
+ break;
+
+ if (no_defaults && t == IN_BINDTYPE_COUNT)
+ continue; /* no change from defaults */
+
+ name = in_get_key_name(dev_id, k);
+
+ for (t = 0; t < IN_BINDTYPE_COUNT; t++)
+ if (binds[IN_BIND_OFFS(k, t)] != 0 || def_binds[IN_BIND_OFFS(k, t)] == 0)
+ break;
+
+ if (t == IN_BINDTYPE_COUNT) {
+ /* key has default bind removed */
+ fprintf(fn, "%s %s =" NL, bind_str, name);
+ continue;
+ }
+
+ for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
+ mask = me_ctrl_actions[i].mask;
+ if (mask & binds[IN_BIND_OFFS(k, IN_BINDTYPE_PLAYER12)]) {
+ strncpy(act, me_ctrl_actions[i].name, 31);
+ fprintf(fn, "%s %s = player1 %s" NL, bind_str, name, mystrip(act));
+ }
+ mask = me_ctrl_actions[i].mask << 16;
+ if (mask & binds[IN_BIND_OFFS(k, IN_BINDTYPE_PLAYER12)]) {
+ strncpy(act, me_ctrl_actions[i].name, 31);
+ fprintf(fn, "%s %s = player2 %s" NL, bind_str, name, mystrip(act));
+ }
+ }
+
+ for (i = 0; emuctrl_actions[i].name != NULL; i++) {
+ mask = emuctrl_actions[i].mask;
+ if (mask & binds[IN_BIND_OFFS(k, IN_BINDTYPE_EMU)]) {
+ 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;
+ }
+}
+