refresh controls immediately when rebinding instead of requiring emulator reboot

This commit is contained in:
zeromus 2011-04-06 05:43:59 +00:00
parent c6a0956f13
commit 046d815bd3
3 changed files with 40 additions and 7 deletions

View File

@ -307,6 +307,12 @@ namespace BizHawk.MultiClient
{ {
InputConfig i = new InputConfig(); InputConfig i = new InputConfig();
i.ShowDialog(); i.ShowDialog();
//re-initialize controls in case anything was changed
if (i.DialogResult == DialogResult.OK)
{
InitControls();
SyncControls();
}
} }
private void hotkeysToolStripMenuItem_Click(object sender, EventArgs e) private void hotkeysToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -442,6 +442,38 @@ namespace BizHawk.MultiClient
} }
} }
void SyncControls()
{
switch (Global.Game.System)
{
case "SG":
case "SMS":
Global.Emulator.Controller = Global.SMSControls;
break;
case "GG":
Global.Emulator.Controller = Global.SMSControls;
break;
case "PCE":
Global.Emulator.Controller = Global.PCEControls;
break;
case "SGX":
Global.Emulator.Controller = Global.PCEControls;
break;
case "GEN":
Global.Emulator.Controller = Global.GenControls;
break;
case "TI83":
Global.Emulator.Controller = Global.TI83Controls;
break;
case "NES":
Global.Emulator.Controller = Global.NESControls;
break;
case "GB":
break;
}
}
private bool LoadRom(string path) private bool LoadRom(string path)
{ {
using (var file = new HawkFile(path)) using (var file = new HawkFile(path))
@ -472,35 +504,28 @@ namespace BizHawk.MultiClient
case "SG": case "SG":
case "SMS": case "SMS":
nextEmulator = new SMS(); nextEmulator = new SMS();
nextEmulator.Controller = Global.SMSControls;
if (Global.Config.SmsEnableFM) game.AddOptions("UseFM"); if (Global.Config.SmsEnableFM) game.AddOptions("UseFM");
if (Global.Config.SmsAllowOverlock) game.AddOptions("AllowOverclock"); if (Global.Config.SmsAllowOverlock) game.AddOptions("AllowOverclock");
if (Global.Config.SmsForceStereoSeparation) game.AddOptions("ForceStereo"); if (Global.Config.SmsForceStereoSeparation) game.AddOptions("ForceStereo");
break; break;
case "GG": case "GG":
nextEmulator = new SMS { IsGameGear = true }; nextEmulator = new SMS { IsGameGear = true };
nextEmulator.Controller = Global.SMSControls;
if (Global.Config.SmsAllowOverlock) game.AddOptions("AllowOverclock"); if (Global.Config.SmsAllowOverlock) game.AddOptions("AllowOverclock");
break; break;
case "PCE": case "PCE":
nextEmulator = new PCEngine(NecSystemType.TurboGrafx); nextEmulator = new PCEngine(NecSystemType.TurboGrafx);
nextEmulator.Controller = Global.PCEControls;
break; break;
case "SGX": case "SGX":
nextEmulator = new PCEngine(NecSystemType.SuperGrafx); nextEmulator = new PCEngine(NecSystemType.SuperGrafx);
nextEmulator.Controller = Global.PCEControls;
break; break;
case "GEN": case "GEN":
nextEmulator = new Genesis(false);//TODO nextEmulator = new Genesis(false);//TODO
nextEmulator.Controller = Global.GenControls;
break; break;
case "TI83": case "TI83":
nextEmulator = new TI83(); nextEmulator = new TI83();
nextEmulator.Controller = Global.TI83Controls;
break; break;
case "NES": case "NES":
nextEmulator = new NES(); nextEmulator = new NES();
nextEmulator.Controller = Global.NESControls;
break; break;
case "GB": case "GB":
nextEmulator = new Gameboy(); nextEmulator = new Gameboy();
@ -525,6 +550,7 @@ namespace BizHawk.MultiClient
CloseGame(); CloseGame();
Global.Emulator = nextEmulator; Global.Emulator = nextEmulator;
Global.Game = game; Global.Game = game;
SyncControls();
if (game.System == "NES") if (game.System == "NES")
{ {

View File

@ -381,6 +381,7 @@ namespace BizHawk.MultiClient
{ {
UpdateAll(); UpdateAll();
} }
this.DialogResult = DialogResult.OK;
this.Close(); this.Close();
} }