From 2cbc50143f8d2745a1c865777db34cf7cca6cfe8 Mon Sep 17 00:00:00 2001 From: beirich Date: Fri, 8 Jul 2011 05:15:28 +0000 Subject: [PATCH] Input update... always run directinput in background input mode, we take care of ignoring input when application isn't focused ourselves --- BizHawk.MultiClient/Config.cs | 2 +- BizHawk.MultiClient/Input/Input.cs | 4 ++++ BizHawk.MultiClient/Input/Keyboard.cs | 7 ++----- BizHawk.MultiClient/MainForm.MenuItems.cs | 1 - BizHawk.MultiClient/config/InputWidget.cs | 7 +++---- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index a405ded874..acac46fe1d 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -370,7 +370,7 @@ public bool SmsAllowOverlock = false; public bool SmsForceStereoSeparation = false; - public string SmsReset = "Tab"; + public string SmsReset = "R"; public string SmsPause = "J1 B8, Space"; public SMSControllerTemplate[] SMSController = new SMSControllerTemplate[2]; diff --git a/BizHawk.MultiClient/Input/Input.cs b/BizHawk.MultiClient/Input/Input.cs index 9ac49c44fa..b18bda3840 100644 --- a/BizHawk.MultiClient/Input/Input.cs +++ b/BizHawk.MultiClient/Input/Input.cs @@ -1,4 +1,5 @@ using System; +using System.Windows.Forms; using SlimDX.DirectInput; namespace BizHawk.MultiClient @@ -19,6 +20,9 @@ namespace BizHawk.MultiClient public static bool IsPressed(string control) { + if (Global.Config.AcceptBackgroundInput == false && Form.ActiveForm == null) + return false; // application isn't active and background input is disabled + // Check joystick first, its easier if (control.StartsWith("J1 ")) return GetGamePad(0, control.Substring(3)); if (control.StartsWith("J2 ")) return GetGamePad(1, control.Substring(3)); diff --git a/BizHawk.MultiClient/Input/Keyboard.cs b/BizHawk.MultiClient/Input/Keyboard.cs index e008dcecac..6fce7c8508 100644 --- a/BizHawk.MultiClient/Input/Keyboard.cs +++ b/BizHawk.MultiClient/Input/Keyboard.cs @@ -14,15 +14,12 @@ namespace BizHawk.MultiClient public static void Initialize() { - if (dinput == null) + if (dinput == null) dinput = new DirectInput(); if (keyboard == null || keyboard.Disposed) keyboard = new Keyboard(dinput); - if (Global.Config.AcceptBackgroundInput) - keyboard.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); - else - keyboard.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Foreground | CooperativeLevel.Nonexclusive); + keyboard.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); } public static void Update() diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index 2811f33414..0077b972af 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -695,7 +695,6 @@ namespace BizHawk.MultiClient private void acceptBackgroundInputToolStripMenuItem_Click(object sender, EventArgs e) { Global.Config.AcceptBackgroundInput ^= true; - MessageBox.Show("Background input settings will take effect the next time Bizhawk loads", "Background input property change", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void displayStatusBarToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/config/InputWidget.cs b/BizHawk.MultiClient/config/InputWidget.cs index df1f6213ef..14a5c95a14 100644 --- a/BizHawk.MultiClient/config/InputWidget.cs +++ b/BizHawk.MultiClient/config/InputWidget.cs @@ -37,16 +37,15 @@ namespace BizHawk.MultiClient private void Timer_Tick(object sender, EventArgs e) { + Input.Update(); TempBindingStr = Input.GetPressedKey(); if (TempBindingStr != null) { - int x = 0; - x++; - int y = x; + // just for debugging. not really sure how to rebind from inside the timer? + MessageBox.Show(TempBindingStr); } } - void UpdateLabel() { if (Bindings.Count == 0)