2 * (C) GraÅžvydas "notaz" Ignotas, 2006-2012
\r
4 * This work is licensed under the terms of any of these licenses
\r
6 * - GNU GPL, version 2 or later.
\r
7 * - GNU LGPL, version 2.1 or later.
\r
9 * See the COPYING file in the top-level directory.
\r
17 #include <locale.h> // savestate date
\r
21 #include "readpng.h"
\r
22 #include "lprintf.h"
\r
27 #if defined(__GNUC__) && __GNUC__ >= 7
\r
28 #pragma GCC diagnostic ignored "-Wformat-truncation"
\r
31 static char static_buff[64];
\r
32 static int menu_error_time = 0;
\r
33 char menu_error_msg[64] = { 0, };
\r
34 // g_menuscreen is the current output buffer the menu is rendered to.
\r
35 void *g_menuscreen_ptr;
\r
36 // g_menubg is the menu background and has the same w/h as g_menuscreen, but
\r
37 // pp=w. It is filled on menu entry from file or from g_menubg_src if available.
\r
39 // g_menubg_src points to a buffer containing a bg image. This is usually either
\r
40 // the emulator screen buffer or the host frame buffer.
\r
41 void *g_menubg_src_ptr;
\r
45 int g_menuscreen_pp;
\r
48 int g_menubg_src_pp;
\r
50 int g_autostateld_opt;
\r
52 static unsigned char *menu_font_data = NULL;
\r
53 static int menu_text_color = 0xfffe; // default to white
\r
54 static int menu_sel_color = -1; // disabled
\r
56 /* note: these might become non-constant in future */
\r
58 static const int me_mfont_w = 16, me_mfont_h = 20;
\r
59 static const int me_sfont_w = 12, me_sfont_h = 20;
\r
61 static const int me_mfont_w = 8, me_mfont_h = 10;
\r
62 static const int me_sfont_w = 6, me_sfont_h = 10;
\r
65 static int g_menu_filter_off;
\r
66 static int g_border_style;
\r
67 static int border_left, border_right, border_top, border_bottom;
\r
69 void menuscreen_memset_lines(unsigned short *dst, int c, int l)
\r
71 for (; l > 0; l--, dst += g_menuscreen_pp)
\r
72 memset(dst, c, g_menuscreen_w * 2);
\r
75 // draws text to current bbp16 screen
\r
76 static void text_out16_(int x, int y, const char *text, int color)
\r
78 int i, lh, tr, tg, tb, len;
\r
79 unsigned short *dest = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_pp;
\r
80 tr = (color & 0xf800) >> 8;
\r
81 tg = (color & 0x07e0) >> 3;
\r
82 tb = (color & 0x001f) << 3;
\r
84 if (text == (void *)1)
\r
93 for (p = text; *p != 0 && *p != '\n'; p++)
\r
99 if (y + lh > g_menuscreen_h)
\r
100 lh = g_menuscreen_h - y;
\r
102 for (i = 0; i < len; i++)
\r
104 unsigned char *src = menu_font_data + (unsigned int)text[i] * me_mfont_w * me_mfont_h / 2;
\r
105 unsigned short *dst = dest;
\r
108 for (l = 0; l < lh; l++, dst += g_menuscreen_pp - me_mfont_w)
\r
110 for (u = me_mfont_w / 2; u > 0; u--, src++)
\r
114 r = (*dst & 0xf800) >> 8;
\r
115 g = (*dst & 0x07e0) >> 3;
\r
116 b = (*dst & 0x001f) << 3;
\r
117 r = (c^0xf)*r/15 + c*tr/15;
\r
118 g = (c^0xf)*g/15 + c*tg/15;
\r
119 b = (c^0xf)*b/15 + c*tb/15;
\r
120 *dst++ = ((r<<8)&0xf800) | ((g<<3)&0x07e0) | (b>>3);
\r
122 r = (*dst & 0xf800) >> 8;
\r
123 g = (*dst & 0x07e0) >> 3;
\r
124 b = (*dst & 0x001f) << 3;
\r
125 r = (c^0xf)*r/15 + c*tr/15;
\r
126 g = (c^0xf)*g/15 + c*tg/15;
\r
127 b = (c^0xf)*b/15 + c*tb/15;
\r
128 *dst++ = ((r<<8)&0xf800) | ((g<<3)&0x07e0) | (b>>3);
\r
131 dest += me_mfont_w;
\r
134 if (x < border_left)
\r
136 if (x + i * me_mfont_w > border_right)
\r
137 border_right = x + i * me_mfont_w;
\r
138 if (y < border_top)
\r
140 if (y + me_mfont_h > border_bottom)
\r
141 border_bottom = y + me_mfont_h;
\r
144 void text_out16(int x, int y, const char *texto, ...)
\r
148 int maxw = (g_menuscreen_w - x) / me_mfont_w;
\r
153 va_start(args, texto);
\r
154 vsnprintf(buffer, sizeof(buffer), texto, args);
\r
157 if (maxw > sizeof(buffer) - 1)
\r
158 maxw = sizeof(buffer) - 1;
\r
161 text_out16_(x,y,buffer,menu_text_color);
\r
164 /* draws in 6x8 font, might multiply size by integer */
\r
165 static void smalltext_out16_(int x, int y, const char *texto, int color)
\r
167 unsigned char *src;
\r
168 unsigned short *dst;
\r
169 int multiplier = me_sfont_w / 6;
\r
172 for (i = 0;; i++, x += me_sfont_w)
\r
174 unsigned char c = (unsigned char) texto[i];
\r
177 if (!c || c == '\n')
\r
180 src = fontdata6x8[c];
\r
181 dst = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_pp;
\r
186 for (h2 = multiplier; h2 > 0; h2--)
\r
188 for (m = 0x20; m; m >>= 1) {
\r
190 for (w2 = multiplier; w2 > 0; w2--)
\r
196 dst += g_menuscreen_pp - me_sfont_w;
\r
203 static void smalltext_out16(int x, int y, const char *texto, int color)
\r
206 int maxw = (g_menuscreen_w - x) / me_sfont_w;
\r
210 if (maxw > sizeof(buffer) - 1)
\r
211 maxw = sizeof(buffer) - 1;
\r
213 strncpy(buffer, texto, maxw);
\r
216 smalltext_out16_(x, y, buffer, color);
\r
219 static void menu_draw_selection(int x, int y, int w)
\r
222 unsigned short *dst, *dest;
\r
224 text_out16_(x, y, (void *)1, (menu_sel_color < 0) ? menu_text_color : menu_sel_color);
\r
226 if (menu_sel_color < 0) return; // no selection hilight
\r
229 dest = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_pp + me_mfont_w * 2 - 2;
\r
230 for (h = me_mfont_h + 1; h > 0; h--)
\r
233 for (i = w - (me_mfont_w * 2 - 2); i > 0; i--)
\r
234 *dst++ = menu_sel_color;
\r
235 dest += g_menuscreen_pp;
\r
239 static int parse_hex_color(char *buff)
\r
242 int t = (int) strtoul(buff, &endp, 16);
\r
245 return ((t<<8)&0xf800) | ((t>>5)&0x07e0) | ((t>>19)&0x1f);
\r
247 return ((t>>8)&0xf800) | ((t>>5)&0x07e0) | ((t>>3)&0x1f);
\r
252 static char tolower_simple(char c)
\r
254 if ('A' <= c && c <= 'Z')
\r
259 void menu_init_base(void)
\r
262 unsigned char *fd, *fds;
\r
266 if (menu_font_data != NULL)
\r
267 free(menu_font_data);
\r
269 menu_font_data = calloc((MENU_X2 ? 256 * 320 : 128 * 160) / 2, 1);
\r
270 if (menu_font_data == NULL)
\r
273 // generate default 8x10 font from fontdata8x8
\r
274 for (c = 0, fd = menu_font_data; c < 128; c++)
\r
276 for (l = 0; l < 8; l++)
\r
278 unsigned char fd8x8 = fontdata8x8[c*8+l];
\r
279 if (fd8x8&0x80) { *fd = 0xf0; }
\r
280 if (fd8x8&0x40) { *fd |= 0x0f; }; fd++;
\r
281 if (fd8x8&0x20) { *fd = 0xf0; }
\r
282 if (fd8x8&0x10) { *fd |= 0x0f; }; fd++;
\r
283 if (fd8x8&0x08) { *fd = 0xf0; }
\r
284 if (fd8x8&0x04) { *fd |= 0x0f; }; fd++;
\r
285 if (fd8x8&0x02) { *fd = 0xf0; }
\r
286 if (fd8x8&0x01) { *fd |= 0x0f; }; fd++;
\r
288 fd += 8*2/2; // 2 empty lines
\r
292 // expand default font
\r
293 fds = menu_font_data + 128 * 160 / 2 - 4;
\r
294 fd = menu_font_data + 256 * 320 / 2 - 1;
\r
295 for (c = 255; c >= 0; c--)
\r
297 for (l = 9; l >= 0; l--, fds -= 4)
\r
299 for (i = 3; i >= 0; i--) {
\r
300 int px = fds[i] & 0x0f;
\r
301 *fd-- = px | (px << 4);
\r
302 px = (fds[i] >> 4) & 0x0f;
\r
303 *fd-- = px | (px << 4);
\r
305 for (i = 3; i >= 0; i--) {
\r
306 int px = fds[i] & 0x0f;
\r
307 *fd-- = px | (px << 4);
\r
308 px = (fds[i] >> 4) & 0x0f;
\r
309 *fd-- = px | (px << 4);
\r
315 // load custom font and selector (stored as 1st symbol in font table)
\r
316 pos = plat_get_skin_dir(buff, sizeof(buff));
\r
317 strcpy(buff + pos, "font.png");
\r
318 readpng(menu_font_data, buff, READPNG_FONT,
\r
319 MENU_X2 ? 256 : 128, MENU_X2 ? 320 : 160);
\r
320 // default selector symbol is '>'
\r
321 memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2,
\r
322 me_mfont_w * me_mfont_h / 2);
\r
323 strcpy(buff + pos, "selector.png");
\r
324 readpng(menu_font_data, buff, READPNG_SELECTOR, me_mfont_w, me_mfont_h);
\r
326 // load custom colors
\r
327 strcpy(buff + pos, "skin.txt");
\r
328 f = fopen(buff, "r");
\r
331 lprintf("found skin.txt\n");
\r
334 if (fgets(buff, sizeof(buff), f) == NULL)
\r
336 if (buff[0] == '#' || buff[0] == '/') continue; // comment
\r
337 if (buff[0] == '\r' || buff[0] == '\n') continue; // empty line
\r
338 if (strncmp(buff, "text_color=", 11) == 0)
\r
340 int tmp = parse_hex_color(buff+11);
\r
341 if (tmp >= 0) menu_text_color = tmp;
\r
342 else lprintf("skin.txt: parse error for text_color\n");
\r
344 else if (strncmp(buff, "selection_color=", 16) == 0)
\r
346 int tmp = parse_hex_color(buff+16);
\r
347 if (tmp >= 0) menu_sel_color = tmp;
\r
348 else lprintf("skin.txt: parse error for selection_color\n");
\r
351 lprintf("skin.txt: parse error: %s\n", buff);
\r
356 // use user's locale for savestate date display
\r
357 setlocale(LC_TIME, "");
\r
360 static void menu_darken_bg(void *dst, void *src, int pixels, int darker)
\r
362 unsigned int *dest = dst;
\r
363 unsigned int *sorc = src;
\r
369 unsigned int p = *sorc++;
\r
370 *dest++ = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3);
\r
377 unsigned int p = *sorc++;
\r
378 *dest++ = (p&0xf79ef79e)>>1;
\r
383 static void menu_darken_text_bg(void)
\r
385 int x, y, xmin, xmax, ymax, ls;
\r
386 unsigned short *screen = g_menuscreen_ptr;
\r
388 xmin = border_left - 3;
\r
391 xmax = border_right + 2;
\r
392 if (xmax > g_menuscreen_w - 1)
\r
393 xmax = g_menuscreen_w - 1;
\r
395 y = border_top - 3;
\r
398 ymax = border_bottom + 2;
\r
399 if (ymax > g_menuscreen_h - 1)
\r
400 ymax = g_menuscreen_h - 1;
\r
402 for (x = xmin; x <= xmax; x++)
\r
403 screen[y * g_menuscreen_pp + x] = 0xa514;
\r
404 for (y++; y < ymax; y++)
\r
406 ls = y * g_menuscreen_pp;
\r
407 screen[ls + xmin] = 0xffff;
\r
408 for (x = xmin + 1; x < xmax; x++)
\r
410 unsigned int p = screen[ls + x];
\r
411 if (p != menu_text_color)
\r
412 screen[ls + x] = ((p&0xf79e)>>1) - ((p&0xc618)>>3);
\r
414 screen[ls + xmax] = 0xffff;
\r
416 ls = y * g_menuscreen_pp;
\r
417 for (x = xmin; x <= xmax; x++)
\r
418 screen[ls + x] = 0xffff;
\r
421 static int borders_pending;
\r
423 static void menu_reset_borders(void)
\r
425 border_left = g_menuscreen_w;
\r
427 border_top = g_menuscreen_h;
\r
431 static void menu_draw_begin(int need_bg, int no_borders)
\r
435 plat_video_menu_begin();
\r
437 menu_reset_borders();
\r
438 borders_pending = g_border_style && !no_borders;
\r
441 if (g_border_style && no_borders) {
\r
442 for (y = 0; y < g_menuscreen_h; y++)
\r
443 menu_darken_bg((short *)g_menuscreen_ptr + g_menuscreen_pp * y,
\r
444 (short *)g_menubg_ptr + g_menuscreen_w * y, g_menuscreen_w, 1);
\r
447 for (y = 0; y < g_menuscreen_h; y++)
\r
448 memcpy((short *)g_menuscreen_ptr + g_menuscreen_pp * y,
\r
449 (short *)g_menubg_ptr + g_menuscreen_w * y, g_menuscreen_w * 2);
\r
454 static void menu_draw_end(void)
\r
456 if (borders_pending)
\r
457 menu_darken_text_bg();
\r
458 plat_video_menu_end();
\r
461 static void menu_separation(void)
\r
463 if (borders_pending) {
\r
464 menu_darken_text_bg();
\r
465 menu_reset_borders();
\r
469 static int me_id2offset(const menu_entry *ent, menu_id id)
\r
472 for (i = 0; ent->name; ent++, i++)
\r
473 if (ent->id == id) return i;
\r
475 lprintf("%s: id %i not found\n", __FUNCTION__, id);
\r
479 static void me_enable(menu_entry *entries, menu_id id, int enable)
\r
481 int i = me_id2offset(entries, id);
\r
482 entries[i].enabled = enable;
\r
485 static int me_count(const menu_entry *ent)
\r
489 for (ret = 0; ent->name; ent++, ret++)
\r
495 static unsigned int me_read_onoff(const menu_entry *ent)
\r
497 return *(unsigned int *)ent->var & ent->mask;
\r
500 static void me_toggle_onoff(menu_entry *ent)
\r
502 *(unsigned int *)ent->var ^= ent->mask;
\r
505 static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
\r
507 const menu_entry *ent, *ent_sel = entries;
\r
508 int x, y, w = 0, h = 0;
\r
509 int offs, col2_offs = 27 * me_mfont_w;
\r
514 /* calculate size of menu rect */
\r
515 for (ent = entries, i = n = 0; ent->name; ent++, i++)
\r
528 wt = strlen(ent->name) * me_mfont_w;
\r
529 if (wt == 0 && ent->generate_name)
\r
530 name = ent->generate_name(ent->id, &offs);
\r
532 wt = strlen(name) * me_mfont_w;
\r
534 if (ent->beh != MB_NONE)
\r
536 if (wt > col2_offs)
\r
537 col2_offs = wt + me_mfont_w;
\r
540 switch (ent->beh) {
\r
545 wt += me_mfont_w * 3;
\r
547 case MB_OPT_CUSTOM:
\r
548 case MB_OPT_CUSTONOFF:
\r
549 case MB_OPT_CUSTRANGE:
\r
552 if (ent->generate_name != NULL)
\r
553 name = ent->generate_name(ent->id, &offs);
\r
555 wt += (strlen(name) + offs) * me_mfont_w;
\r
558 wt += 10 * me_mfont_w;
\r
567 h = n * me_mfont_h;
\r
568 w += me_mfont_w * 2; /* selector */
\r
570 if (w > g_menuscreen_w) {
\r
571 lprintf("width %d > %d\n", w, g_menuscreen_w);
\r
572 w = g_menuscreen_w;
\r
574 if (h > g_menuscreen_h) {
\r
575 lprintf("height %d > %d\n", w, g_menuscreen_h);
\r
576 h = g_menuscreen_h;
\r
579 x = g_menuscreen_w / 2 - w / 2;
\r
580 y = g_menuscreen_h / 2 - h / 2;
\r
581 #ifdef MENU_ALIGN_LEFT
\r
582 if (x > 12) x = 12;
\r
586 menu_draw_begin(1, 0);
\r
587 menu_draw_selection(x, y + vi_sel_ln * me_mfont_h, w);
\r
588 x += me_mfont_w * 2;
\r
590 for (ent = entries; ent->name; ent++)
\r
592 const char **names;
\r
593 int len, leftname_end = 0;
\r
599 if (strlen(name) == 0) {
\r
600 if (ent->generate_name)
\r
601 name = ent->generate_name(ent->id, &offs);
\r
603 if (name != NULL) {
\r
604 text_out16(x, y, "%s", name);
\r
605 leftname_end = x + (strlen(name) + 1) * me_mfont_w;
\r
608 switch (ent->beh) {
\r
612 text_out16(x + col2_offs, y, "%s", me_read_onoff(ent) ? "ON" : "OFF");
\r
615 text_out16(x + col2_offs, y, "%i", *(int *)ent->var);
\r
617 case MB_OPT_CUSTOM:
\r
618 case MB_OPT_CUSTONOFF:
\r
619 case MB_OPT_CUSTRANGE:
\r
622 if (ent->generate_name)
\r
623 name = ent->generate_name(ent->id, &offs);
\r
625 text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", name);
\r
628 names = (const char **)ent->data;
\r
629 for (i = 0; names[i] != NULL; i++) {
\r
630 offs = x + col2_offs;
\r
631 len = strlen(names[i]);
\r
633 offs += (10 - len) * me_mfont_w;
\r
634 if (offs < leftname_end)
\r
635 offs = leftname_end;
\r
636 if (i == *(int *)ent->var) {
\r
637 text_out16(offs, y, "%s", names[i]);
\r
649 /* display help or message if we have one */
\r
650 h = (g_menuscreen_h - h) / 2; // bottom area height
\r
651 if (menu_error_msg[0] != 0) {
\r
652 if (h >= me_mfont_h + 4)
\r
653 text_out16(5, g_menuscreen_h - me_mfont_h - 4, "%s", menu_error_msg);
\r
655 lprintf("menu msg doesn't fit!\n");
\r
657 if (plat_get_ticks_ms() - menu_error_time > 2048)
\r
658 menu_error_msg[0] = 0;
\r
660 else if (ent_sel->help != NULL) {
\r
661 const char *tmp = ent_sel->help;
\r
663 for (l = 0; tmp != NULL && *tmp != 0; l++)
\r
664 tmp = strchr(tmp + 1, '\n');
\r
665 if (h >= l * me_sfont_h + 4)
\r
666 for (tmp = ent_sel->help; l > 0; l--, tmp = strchr(tmp, '\n') + 1)
\r
667 smalltext_out16(5, g_menuscreen_h - (l * me_sfont_h + 4), tmp, 0xffff);
\r
672 if (draw_more != NULL)
\r
678 static int me_process(menu_entry *entry, int is_next, int is_lr)
\r
680 const char **names;
\r
682 switch (entry->beh)
\r
685 case MB_OPT_CUSTONOFF:
\r
686 me_toggle_onoff(entry);
\r
689 case MB_OPT_CUSTRANGE:
\r
690 c = is_lr ? 10 : 1;
\r
691 *(int *)entry->var += is_next ? c : -c;
\r
692 if (*(int *)entry->var < (int)entry->min)
\r
693 *(int *)entry->var = (int)entry->max;
\r
694 if (*(int *)entry->var > (int)entry->max)
\r
695 *(int *)entry->var = (int)entry->min;
\r
698 names = (const char **)entry->data;
\r
699 for (c = 0; names[c] != NULL; c++)
\r
701 *(int *)entry->var += is_next ? 1 : -1;
\r
702 if (*(int *)entry->var < 0)
\r
703 *(int *)entry->var = 0;
\r
704 if (*(int *)entry->var >= c)
\r
705 *(int *)entry->var = c - 1;
\r
712 static void debug_menu_loop(void);
\r
714 static int me_loop_d(menu_entry *menu, int *menu_sel, void (*draw_prep)(void), void (*draw_more)(void))
\r
716 int ret = 0, inp, sel = *menu_sel, menu_sel_max;
\r
718 menu_sel_max = me_count(menu) - 1;
\r
719 if (menu_sel_max < 0) {
\r
720 lprintf("no enabled menu entries\n");
\r
724 while ((!menu[sel].enabled || !menu[sel].selectable) && sel < menu_sel_max)
\r
727 /* make sure action buttons are not pressed on entering menu */
\r
728 me_draw(menu, sel, NULL);
\r
729 while (in_menu_wait_any(NULL, 50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU));
\r
733 if (draw_prep != NULL)
\r
736 me_draw(menu, sel, draw_more);
\r
737 inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|
\r
738 PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, NULL, 70);
\r
739 if (inp & (PBTN_MENU|PBTN_MBACK))
\r
742 if (inp & PBTN_UP ) {
\r
746 sel = menu_sel_max;
\r
748 while (!menu[sel].enabled || !menu[sel].selectable);
\r
750 if (inp & PBTN_DOWN) {
\r
753 if (sel > menu_sel_max)
\r
756 while (!menu[sel].enabled || !menu[sel].selectable);
\r
759 /* a bit hacky but oh well */
\r
760 if ((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R))
\r
763 if (inp & (PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R)) { /* multi choice */
\r
764 if (me_process(&menu[sel], (inp & (PBTN_RIGHT|PBTN_R)) ? 1 : 0,
\r
765 inp & (PBTN_L|PBTN_R)))
\r
769 if (inp & (PBTN_MOK|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R))
\r
771 /* require PBTN_MOK for MB_NONE */
\r
772 if (menu[sel].handler != NULL && (menu[sel].beh != MB_NONE || (inp & PBTN_MOK))) {
\r
773 ret = menu[sel].handler(menu[sel].id, inp);
\r
775 menu_sel_max = me_count(menu) - 1; /* might change, so update */
\r
784 static int me_loop(menu_entry *menu, int *menu_sel)
\r
786 return me_loop_d(menu, menu_sel, NULL, NULL);
\r
789 /* ***************************************** */
\r
791 static void draw_menu_message(const char *msg, void (*draw_more)(void))
\r
793 int x, y, h, w, wt;
\r
797 for (h = 1, w = 0; *p != 0; h++) {
\r
798 for (wt = 0; *p != 0 && *p != '\n'; p++)
\r
808 x = g_menuscreen_w / 2 - w * me_mfont_w / 2;
\r
809 y = g_menuscreen_h / 2 - h * me_mfont_h / 2;
\r
813 menu_draw_begin(1, 0);
\r
815 for (p = msg; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) {
\r
816 text_out16(x, y, "%s", p);
\r
818 for (; *p != 0 && *p != '\n'; p++)
\r
826 if (draw_more != NULL)
\r
832 // -------------- del confirm ---------------
\r
834 static void do_delete(const char *fpath, const char *fname)
\r
840 menu_draw_begin(1, 0);
\r
842 len = strlen(fname);
\r
843 if (len > g_menuscreen_w / me_sfont_w)
\r
844 len = g_menuscreen_w / me_sfont_w;
\r
846 mid = g_menuscreen_w / 2;
\r
847 text_out16(mid - me_mfont_w * 15 / 2, 8 * me_mfont_h, "About to delete");
\r
848 smalltext_out16(mid - len * me_sfont_w / 2, 9 * me_mfont_h + 5, fname, 0xbdff);
\r
849 text_out16(mid - me_mfont_w * 13 / 2, 11 * me_mfont_h, "Are you sure?");
\r
851 nm = in_get_key_name(-1, -PBTN_MA3);
\r
852 snprintf(tmp, sizeof(tmp), "(%s - confirm, ", nm);
\r
854 nm = in_get_key_name(-1, -PBTN_MBACK);
\r
855 snprintf(tmp + len, sizeof(tmp) - len, "%s - cancel)", nm);
\r
858 text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, "%s", tmp);
\r
861 while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MA2));
\r
862 inp = in_menu_wait(PBTN_MA3|PBTN_MBACK, NULL, 100);
\r
863 if (inp & PBTN_MA3)
\r
867 // -------------- ROM selector --------------
\r
869 static void draw_dirlist(char *curdir, struct dirent **namelist,
\r
870 int n, int sel, int show_help)
\r
872 int max_cnt, start, i, x, pos;
\r
876 max_cnt = g_menuscreen_h / me_sfont_h;
\r
877 start = max_cnt / 2 - sel;
\r
879 menu_draw_begin(1, 1);
\r
881 // if (!rom_loaded)
\r
882 // menu_darken_bg(gp2x_screen, 320*240, 0);
\r
884 darken_ptr = (short *)g_menuscreen_ptr + g_menuscreen_pp * max_cnt/2 * me_sfont_h;
\r
885 menu_darken_bg(darken_ptr, darken_ptr, g_menuscreen_pp * me_sfont_h * 8 / 10, 0);
\r
887 x = 5 + me_mfont_w + 1;
\r
888 if (start - 2 >= 0)
\r
889 smalltext_out16(14, (start - 2) * me_sfont_h, curdir, 0xffff);
\r
890 for (i = 0; i < n; i++) {
\r
892 if (pos < 0) continue;
\r
893 if (pos >= max_cnt) break;
\r
894 if (namelist[i]->d_type == DT_DIR) {
\r
895 smalltext_out16(x, pos * me_sfont_h, "/", 0xfff6);
\r
896 smalltext_out16(x + me_sfont_w, pos * me_sfont_h, namelist[i]->d_name, 0xfff6);
\r
898 unsigned short color = fname2color(namelist[i]->d_name);
\r
899 smalltext_out16(x, pos * me_sfont_h, namelist[i]->d_name, color);
\r
902 smalltext_out16(5, max_cnt/2 * me_sfont_h, ">", 0xffff);
\r
905 darken_ptr = (short *)g_menuscreen_ptr
\r
906 + g_menuscreen_pp * (g_menuscreen_h - me_sfont_h * 5 / 2);
\r
907 menu_darken_bg(darken_ptr, darken_ptr,
\r
908 g_menuscreen_pp * (me_sfont_h * 5 / 2), 1);
\r
910 snprintf(buff, sizeof(buff), "%s - select, %s - back",
\r
911 in_get_key_name(-1, -PBTN_MOK), in_get_key_name(-1, -PBTN_MBACK));
\r
912 smalltext_out16(x, g_menuscreen_h - me_sfont_h * 3 - 2, buff, 0xe78c);
\r
914 snprintf(buff, sizeof(buff), g_menu_filter_off ?
\r
915 "%s - hide unknown files" : "%s - show all files",
\r
916 in_get_key_name(-1, -PBTN_MA3));
\r
917 smalltext_out16(x, g_menuscreen_h - me_sfont_h * 2 - 2, buff, 0xe78c);
\r
919 snprintf(buff, sizeof(buff), g_autostateld_opt ?
\r
920 "%s - autoload save is ON" : "%s - autoload save is OFF",
\r
921 in_get_key_name(-1, -PBTN_MA2));
\r
922 smalltext_out16(x, g_menuscreen_h - me_sfont_h * 1 - 2, buff, 0xe78c);
\r
928 static int scandir_cmp(const void *p1, const void *p2)
\r
930 const struct dirent **d1 = (const struct dirent **)p1;
\r
931 const struct dirent **d2 = (const struct dirent **)p2;
\r
933 if ((p = (*d1)->d_name)[0] == '.' && p[1] == '.' && p[2] == 0)
\r
934 return -1; // ".." first
\r
935 if ((p = (*d2)->d_name)[0] == '.' && p[1] == '.' && p[2] == 0)
\r
937 if ((*d1)->d_type == (*d2)->d_type)
\r
938 return alphasort(d1, d2);
\r
939 if ((*d1)->d_type == DT_DIR)
\r
940 return -1; // directories before files/links
\r
941 if ((*d2)->d_type == DT_DIR)
\r
944 return alphasort(d1, d2);
\r
947 static const char **filter_exts_internal;
\r
949 static int scandir_filter(const struct dirent *ent)
\r
951 const char **filter = filter_exts_internal;
\r
958 switch (ent->d_type) {
\r
960 // leave out useless reference to current directory
\r
961 return strcmp(ent->d_name, ".") != 0;
\r
964 // could be a dir, deal with it later..
\r
968 ext = strrchr(ent->d_name, '.');
\r
973 for (i = 0; filter[i] != NULL; i++)
\r
974 if (strcasecmp(ext, filter[i]) == 0)
\r
980 static int dirent_seek_char(struct dirent **namelist, int len, int sel, char c)
\r
984 for (i = sel + 1; ; i++) {
\r
990 if (tolower_simple(namelist[i]->d_name[0]) == c)
\r
997 static const char *menu_loop_romsel_d(char *curr_path, int len,
\r
998 const char **filter_exts,
\r
999 int (*extra_filter)(struct dirent **namelist, int count,
\r
1000 const char *basedir),
\r
1001 void (*draw_prep)(void))
\r
1003 static char rom_fname_reload[256]; // used for scratch and return
\r
1004 char sel_fname[256];
\r
1005 int (*filter)(const struct dirent *);
\r
1006 struct dirent **namelist = NULL;
\r
1007 int n = 0, inp = 0, sel = 0, show_help = 0;
\r
1008 char *curr_path_restore = NULL;
\r
1009 const char *ret = NULL;
\r
1013 filter_exts_internal = filter_exts;
\r
1016 // is this a dir or a full path?
\r
1017 if (!plat_is_dir(curr_path)) {
\r
1018 char *p = strrchr(curr_path, '/');
\r
1021 curr_path_restore = p;
\r
1022 snprintf(sel_fname, sizeof(sel_fname), "%s", p + 1);
\r
1028 if (namelist != NULL) {
\r
1031 free(namelist[n]);
\r
1037 if (!g_menu_filter_off)
\r
1038 filter = scandir_filter;
\r
1040 n = scandir(curr_path, &namelist, filter, (void *)scandir_cmp);
\r
1041 if (n < 0 || !namelist) {
\r
1042 lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);
\r
1045 plat_get_data_dir(curr_path, len);
\r
1046 n = scandir(curr_path, &namelist, filter, (void *)scandir_cmp);
\r
1047 if (n < 0 || !namelist) {
\r
1048 // oops, we failed
\r
1049 lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);
\r
1050 namelist = malloc(sizeof(*namelist));
\r
1051 namelist[0] = calloc(1, sizeof(**namelist));
\r
1055 // try to resolve DT_UNKNOWN and symlinks
\r
1056 for (i = 0; i < n; i++) {
\r
1060 if (namelist[i]->d_type == DT_REG || namelist[i]->d_type == DT_DIR)
\r
1063 r = strlen(curr_path);
\r
1064 slash = (r && curr_path[r-1] == '/') ? "" : "/";
\r
1065 snprintf(rom_fname_reload, sizeof(rom_fname_reload),
\r
1066 "%s%s%s", curr_path, slash, namelist[i]->d_name);
\r
1067 r = stat(rom_fname_reload, &st);
\r
1070 if (S_ISREG(st.st_mode))
\r
1071 namelist[i]->d_type = DT_REG;
\r
1072 else if (S_ISDIR(st.st_mode))
\r
1073 namelist[i]->d_type = DT_DIR;
\r
1077 if (!g_menu_filter_off && extra_filter != NULL)
\r
1078 n = extra_filter(namelist, n, curr_path);
\r
1081 qsort(namelist, n, sizeof(namelist[0]), scandir_cmp);
\r
1083 // try to find selected file
\r
1085 if (sel_fname[0] != 0) {
\r
1086 for (i = 0; i < n; i++) {
\r
1087 char *dname = namelist[i]->d_name;
\r
1088 if (dname[0] == sel_fname[0] && strcmp(dname, sel_fname) == 0) {
\r
1095 /* make sure action buttons are not pressed on entering menu */
\r
1096 draw_dirlist(curr_path, namelist, n, sel, show_help);
\r
1097 while (in_menu_wait_any(NULL, 50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU))
\r
1102 if (draw_prep != NULL)
\r
1104 draw_dirlist(curr_path, namelist, n, sel, show_help);
\r
1105 inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT
\r
1106 | PBTN_L|PBTN_R|PBTN_MA2|PBTN_MA3|PBTN_MOK|PBTN_MBACK
\r
1107 | PBTN_MENU|PBTN_CHAR, &cinp, 33);
\r
1108 if (inp & PBTN_MA3) {
\r
1109 g_menu_filter_off = !g_menu_filter_off;
\r
1110 snprintf(sel_fname, sizeof(sel_fname), "%s",
\r
1111 namelist[sel]->d_name);
\r
1115 int last = n ? n-1 : 0;
\r
1116 if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = last; }
\r
1117 else if (inp & PBTN_DOWN) { sel++; if (sel > n-1) sel = 0; }
\r
1118 else if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
\r
1119 else if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-1) sel = last; }
\r
1120 else if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }
\r
1121 else if (inp & PBTN_R) { sel+=24; if (sel > n-1) sel = last; }
\r
1123 else if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_MA2)) == (PBTN_MENU|PBTN_MA2))
\r
1125 if (namelist[sel]->d_type == DT_REG)
\r
1127 int l = strlen(curr_path);
\r
1128 char *slash = l && curr_path[l-1] == '/' ? "" : "/";
\r
1129 snprintf(rom_fname_reload, sizeof(rom_fname_reload),
\r
1130 "%s%s%s", curr_path, slash, namelist[sel]->d_name);
\r
1131 if (inp & PBTN_MOK) { // return sel
\r
1132 ret = rom_fname_reload;
\r
1135 do_delete(rom_fname_reload, namelist[sel]->d_name);
\r
1138 else if (namelist[sel]->d_type == DT_DIR)
\r
1142 if (!(inp & PBTN_MOK))
\r
1144 newlen = strlen(curr_path) + strlen(namelist[sel]->d_name) + 2;
\r
1145 newdir = malloc(newlen);
\r
1146 if (newdir == NULL)
\r
1148 if (strcmp(namelist[sel]->d_name, "..") == 0) {
\r
1149 char *start = curr_path;
\r
1150 p = start + strlen(start) - 1;
\r
1151 while (*p == '/' && p > start) p--;
\r
1152 while (*p != '/' && p > start) p--;
\r
1153 if (p <= start) plat_get_data_dir(newdir, newlen);
\r
1154 else { strncpy(newdir, start, p-start); newdir[p-start] = 0; }
\r
1156 strcpy(newdir, curr_path);
\r
1157 p = newdir + strlen(newdir) - 1;
\r
1158 while (*p == '/' && p >= newdir) *p-- = 0;
\r
1159 strcat(newdir, "/");
\r
1160 strcat(newdir, namelist[sel]->d_name);
\r
1162 ret = menu_loop_romsel_d(newdir, newlen, filter_exts, extra_filter, draw_prep);
\r
1167 else if (inp & PBTN_MA2) {
\r
1168 g_autostateld_opt = !g_autostateld_opt;
\r
1171 else if (inp & PBTN_CHAR) {
\r
1173 sel = dirent_seek_char(namelist, n, sel, cinp);
\r
1176 if (inp & PBTN_MBACK)
\r
1179 if (show_help > 0)
\r
1185 free(namelist[n]);
\r
1189 // restore curr_path
\r
1190 if (curr_path_restore != NULL)
\r
1191 *curr_path_restore = '/';
\r
1196 static const char *menu_loop_romsel(char *curr_path, int len,
\r
1197 const char **filter_exts,
\r
1198 int (*extra_filter)(struct dirent **namelist, int count,
\r
1199 const char *basedir))
\r
1201 return menu_loop_romsel_d(curr_path, len, filter_exts, extra_filter, NULL);
\r
1204 // ------------ savestate loader ------------
\r
1206 #define STATE_SLOT_COUNT 10
\r
1208 static int state_slot_flags = 0;
\r
1209 static int state_slot_times[STATE_SLOT_COUNT];
\r
1211 static void state_check_slots(void)
\r
1215 state_slot_flags = 0;
\r
1217 for (slot = 0; slot < STATE_SLOT_COUNT; slot++) {
\r
1218 state_slot_times[slot] = 0;
\r
1219 if (emu_check_save_file(slot, &state_slot_times[slot]))
\r
1220 state_slot_flags |= 1 << slot;
\r
1224 static void draw_savestate_bg(int slot);
\r
1226 static void draw_savestate_menu(int menu_sel, int is_loading)
\r
1228 int i, x, y, w, h;
\r
1229 char time_buf[32];
\r
1231 if (state_slot_flags & (1 << menu_sel))
\r
1232 draw_savestate_bg(menu_sel);
\r
1234 w = (13 + 2) * me_mfont_w;
\r
1235 h = (1+2+STATE_SLOT_COUNT+1) * me_mfont_h;
\r
1236 x = g_menuscreen_w / 2 - w / 2;
\r
1238 y = g_menuscreen_h / 2 - h / 2;
\r
1240 #ifdef MENU_ALIGN_LEFT
\r
1241 if (x > 12 + me_mfont_w * 2)
\r
1242 x = 12 + me_mfont_w * 2;
\r
1245 menu_draw_begin(1, 1);
\r
1247 text_out16(x, y, is_loading ? "Load state" : "Save state");
\r
1248 y += 3 * me_mfont_h;
\r
1250 menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (23 + 2) * me_mfont_w + 4);
\r
1252 /* draw all slots */
\r
1253 for (i = 0; i < STATE_SLOT_COUNT; i++, y += me_mfont_h)
\r
1255 if (!(state_slot_flags & (1 << i)))
\r
1256 strcpy(time_buf, "free");
\r
1258 strcpy(time_buf, "USED");
\r
1259 if (state_slot_times[i] != 0) {
\r
1260 time_t time = state_slot_times[i];
\r
1261 struct tm *t = localtime(&time);
\r
1262 strftime(time_buf, sizeof(time_buf), "%x %R", t);
\r
1266 text_out16(x, y, "SLOT %i (%s)", i, time_buf);
\r
1268 text_out16(x, y, "back");
\r
1273 static int menu_loop_savestate(int is_loading)
\r
1275 static int menu_sel = STATE_SLOT_COUNT;
\r
1276 int menu_sel_max = STATE_SLOT_COUNT;
\r
1277 unsigned long inp = 0;
\r
1280 state_check_slots();
\r
1282 if (!(state_slot_flags & (1 << menu_sel)) && is_loading)
\r
1283 menu_sel = menu_sel_max;
\r
1287 draw_savestate_menu(menu_sel, is_loading);
\r
1288 inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK, NULL, 100);
\r
1289 if (inp & PBTN_UP) {
\r
1293 menu_sel = menu_sel_max;
\r
1294 } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
\r
1296 if (inp & PBTN_DOWN) {
\r
1299 if (menu_sel > menu_sel_max)
\r
1301 } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
\r
1303 if (inp & PBTN_MOK) { // save/load
\r
1304 if (menu_sel < STATE_SLOT_COUNT) {
\r
1305 state_slot = menu_sel;
\r
1306 if (emu_save_load_game(is_loading, 0)) {
\r
1307 menu_update_msg(is_loading ? "Load failed" : "Save failed");
\r
1315 if (inp & PBTN_MBACK)
\r
1322 // -------------- key config --------------
\r
1324 static char *action_binds(int player_idx, int action_mask, int dev_id)
\r
1326 int dev = 0, dev_last = IN_MAX_DEVS - 1;
\r
1327 int can_combo = 1, type;
\r
1329 static_buff[0] = 0;
\r
1331 type = IN_BINDTYPE_EMU;
\r
1332 if (player_idx >= 0) {
\r
1334 type = IN_BINDTYPE_PLAYER12 + (player_idx >> 1);
\r
1335 if (player_idx & 1)
\r
1336 action_mask <<= 16;
\r
1340 dev = dev_last = dev_id;
\r
1342 for (; dev <= dev_last; dev++) {
\r
1343 int k, count = 0, combo = 0;
\r
1346 binds = in_get_dev_binds(dev);
\r
1347 if (binds == NULL)
\r
1350 in_get_config(dev, IN_CFG_BIND_COUNT, &count);
\r
1351 in_get_config(dev, IN_CFG_DOES_COMBOS, &combo);
\r
1352 combo = combo && can_combo;
\r
1354 for (k = 0; k < count; k++) {
\r
1355 const char *xname;
\r
1358 if (!(binds[IN_BIND_OFFS(k, type)] & action_mask))
\r
1361 xname = in_get_key_name(dev, k);
\r
1362 len = strlen(static_buff);
\r
1364 strncat(static_buff, combo ? " + " : ", ",
\r
1365 sizeof(static_buff) - len - 1);
\r
1366 len += combo ? 3 : 2;
\r
1368 strncat(static_buff, xname, sizeof(static_buff) - len - 1);
\r
1372 return static_buff;
\r
1375 static int count_bound_keys(int dev_id, int action_mask, int bindtype)
\r
1381 binds = in_get_dev_binds(dev_id);
\r
1382 if (binds == NULL)
\r
1385 in_get_config(dev_id, IN_CFG_BIND_COUNT, &count);
\r
1386 for (k = 0; k < count; k++)
\r
1388 if (binds[IN_BIND_OFFS(k, bindtype)] & action_mask)
\r
1395 static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx,
\r
1396 int sel, int dev_id, int dev_count, int is_bind)
\r
1398 char buff[64], buff2[32];
\r
1399 const char *dev_name;
\r
1402 w = ((player_idx >= 0) ? 20 : 30) * me_mfont_w;
\r
1403 x = g_menuscreen_w / 2 - w / 2;
\r
1404 y = (g_menuscreen_h - 4 * me_mfont_h) / 2 - (2 + opt_cnt) * me_mfont_h / 2;
\r
1405 if (x < me_mfont_w * 2)
\r
1406 x = me_mfont_w * 2;
\r
1409 menu_draw_begin(1, 0);
\r
1410 if (player_idx >= 0)
\r
1411 text_out16(x, y, "Player %i controls", player_idx + 1);
\r
1413 text_out16(x, y, "Emulator controls");
\r
1415 y += 2 * me_mfont_h;
\r
1416 menu_draw_selection(x - me_mfont_w * 2, y + sel * me_mfont_h, w + 2 * me_mfont_w);
\r
1418 for (i = 0; i < opt_cnt; i++, y += me_mfont_h)
\r
1419 text_out16(x, y, "%s : %s", opts[i].name,
\r
1420 action_binds(player_idx, opts[i].mask, dev_id));
\r
1422 menu_separation();
\r
1425 dev_name = "(all devices)";
\r
1427 dev_name = in_get_dev_name(dev_id, 0, 1);
\r
1428 w = strlen(dev_name) * me_mfont_w;
\r
1429 if (w < 30 * me_mfont_w)
\r
1430 w = 30 * me_mfont_w;
\r
1431 if (w > g_menuscreen_w)
\r
1432 w = g_menuscreen_w;
\r
1434 x = g_menuscreen_w / 2 - w / 2;
\r
1437 snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK));
\r
1438 snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2,
\r
1439 in_get_key_name(-1, -PBTN_MA2));
\r
1440 text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "%s", buff);
\r
1443 text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "Press a button to bind/unbind");
\r
1445 if (dev_count > 1) {
\r
1446 text_out16(x, g_menuscreen_h - 3 * me_mfont_h, "%s", dev_name);
\r
1447 text_out16(x, g_menuscreen_h - 2 * me_mfont_h, "Press left/right for other devs");
\r
1453 static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx)
\r
1455 int i, sel = 0, menu_sel_max = opt_cnt - 1, does_combos = 0;
\r
1456 int dev_id, bind_dev_id, dev_count, kc, is_down, mkey;
\r
1457 int unbind, bindtype, mask_shift;
\r
1459 for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) {
\r
1460 if (in_get_dev_name(i, 1, 0) != NULL) {
\r
1467 if (dev_id == -1) {
\r
1468 lprintf("no devs, can't do config\n");
\r
1472 dev_id = -1; // show all
\r
1474 if (player_idx >= 0) {
\r
1475 if (player_idx & 1)
\r
1477 bindtype = IN_BINDTYPE_PLAYER12 + (player_idx >> 1);
\r
1479 bindtype = IN_BINDTYPE_EMU;
\r
1483 draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0);
\r
1484 mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT
\r
1485 |PBTN_MBACK|PBTN_MOK|PBTN_MA2, NULL, 100);
\r
1487 case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue;
\r
1488 case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue;
\r
1490 for (i = 0, dev_id--; i < IN_MAX_DEVS + 1; i++, dev_id--) {
\r
1492 dev_id = IN_MAX_DEVS - 1;
\r
1493 if (dev_id == -1 || in_get_dev_name(dev_id, 0, 0) != NULL)
\r
1498 for (i = 0, dev_id++; i < IN_MAX_DEVS; i++, dev_id++) {
\r
1499 if (dev_id >= IN_MAX_DEVS)
\r
1501 if (dev_id == -1 || in_get_dev_name(dev_id, 0, 0) != NULL)
\r
1508 if (sel >= opt_cnt)
\r
1510 while (in_menu_wait_any(NULL, 30) & PBTN_MOK)
\r
1514 in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype);
\r
1519 draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 1);
\r
1521 /* wait for some up event */
\r
1522 for (is_down = 1; is_down; )
\r
1523 kc = in_update_keycode(&bind_dev_id, &is_down, NULL, -1);
\r
1525 i = count_bound_keys(bind_dev_id, opts[sel].mask << mask_shift, bindtype);
\r
1528 /* allow combos if device supports them */
\r
1529 in_get_config(bind_dev_id, IN_CFG_DOES_COMBOS, &does_combos);
\r
1530 if (i == 1 && bindtype == IN_BINDTYPE_EMU && does_combos)
\r
1534 in_unbind_all(bind_dev_id, opts[sel].mask << mask_shift, bindtype);
\r
1536 in_bind_key(bind_dev_id, kc, opts[sel].mask << mask_shift, bindtype, 0);
\r
1538 // make sure bind change is displayed
\r
1540 dev_id = bind_dev_id;
\r