diff --git a/gx/config.c b/gx/config.c index 668fa3a..2c6b9f2 100644 --- a/gx/config.c +++ b/gx/config.c @@ -162,6 +162,8 @@ void config_default(void) #ifdef HW_RVL config.trap = 0; config.gamma = VI_GM_1_0 / 10.0; +#else + config.v_prog = 1; #endif /* NTSC filter options */ @@ -183,25 +185,31 @@ void config_default(void) /* menu options */ config.autoload = 0; config.autocheat = 0; -#ifdef HW_RVL config.s_auto = 1; - config.autosleep = 1; -#else - config.s_auto = 0; - config.v_prog = 1; -#endif config.s_default = 1; config.s_device = 0; config.bg_overlay = 0; config.screen_w = 658; config.bgm_volume = 100.0; config.sfx_volume = 100.0; +#ifdef HW_RVL + config.autosleep = 1; + config.calx = 0; + config.caly = 0; +#endif /* default ROM directories */ #ifdef HW_RVL - char dir[16]; - getcwd(dir, 16); - config.l_device = strstr(dir, "sd") ? TYPE_SD : TYPE_USB; + DIR *dir = opendir("sd:/"); + if (dir) + { + config.l_device = TYPE_SD; + closedir(dir); + } + else + { + config.l_device = TYPE_USB; + } sprintf (config.lastdir[0][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); diff --git a/gx/config.h b/gx/config.h index ddf1fb1..30b6be4 100644 --- a/gx/config.h +++ b/gx/config.h @@ -98,6 +98,8 @@ typedef struct #ifdef HW_RVL uint32 wpad_keymap[4*3][MAX_KEYS]; uint8 autosleep; + int32 calx; + int32 caly; #endif uint8 autoload; uint8 autocheat; diff --git a/gx/gui/menu.c b/gx/gui/menu.c index 233ba4c..50c7867 100644 --- a/gx/gui/menu.c +++ b/gx/gui/menu.c @@ -401,7 +401,7 @@ static gui_item items_video[16] = /* Menu options */ #ifdef HW_RVL -static gui_item items_prefs[12] = +static gui_item items_prefs[13] = #else static gui_item items_prefs[11] = #endif @@ -419,6 +419,7 @@ static gui_item items_prefs[11] = {NULL,NULL,"Show FPS: OFF", "Enable/disable FPS counter", 56,132,276,48}, #ifdef HW_RVL {NULL,NULL,"Wiimote Timeout: OFF","Enable/disable Wii remote automatic shutodwn", 56,132,276,48}, + {NULL,NULL,"Wiimote Calibration: AUTO","Calibrate Wii remote pointer", 56,132,276,48}, #endif }; @@ -698,8 +699,10 @@ static void prefmenu () sprintf (items[9].text, "Show CD Leds: %s", config.cd_leds ? "ON":"OFF"); sprintf (items[10].text, "Show FPS: %s", config.fps ? "ON":"OFF"); #ifdef HW_RVL - sprintf (items[11].text, "Wiimote Timeout: %s", config.autosleep ? "5min":"30min"); - m->max_items = 12; + sprintf (items[11].text, "Wiimote Timeout: %s", config.autosleep ? "5 MIN":"30 MIN"); + sprintf (items[12].text, "Wiimote Calibration: %s", ((config.calx * config.caly) != 0) ? "MANUAL":"AUTO"); + sprintf (items[12].comment, "%s", ((config.calx * config.caly) != 0) ? "Reset default Wii remote pointer calibration":"Calibrate Wii remote pointer"); + m->max_items = 13; #else m->max_items = 11; #endif @@ -803,6 +806,25 @@ static void prefmenu () sprintf (items[11].text, "Wiimote Timeout: %s", config.autosleep ? "5min":"30min"); WPAD_SetIdleTimeout(config.autosleep ? 300 : 1800); break; + + case 12: /*** Wii remote pointer calibration ***/ + if ((config.calx * config.caly) == 0) + { + sprintf (items[12].text, "Wiimote Calibration: MANUAL"); + sprintf (items[12].comment, "Reset default Wii remote pointer calibration"); + GUI_WaitConfirm("Pointer Calibration","Aim center of TV screen"); + config.calx = 320 - m_input.ir.x; + config.caly = 240 - m_input.ir.y; + m_input.ir.x = 320; + m_input.ir.y = 240; + } + else + { + sprintf (items[12].text, "Wiimote Calibration: AUTO"); + sprintf (items[12].comment, "Calibrate Wii remote pointer"); + config.calx = config.caly = 0; + } + break; #endif case -1: diff --git a/gx/gx_input.c b/gx/gx_input.c index b0eeda3..3f9af41 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -858,8 +858,8 @@ static void wpad_update(s8 chan, u8 i, u32 exp) if (ir.valid) { /* screen position */ - input.analog[i][0] = (ir.x * bitmap.viewport.w) / 640; - input.analog[i][1] = (ir.y * bitmap.viewport.h) / 480; + input.analog[i][0] = ((ir.x + config.calx) * bitmap.viewport.w) / 640; + input.analog[i][1] = ((ir.y + config.caly) * bitmap.viewport.h) / 480; } else { @@ -968,8 +968,8 @@ static void wpad_update(s8 chan, u8 i, u32 exp) WPAD_IR(chan, &ir); if (ir.valid) { - input.analog[0][0] = 0x3c + (ir.x * (0x17c - 0x3c + 1)) / 640; - input.analog[0][1] = 0x1fc + (ir.y * (0x3f3 - 0x1fc + 1)) / 480; + input.analog[0][0] = 0x3c + ((ir.x + config.calx) * (0x17c - 0x3c + 1)) / 640; + input.analog[0][1] = 0x1fc + ((ir.y + config.caly) * (0x3f3 - 0x1fc + 1)) / 480; } } @@ -1004,8 +1004,8 @@ static void wpad_update(s8 chan, u8 i, u32 exp) WPAD_IR(chan, &ir); if (ir.valid) { - input.analog[0][0] = (ir.x * 250) / 640; - input.analog[0][1] = (ir.y * 250) / 480; + input.analog[0][0] = ((ir.x + config.calx) * 250) / 640; + input.analog[0][1] = ((ir.y + config.caly) * 250) / 480; } } @@ -1582,6 +1582,10 @@ void gx_input_UpdateMenu(void) else if (pw & (WPAD_BUTTON_DOWN|WPAD_CLASSIC_BUTTON_DOWN)) pp |= PAD_BUTTON_DOWN; else if (pw & (WPAD_BUTTON_LEFT|WPAD_CLASSIC_BUTTON_LEFT)) pp |= PAD_BUTTON_LEFT; else if (pw & (WPAD_BUTTON_RIGHT|WPAD_CLASSIC_BUTTON_RIGHT)) pp |= PAD_BUTTON_RIGHT; + + /* Wiimote pointer user calibration */ + m_input.ir.x += config.calx; + m_input.ir.y += config.caly; } else {