From 046d815bd34fd6f71f515f7ff2a947ec93e844a9 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 6 Apr 2011 05:43:59 +0000 Subject: [PATCH] refresh controls immediately when rebinding instead of requiring emulator reboot --- BizHawk.MultiClient/MainForm.MenuItems.cs | 6 ++++ BizHawk.MultiClient/MainForm.cs | 40 +++++++++++++++++++---- BizHawk.MultiClient/config/InputConfig.cs | 1 + 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index 77368d6724..a9e3976ec6 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -307,6 +307,12 @@ namespace BizHawk.MultiClient { InputConfig i = new InputConfig(); 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) diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 13e82e6b67..72caa1f39d 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -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) { using (var file = new HawkFile(path)) @@ -472,35 +504,28 @@ namespace BizHawk.MultiClient case "SG": case "SMS": nextEmulator = new SMS(); - nextEmulator.Controller = Global.SMSControls; if (Global.Config.SmsEnableFM) game.AddOptions("UseFM"); if (Global.Config.SmsAllowOverlock) game.AddOptions("AllowOverclock"); if (Global.Config.SmsForceStereoSeparation) game.AddOptions("ForceStereo"); break; case "GG": nextEmulator = new SMS { IsGameGear = true }; - nextEmulator.Controller = Global.SMSControls; if (Global.Config.SmsAllowOverlock) game.AddOptions("AllowOverclock"); break; case "PCE": nextEmulator = new PCEngine(NecSystemType.TurboGrafx); - nextEmulator.Controller = Global.PCEControls; break; case "SGX": nextEmulator = new PCEngine(NecSystemType.SuperGrafx); - nextEmulator.Controller = Global.PCEControls; break; case "GEN": nextEmulator = new Genesis(false);//TODO - nextEmulator.Controller = Global.GenControls; break; case "TI83": nextEmulator = new TI83(); - nextEmulator.Controller = Global.TI83Controls; break; case "NES": nextEmulator = new NES(); - nextEmulator.Controller = Global.NESControls; break; case "GB": nextEmulator = new Gameboy(); @@ -525,6 +550,7 @@ namespace BizHawk.MultiClient CloseGame(); Global.Emulator = nextEmulator; Global.Game = game; + SyncControls(); if (game.System == "NES") { diff --git a/BizHawk.MultiClient/config/InputConfig.cs b/BizHawk.MultiClient/config/InputConfig.cs index ef1175b949..31a498a46d 100644 --- a/BizHawk.MultiClient/config/InputConfig.cs +++ b/BizHawk.MultiClient/config/InputConfig.cs @@ -381,6 +381,7 @@ namespace BizHawk.MultiClient { UpdateAll(); } + this.DialogResult = DialogResult.OK; this.Close(); }