+
+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"
+};
+
+static void keys_write(FILE *fn, const char *bind_str, const int binds[32],
+ const int def_binds[32], const char * const names[32], int no_defaults)
+{
+ int t, i;
+ char act[48];
+
+ for (t = 0; t < 32; t++)
+ {
+ act[0] = act[31] = 0;
+ if (no_defaults && binds[t] == def_binds[t])
+ continue;
+ if (strcmp(names[t], "???") == 0) continue;
+#ifdef __GP2X__
+ if (strcmp(names[t], "SELECT") == 0) continue;
+#endif
+ if (binds[t] == 0 && def_binds[t] != 0) {
+ fprintf(fn, "%s %s =" NL, bind_str, names[t]); // no binds
+ 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, names[t],
+ ((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, names[t], mystrip(act));
+ }
+ }
+ }
+}
+
+