From aa1bb0055c80ca8c01ba74e15706c9a44c2a8dc8 Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sat, 3 Jan 2015 17:52:36 +0000 Subject: [PATCH] Rumble option for single wiimote and moved in Wiimote menu --- src/cfgfile.c | 9 +++++--- src/gui-sdl/gui-sdl.c | 54 ++++++++++++++++++++++--------------------- src/gui-sdl/menu.c | 2 +- src/include/options.h | 2 +- src/jd-sdl/joystick.c | 16 +++++++++---- 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/cfgfile.c b/src/cfgfile.c index 205d283..983d2ef 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -557,7 +557,8 @@ void save_options (FILE *f, const struct uae_prefs *p, int type) #if defined GEKKO //cfgfile_write (f, "wii_use_mario_kart_wheel=%s\n", p->use_wheel_input ? "yes" : "no"); cfgfile_write (f, "wii_port=%d\n", p->Port); - cfgfile_write (f, "rumble=%s\n", p->rumble? "true" : "false"); + cfgfile_write (f, "rumble1=%s\n", p->rumble[0]? "true" : "false"); + cfgfile_write (f, "rumble2=%s\n", p->rumble[1]? "true" : "false"); cfgfile_write (f, "gfx_correct_ratio=%d\n", p->gfx_correct_ratio); #endif @@ -875,7 +876,8 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) //return 1; if (cfgfile_intval (option, value, "wii_port", &p->Port, 1)) return 1; if (cfgfile_yesno (option, value, "smb_enable", &p->smb_enable)) return 1; - if (cfgfile_yesno (option, value, "rumble", &p->rumble)) return 1; + if (cfgfile_yesno (option, value, "rumble1", &p->rumble[0])) return 1; + if (cfgfile_yesno (option, value, "rumble2", &p->rumble[1])) return 1; if (cfgfile_string (option, value, "user", p->SmbUser, 32) || cfgfile_string (option, value, "password", p->SmbPwd,32) || cfgfile_string (option, value, "share_name", p->SmbShare, 32) @@ -2519,7 +2521,8 @@ void default_prefs (struct uae_prefs *p, int type) strcpy (p->SmbShare, "Share"); strcpy (p->SmbIp, "192.168.0.1"); p->Port= PORT_DEFAULT; - p->rumble= 0; + p->rumble[0]= 0; + p->rumble[1]= 0; p->gfx_correct_ratio = 100; p->write_logfile= 0; #endif diff --git a/src/gui-sdl/gui-sdl.c b/src/gui-sdl/gui-sdl.c index 4c41c15..78c05d7 100644 --- a/src/gui-sdl/gui-sdl.c +++ b/src/gui-sdl/gui-sdl.c @@ -63,18 +63,16 @@ static const char *main_menu_messages[] = { static const char *input_messages[] = { /*00*/ "Bind key to Wiimote", /*01*/ "^|1|2|-", - /*02*/ " ", - /*03*/ "Bind key to Nunchuk", - /*04*/ "^|Z|C", - /*05*/ " ", - /*06*/ "Bind key to Classic", - /*07*/ "^|a|b|x|y|L|R|Zl|Zr|-", - /*08*/ " ", - /*09*/ "Mario kart wheel (horizontal only)", - /*10*/ "^|On|Off", - /*11*/ " ", - /*12*/ "Mouse emulation", - /*13*/ "^|On|Off", + /*02*/ "Bind key to Nunchuk", + /*03*/ "^|Z|C", + /*04*/ "Bind key to Classic", + /*05*/ "^|a|b|x|y|L|R|Zl|Zr|-", + /*06*/ "Mario kart wheel (horizontal only)", + /*07*/ "^|On|Off", + /*08*/ "Mouse emulation", + /*09*/ "^|On|Off", + /*10*/ "Rumble", + /*11*/ "^|on|off", NULL }; @@ -189,8 +187,6 @@ static const char *other_messages[] = { /*11*/ "^|on|off", /*12*/ "Port", /*13*/ "^|DEFAULT|SD|USB|SMB", - /*14*/ "Rumble", - /*15*/ "^|on|off", NULL }; @@ -1127,7 +1123,8 @@ cfgfile_load(&changed_prefs, user_options, 0); fix_options_menu_sdl(0); currprefs.Port = changed_prefs.Port; currprefs.leds_on_screen = changed_prefs.leds_on_screen; -currprefs.rumble = changed_prefs.rumble; +currprefs.rumble[0] = changed_prefs.rumble[0]; +currprefs.rumble[1] = changed_prefs.rumble[1]; return 0; } @@ -1263,7 +1260,7 @@ extern int screen_is_picasso; static void other_options(void) { - int submenus[8]; + int submenus[7]; int opt, floppy_n, old_sub_3; memset(submenus, 0, sizeof(submenus)); @@ -1277,7 +1274,6 @@ static void other_options(void) submenus[4] = !(changed_prefs.gfx_linedbl == 2) ; submenus[5] = !changed_prefs.leds_on_screen; submenus[6] = changed_prefs.Port; - submenus[7] = !changed_prefs.rumble; opt = menu_select_title("Other options menu", other_messages, submenus); @@ -1295,9 +1291,8 @@ static void other_options(void) if (changed_prefs.gfx_width_win == 640) changed_prefs.gfx_linedbl = submenus[4] ? 1 : 2; changed_prefs.leds_on_screen = !submenus[5]; set_Port(submenus[6]); - changed_prefs.rumble = !submenus[7]; + currprefs.leds_on_screen = changed_prefs.leds_on_screen; - currprefs.rumble = changed_prefs.rumble; fix_options_menu_sdl(1); @@ -1417,21 +1412,21 @@ static void input_options(int joy) const int classic_to_sdl[] = {9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; int sdl_key = 1; const char *key; - int submenus[5]; + int submenus[6]; int opt; struct virtkey *virtualkey; memset(submenus, 0, sizeof(submenus)); submenus[3] = !changed_prefs.joystick_settings[1][joy].eventid[ID_AXIS_OFFSET + 6][0]; submenus[4] = (changed_prefs.mouse_settings[1][joy].enabled == 0); + submenus[5] = !changed_prefs.rumble[joy]; opt = menu_select_title("Input menu", input_messages, submenus); if (opt < 0) return; - /* Translate key to UAE key event name */ - if (opt == 9) + if (opt == 6) //Mario Kart Wheel { if (!submenus[3]){ if (!joy) insert_keyboard_map("JOY2_HORIZ","input.1.joystick.%d.axis.6", 0); @@ -1443,7 +1438,7 @@ static void input_options(int joy) return; } - if (opt == 12) + if (opt == 8) //Mouse emulation { if (submenus[4]) { @@ -1457,6 +1452,13 @@ static void input_options(int joy) return; } + if (opt == 10) //Rumble + { + changed_prefs.rumble[joy] = !submenus[5]; + currprefs.rumble[joy] = changed_prefs.rumble[joy]; + return; + } + virtualkey = virtkbd_get_key(); if (virtualkey == NULL) return; @@ -1466,9 +1468,9 @@ static void input_options(int joy) { case 0: /* wiimote */ sdl_key = wiimote_to_sdl[submenus[0]]; break; - case 3: /* nunchuk */ + case 2: /* nunchuk */ sdl_key = nunchuk_to_sdl[submenus[1]]; break; - case 6: /* classic */ + case 4: /* classic */ sdl_key = classic_to_sdl[submenus[2]]; break; default: /* can never happen */ break; @@ -1790,7 +1792,7 @@ void gui_display(int shortcut) break; case 15: if (msgYesNo("Are you sure to quit?", 0, FULL_DISPLAY_X /2-138/RATIO, FULL_DISPLAY_Y /2-48/RATIO)) - {currprefs.rumble=0; uae_quit(); exit = 1;} + {currprefs.rumble[0]=0; currprefs.rumble[1]=0;uae_quit(); exit = 1;} break; default: break; diff --git a/src/gui-sdl/menu.c b/src/gui-sdl/menu.c index ac4f829..e13a796 100644 --- a/src/gui-sdl/menu.c +++ b/src/gui-sdl/menu.c @@ -520,7 +520,7 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz SDL_FillRect(screen, &r_ext, SDL_MapRGB(screen->format, 116, 117, 206)); - SDL_BlitSurface(image_window, &r_int, real_screen, &r_int); + SDL_BlitSurface(image_window, &r_int, screen, &r_int); if ( p_menu->n_entries * line_height > p_menu->y2 ) y_start = p_menu->y1 + line_height; diff --git a/src/include/options.h b/src/include/options.h index 9c2eb8e..6b06250 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -253,7 +253,7 @@ struct uae_prefs { char SmbShare[32]; char SmbIp[32]; int Port; //SD, USB or SMB - int rumble; + int rumble[2]; int gfx_correct_ratio; #endif diff --git a/src/jd-sdl/joystick.c b/src/jd-sdl/joystick.c index 98b1955..33cb6a1 100644 --- a/src/jd-sdl/joystick.c +++ b/src/jd-sdl/joystick.c @@ -37,13 +37,15 @@ struct joyinfo joys[MAX_INPUT_DEVICES]; #ifdef GEKKO void Rumble(unsigned int nr, unsigned int i, int bs) { - static Uint32 last_ticks[MAX_INPUT_DEVICES]; + static Uint32 last_ticks[2]; Uint32 cur_ticks; - static bool rumble_on[MAX_INPUT_DEVICES]; - static bool fire_pressed[MAX_INPUT_DEVICES]; - static int joystickbutton_fire[MAX_INPUT_DEVICES]={-1,-1,-1,-1,-1,-1}; + static bool rumble_on[2]; + static bool fire_pressed[2]; + static int joystickbutton_fire[2]={-1,-1,-1,-1,-1,-1}; int kc; + if (nr>1) return; + cur_ticks = SDL_GetTicks(); kc = currprefs.joystick_settings[1][nr].eventid[i][0]; @@ -123,7 +125,11 @@ static void read_joy (unsigned int nr) int bs = SDL_JoystickGetButton (joy, i) ? 1 : 0; setjoybuttonstate (nr, i, bs); #ifdef GEKKO - if (!gui_is_active && currprefs.rumble) Rumble (nr,i, bs); + if (!gui_is_active) + { + if ((nr==0) && (currprefs.rumble[0])) Rumble (0,i, bs); + if ((nr==1) && (currprefs.rumble[1])) Rumble (1,i, bs); + } #endif } }