-// (c) Copyright 2006-2010 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * (C) GraÅžvydas "notaz" Ignotas, 2006-2011\r
+ *\r
+ * This work is licensed under the terms of any of these licenses\r
+ * (at your option):\r
+ * - GNU GPL, version 2 or later.\r
+ * - GNU LGPL, version 2.1 or later.\r
+ * See the COPYING file in the top-level directory.\r
+ */\r
\r
#include <stdio.h>\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdarg.h>\r
+#include <time.h>\r
+#include <locale.h> // savestate date\r
\r
#include "menu.h"\r
#include "fonts.h"\r
return -1;\r
}\r
\r
+static char tolower_simple(char c)\r
+{\r
+ if ('A' <= c && c <= 'Z')\r
+ c = c - 'A' + 'a';\r
+ return c;\r
+}\r
+\r
void menu_init(void)\r
{\r
int i, c, l;\r
}\r
fclose(f);\r
}\r
+\r
+ // use user's locale for savestate date display\r
+ setlocale(LC_TIME, "");\r
}\r
\r
static void menu_draw_begin(int need_bg)\r
}\r
}\r
\r
-static void menu_enter(int is_rom_loaded)\r
-{\r
- if (is_rom_loaded)\r
- {\r
- // darken the active framebuffer\r
- menu_darken_bg(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h, 1);\r
- }\r
- else\r
- {\r
- char buff[256];\r
-\r
- // should really only happen once, on startup..\r
- emu_make_path(buff, "skin/background.png", sizeof(buff));\r
- if (readpng(g_menubg_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h) < 0)\r
- memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);\r
- }\r
-\r
- plat_video_menu_enter(is_rom_loaded);\r
-}\r
-\r
static int me_id2offset(const menu_entry *ent, menu_id id)\r
{\r
int i;\r
return ret;\r
}\r
\r
+static unsigned int me_read_onoff(const menu_entry *ent)\r
+{\r
+ // guess var size based on mask to avoid reading too much\r
+ if (ent->mask & 0xffff0000)\r
+ return *(unsigned int *)ent->var & ent->mask;\r
+ else if (ent->mask & 0xff00)\r
+ return *(unsigned short *)ent->var & ent->mask;\r
+ else\r
+ return *(unsigned char *)ent->var & ent->mask;\r
+}\r
+\r
+static void me_toggle_onoff(menu_entry *ent)\r
+{\r
+ // guess var size based on mask to avoid reading too much\r
+ if (ent->mask & 0xffff0000)\r
+ *(unsigned int *)ent->var ^= ent->mask;\r
+ else if (ent->mask & 0xff00)\r
+ *(unsigned short *)ent->var ^= ent->mask;\r
+ else\r
+ *(unsigned char *)ent->var ^= ent->mask;\r
+}\r
+\r
static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))\r
{\r
const menu_entry *ent, *ent_sel = entries;\r
h = g_menuscreen_h;\r
}\r
\r
- x = g_menuscreen_w / 2 - w / 2;\r
+ x = g_menuscreen_w / 2 - w / 2;\r
y = g_menuscreen_h / 2 - h / 2;\r
+#ifdef MENU_ALIGN_LEFT\r
+ if (x > 12) x = 12;\r
+#endif\r
\r
/* draw */\r
menu_draw_begin(1);\r
for (ent = entries; ent->name; ent++)\r
{\r
const char **names;\r
- int len;\r
+ int len, leftname_end = 0;\r
\r
if (!ent->enabled)\r
continue;\r
if (ent->generate_name)\r
name = ent->generate_name(ent->id, &offs);\r
}\r
- if (name != NULL)\r
+ if (name != NULL) {\r
text_out16(x, y, name);\r
+ leftname_end = x + (strlen(name) + 1) * me_mfont_w;\r
+ }\r
\r
switch (ent->beh) {\r
case MB_NONE:\r
break;\r
case MB_OPT_ONOFF:\r
- text_out16(x + col2_offs, y, (*(int *)ent->var & ent->mask) ? "ON" : "OFF");\r
+ text_out16(x + col2_offs, y, me_read_onoff(ent) ? "ON" : "OFF");\r
break;\r
case MB_OPT_RANGE:\r
text_out16(x + col2_offs, y, "%i", *(int *)ent->var);\r
break;\r
case MB_OPT_ENUM:\r
names = (const char **)ent->data;\r
- offs = 0;\r
for (i = 0; names[i] != NULL; i++) {\r
+ offs = x + col2_offs;\r
len = strlen(names[i]);\r
if (len > 10)\r
- offs = 10 - len - 2;\r
- if (i == *(int *)ent->var) {\r
- text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", names[i]);\r
+ offs += (10 - len - 2) * me_mfont_w;\r
+ if (offs < leftname_end)\r
+ offs = leftname_end;\r
+ if (i == *(unsigned char *)ent->var) {\r
+ text_out16(offs, y, "%s", names[i]);\r
break;\r
}\r
}\r
{\r
case MB_OPT_ONOFF:\r
case MB_OPT_CUSTONOFF:\r
- *(int *)entry->var ^= entry->mask;\r
+ me_toggle_onoff(entry);\r
return 1;\r
case MB_OPT_RANGE:\r
case MB_OPT_CUSTRANGE:\r
names = (const char **)entry->data;\r
for (c = 0; names[c] != NULL; c++)\r
;\r
- *(int *)entry->var += is_next ? 1 : -1;\r
- if (*(int *)entry->var < 0)\r
- *(int *)entry->var = 0;\r
- if (*(int *)entry->var >= c)\r
- *(int *)entry->var = c - 1;\r
+ *(signed char *)entry->var += is_next ? 1 : -1;\r
+ if (*(signed char *)entry->var < 0)\r
+ *(signed char *)entry->var = 0;\r
+ if (*(signed char *)entry->var >= c)\r
+ *(signed char *)entry->var = c - 1;\r
return 1;\r
default:\r
return 0;\r
\r
static void debug_menu_loop(void);\r
\r
-static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void))\r
+static int me_loop_d(menu_entry *menu, int *menu_sel, void (*draw_prep)(void), void (*draw_more)(void))\r
{\r
- int ret, inp, sel = *menu_sel, menu_sel_max;\r
+ int ret = 0, inp, sel = *menu_sel, menu_sel_max;\r
\r
menu_sel_max = me_count(menu) - 1;\r
if (menu_sel_max < 0) {\r
lprintf("no enabled menu entries\n");\r
- return;\r
+ return 0;\r
}\r
\r
while ((!menu[sel].enabled || !menu[sel].selectable) && sel < menu_sel_max)\r
\r
/* make sure action buttons are not pressed on entering menu */\r
me_draw(menu, sel, NULL);\r
- while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU));\r
+ while (in_menu_wait_any(NULL, 50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU));\r
\r
for (;;)\r
{\r
+ if (draw_prep != NULL)\r
+ draw_prep();\r
+\r
me_draw(menu, sel, draw_more);\r
inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|\r
- PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, 70);\r
+ PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, NULL, 70);\r
if (inp & (PBTN_MENU|PBTN_MBACK))\r
break;\r
\r
}\r
}\r
*menu_sel = sel;\r
+\r
+ return ret;\r
+}\r
+\r
+static int me_loop(menu_entry *menu, int *menu_sel)\r
+{\r
+ return me_loop_d(menu, menu_sel, NULL, NULL);\r
}\r
\r
/* ***************************************** */\r
\r
-static void draw_menu_credits(void (*draw_more)(void))\r
+static void draw_menu_message(const char *msg, void (*draw_more)(void))\r
{\r
- const char *creds, *p;\r
int x, y, h, w, wt;\r
+ const char *p;\r
\r
- p = creds = plat_get_credits();\r
-\r
+ p = msg;\r
for (h = 1, w = 0; *p != 0; h++) {\r
for (wt = 0; *p != 0 && *p != '\n'; p++)\r
wt++;\r
p++;\r
}\r
\r
- x = g_menuscreen_w / 2 - w * me_mfont_w / 2;\r
+ x = g_menuscreen_w / 2 - w * me_mfont_w / 2;\r
y = g_menuscreen_h / 2 - h * me_mfont_h / 2;\r
if (x < 0) x = 0;\r
if (y < 0) y = 0;\r
\r
menu_draw_begin(1);\r
\r
- for (p = creds; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) {\r
+ for (p = msg; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) {\r
text_out16(x, y, p);\r
\r
for (; *p != 0 && *p != '\n'; p++)\r
text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, tmp);\r
menu_draw_end();\r
\r
- while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MA2));\r
- inp = in_menu_wait(PBTN_MA3|PBTN_MBACK, 100);\r
+ while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MA2));\r
+ inp = in_menu_wait(PBTN_MA3|PBTN_MBACK, NULL, 100);\r
if (inp & PBTN_MA3)\r
remove(fpath);\r
}\r
\r
// -------------- ROM selector --------------\r
\r
-// rrrr rggg gggb bbbb\r
-static unsigned short file2color(const char *fname)\r
-{\r
- const char *ext = fname + strlen(fname) - 3;\r
- static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso", "cue" };\r
- static const char *other_exts[] = { "gmv", "pat" };\r
- int i;\r
-\r
- if (ext < fname) ext = fname;\r
- for (i = 0; i < array_size(rom_exts); i++)\r
- if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff; // FIXME: mk defines\r
- for (i = 0; i < array_size(other_exts); i++)\r
- if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5;\r
- return 0xffff;\r
-}\r
-\r
static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)\r
{\r
int max_cnt, start, i, x, pos;\r
smalltext_out16(x, pos * me_sfont_h, "/", 0xfff6);\r
smalltext_out16(x + me_sfont_w, pos * me_sfont_h, namelist[i+1]->d_name, 0xfff6);\r
} else {\r
- unsigned short color = file2color(namelist[i+1]->d_name);\r
+ unsigned short color = fname2color(namelist[i+1]->d_name);\r
smalltext_out16(x, pos * me_sfont_h, namelist[i+1]->d_name, color);\r
}\r
}\r
return alphasort(d1, d2);\r
}\r
\r
-static const char *filter_exts[] = {\r
- ".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html",\r
- ".jpg", ".gpe"\r
-};\r
-\r
static int scandir_filter(const struct dirent *ent)\r
{\r
const char *p;\r
return 1;\r
}\r
\r
+static int dirent_seek_char(struct dirent **namelist, int len, int sel, char c)\r
+{\r
+ int i;\r
+\r
+ sel++;\r
+ for (i = sel + 1; i != sel; i++) {\r
+ if (i >= len)\r
+ i = 1;\r
+\r
+ if (tolower_simple(namelist[i]->d_name[0]) == c)\r
+ break;\r
+ }\r
+\r
+ return i - 1;\r
+}\r
+\r
static char *menu_loop_romsel(char *curr_path, int len)\r
{\r
struct dirent **namelist;\r
int n, inp, sel = 0;\r
char *ret = NULL, *fname = NULL;\r
+ char cinp;\r
\r
rescan:\r
// is this a dir or a full path?\r
}\r
\r
// try to find sel\r
+ // note: we don't show '.' so sel is namelist index - 1\r
if (fname != NULL) {\r
int i;\r
for (i = 1; i < n; i++) {\r
- if (strcmp(namelist[i]->d_name, fname) == 0) {\r
+ char *dname = namelist[i]->d_name;\r
+ if (dname[0] == fname[0] && strcmp(dname, fname) == 0) {\r
sel = i - 1;\r
break;\r
}\r
\r
/* make sure action buttons are not pressed on entering menu */\r
draw_dirlist(curr_path, namelist, n, sel);\r
- while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU))\r
+ while (in_menu_wait_any(NULL, 50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU))\r
;\r
\r
for (;;)\r
{\r
draw_dirlist(curr_path, namelist, n, sel);\r
inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|\r
- PBTN_L|PBTN_R|PBTN_MA2|PBTN_MOK|PBTN_MBACK|PBTN_MENU, 33);\r
+ PBTN_L|PBTN_R|PBTN_MA2|PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_CHAR, &cinp, 33);\r
if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }\r
if (inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }\r
if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
if (inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }\r
+ if (inp & PBTN_CHAR) sel = dirent_seek_char(namelist, n, sel, cinp);\r
if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_MA2)) == (PBTN_MENU|PBTN_MA2))\r
{\r
again:\r
{\r
int newlen;\r
char *p, *newdir;\r
- if (!(inp & PBTN_MOK)) continue;\r
+ if (!(inp & PBTN_MOK))\r
+ continue;\r
newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
newdir = malloc(newlen);\r
+ if (newdir == NULL)\r
+ break;\r
if (strcmp(namelist[sel+1]->d_name, "..") == 0) {\r
char *start = curr_path;\r
p = start + strlen(start) - 1;\r
free(namelist);\r
}\r
\r
+ // restore curr_path\r
+ if (fname != NULL) {\r
+ n = strlen(curr_path);\r
+ if (curr_path + n + 1 == fname)\r
+ curr_path[n] = '/';\r
+ }\r
+\r
return ret;\r
}\r
\r
// ------------ savestate loader ------------\r
\r
+#define STATE_SLOT_COUNT 10\r
+\r
static int state_slot_flags = 0;\r
+static int state_slot_times[STATE_SLOT_COUNT];\r
\r
static void state_check_slots(void)\r
{\r
\r
state_slot_flags = 0;\r
\r
- for (slot = 0; slot < 10; slot++) {\r
- if (emu_check_save_file(slot))\r
+ for (slot = 0; slot < STATE_SLOT_COUNT; slot++) {\r
+ state_slot_times[slot] = 0;\r
+ if (emu_check_save_file(slot, &state_slot_times[slot]))\r
state_slot_flags |= 1 << slot;\r
}\r
}\r
static void draw_savestate_menu(int menu_sel, int is_loading)\r
{\r
int i, x, y, w, h;\r
+ char time_buf[32];\r
\r
if (state_slot_flags & (1 << menu_sel))\r
draw_savestate_bg(menu_sel);\r
\r
w = (13 + 2) * me_mfont_w;\r
- h = (1+2+10+1) * me_mfont_h;\r
+ h = (1+2+STATE_SLOT_COUNT+1) * me_mfont_h;\r
x = g_menuscreen_w / 2 - w / 2;\r
if (x < 0) x = 0;\r
y = g_menuscreen_h / 2 - h / 2;\r
if (y < 0) y = 0;\r
+#ifdef MENU_ALIGN_LEFT\r
+ if (x > 12 + me_mfont_w * 2)\r
+ x = 12 + me_mfont_w * 2;\r
+#endif\r
\r
menu_draw_begin(1);\r
\r
text_out16(x, y, is_loading ? "Load state" : "Save state");\r
y += 3 * me_mfont_h;\r
\r
- menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (13 + 2) * me_mfont_w + 4);\r
+ menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (23 + 2) * me_mfont_w + 4);\r
\r
- /* draw all 10 slots */\r
- for (i = 0; i < 10; i++, y += me_mfont_h)\r
+ /* draw all slots */\r
+ for (i = 0; i < STATE_SLOT_COUNT; i++, y += me_mfont_h)\r
{\r
- text_out16(x, y, "SLOT %i (%s)", i, (state_slot_flags & (1 << i)) ? "USED" : "free");\r
+ if (!(state_slot_flags & (1 << i)))\r
+ strcpy(time_buf, "free");\r
+ else {\r
+ strcpy(time_buf, "USED");\r
+ if (state_slot_times[i] != 0) {\r
+ time_t time = state_slot_times[i];\r
+ struct tm *t = localtime(&time);\r
+ strftime(time_buf, sizeof(time_buf), "%x %R", t);\r
+ }\r
+ }\r
+\r
+ text_out16(x, y, "SLOT %i (%s)", i, time_buf);\r
}\r
text_out16(x, y, "back");\r
\r
\r
static int menu_loop_savestate(int is_loading)\r
{\r
- static int menu_sel = 10;\r
- int menu_sel_max = 10;\r
+ static int menu_sel = STATE_SLOT_COUNT;\r
+ int menu_sel_max = STATE_SLOT_COUNT;\r
unsigned long inp = 0;\r
int ret = 0;\r
\r
for (;;)\r
{\r
draw_savestate_menu(menu_sel, is_loading);\r
- inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK, 100);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK, NULL, 100);\r
if (inp & PBTN_UP) {\r
do {\r
menu_sel--;\r
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);\r
}\r
if (inp & PBTN_MOK) { // save/load\r
- if (menu_sel < 10) {\r
+ if (menu_sel < STATE_SLOT_COUNT) {\r
state_slot = menu_sel;\r
if (emu_save_load_game(is_loading, 0)) {\r
me_update_msg(is_loading ? "Load failed" : "Save failed");\r
\r
static char *action_binds(int player_idx, int action_mask, int dev_id)\r
{\r
- int k, count = 0, can_combo = 0, type;\r
- const int *binds;\r
+ int dev = 0, dev_last = IN_MAX_DEVS - 1;\r
+ int can_combo = 1, type;\r
\r
static_buff[0] = 0;\r
\r
- binds = in_get_dev_binds(dev_id);\r
- if (binds == NULL)\r
- return static_buff;\r
-\r
- in_get_config(dev_id, IN_CFG_BIND_COUNT, &count);\r
- in_get_config(dev_id, IN_CFG_DOES_COMBOS, &can_combo);\r
-\r
type = IN_BINDTYPE_EMU;\r
if (player_idx >= 0) {\r
can_combo = 0;\r
if (player_idx == 1)\r
action_mask <<= 16;\r
\r
- for (k = 0; k < count; k++)\r
- {\r
- const char *xname;\r
- int len;\r
+ if (dev_id >= 0)\r
+ dev = dev_last = dev_id;\r
+\r
+ for (; dev <= dev_last; dev++) {\r
+ int k, count = 0, combo = 0;\r
+ const int *binds;\r
\r
- if (!(binds[IN_BIND_OFFS(k, type)] & action_mask))\r
+ binds = in_get_dev_binds(dev);\r
+ if (binds == NULL)\r
continue;\r
\r
- xname = in_get_key_name(dev_id, k);\r
- len = strlen(static_buff);\r
- if (len) {\r
- strncat(static_buff, can_combo ? " + " : ", ",\r
- sizeof(static_buff) - len - 1);\r
- len += can_combo ? 3 : 2;\r
+ in_get_config(dev, IN_CFG_BIND_COUNT, &count);\r
+ in_get_config(dev, IN_CFG_DOES_COMBOS, &combo);\r
+ combo = combo && can_combo;\r
+\r
+ for (k = 0; k < count; k++) {\r
+ const char *xname;\r
+ int len;\r
+\r
+ if (!(binds[IN_BIND_OFFS(k, type)] & action_mask))\r
+ continue;\r
+\r
+ xname = in_get_key_name(dev, k);\r
+ len = strlen(static_buff);\r
+ if (len) {\r
+ strncat(static_buff, combo ? " + " : ", ",\r
+ sizeof(static_buff) - len - 1);\r
+ len += combo ? 3 : 2;\r
+ }\r
+ strncat(static_buff, xname, sizeof(static_buff) - len - 1);\r
}\r
- strncat(static_buff, xname, sizeof(static_buff) - len - 1);\r
}\r
\r
return static_buff;\r
text_out16(x, y, "%s : %s", opts[i].name,\r
action_binds(player_idx, opts[i].mask, dev_id));\r
\r
- dev_name = in_get_dev_name(dev_id, 1, 1);\r
+ if (dev_id < 0)\r
+ dev_name = "(all devices)";\r
+ else\r
+ dev_name = in_get_dev_name(dev_id, 1, 1);\r
w = strlen(dev_name) * me_mfont_w;\r
if (w < 30 * me_mfont_w)\r
w = 30 * me_mfont_w;\r
static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx)\r
{\r
int i, sel = 0, menu_sel_max = opt_cnt - 1, does_combos = 0;\r
- int dev_id, dev_count, kc, is_down, mkey;\r
+ int dev_id, bind_dev_id, dev_count, kc, is_down, mkey;\r
int unbind, bindtype, mask_shift;\r
\r
for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) {\r
return;\r
}\r
\r
+ dev_id = -1; // show all\r
mask_shift = 0;\r
if (player_idx == 1)\r
mask_shift = 16;\r
for (;;)\r
{\r
draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0);\r
- mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK|PBTN_MA2, 100);\r
+ mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT\r
+ |PBTN_MBACK|PBTN_MOK|PBTN_MA2, NULL, 100);\r
switch (mkey) {\r
case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue;\r
case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue;\r
case PBTN_LEFT:\r
- for (i = 0, dev_id--; i < IN_MAX_DEVS; i++, dev_id--) {\r
- if (dev_id < 0)\r
+ for (i = 0, dev_id--; i < IN_MAX_DEVS + 1; i++, dev_id--) {\r
+ if (dev_id < -1)\r
dev_id = IN_MAX_DEVS - 1;\r
- if (in_get_dev_name(dev_id, 1, 0) != NULL)\r
+ if (dev_id == -1 || in_get_dev_name(dev_id, 1, 0) != NULL)\r
break;\r
}\r
continue;\r
case PBTN_RIGHT:\r
for (i = 0, dev_id++; i < IN_MAX_DEVS; i++, dev_id++) {\r
if (dev_id >= IN_MAX_DEVS)\r
- dev_id = 0;\r
- if (in_get_dev_name(dev_id, 1, 0) != NULL)\r
+ dev_id = -1;\r
+ if (dev_id == -1 || in_get_dev_name(dev_id, 1, 0) != NULL)\r
break;\r
}\r
continue;\r
case PBTN_MOK:\r
if (sel >= opt_cnt)\r
return;\r
- while (in_menu_wait_any(30) & PBTN_MOK)\r
+ while (in_menu_wait_any(NULL, 30) & PBTN_MOK)\r
;\r
break;\r
case PBTN_MA2:\r
\r
/* wait for some up event */\r
for (is_down = 1; is_down; )\r
- kc = in_update_keycode(&dev_id, &is_down, -1);\r
+ kc = in_update_keycode(&bind_dev_id, &is_down, NULL, -1);\r
\r
- i = count_bound_keys(dev_id, opts[sel].mask << mask_shift, bindtype);\r
+ i = count_bound_keys(bind_dev_id, opts[sel].mask << mask_shift, bindtype);\r
unbind = (i > 0);\r
\r
/* allow combos if device supports them */\r
- in_get_config(dev_id, IN_CFG_DOES_COMBOS, &does_combos);\r
+ in_get_config(bind_dev_id, IN_CFG_DOES_COMBOS, &does_combos);\r
if (i == 1 && bindtype == IN_BINDTYPE_EMU && does_combos)\r
unbind = 0;\r
\r
if (unbind)\r
- in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype);\r
+ in_unbind_all(bind_dev_id, opts[sel].mask << mask_shift, bindtype);\r
\r
- in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, 0);\r
+ in_bind_key(bind_dev_id, kc, opts[sel].mask << mask_shift, bindtype, 0);\r
}\r
}\r
\r