diff --git a/Source/Examples/Tests/S04_Input_Logger.cs b/Source/Examples/Tests/S04_Input_Logger.cs index 5ea85709..2df066a5 100644 --- a/Source/Examples/Tests/S04_Input_Logger.cs +++ b/Source/Examples/Tests/S04_Input_Logger.cs @@ -21,6 +21,17 @@ namespace Examples.Tests public S04_Input_Logger() { InitializeComponent(); + + Application.Idle += new EventHandler(Application_Idle); + } + + void Application_Idle(object sender, EventArgs e) + { + // Update mouse coordinates. + textBox1.Text = driver.Mouse[ChooseMouse.SelectedIndex].X.ToString(); + textBox2.Text = driver.Mouse[ChooseMouse.SelectedIndex].Y.ToString(); + textBox3.Text = driver.Mouse[ChooseMouse.SelectedIndex].DeltaX.ToString(); + textBox4.Text = driver.Mouse[ChooseMouse.SelectedIndex].DeltaY.ToString(); } protected override void OnLoad(EventArgs e) @@ -76,7 +87,6 @@ namespace Examples.Tests ChooseMouse.Items.Add(String.Format("Mouse {0} ({1})", ++i, m.Description)); m.ButtonDown += LogMouseButtonDown; m.ButtonUp += LogMouseButtonUp; - //m.Move += LogMouseMove; } if (i > 0) { @@ -102,11 +112,6 @@ namespace Examples.Tests MouseButtons.Items.Remove(button); } - void LogMouseMove(IMouse sender, MouseMoveData key) - { - throw new Exception("The method or operation is not implemented."); - } - void LogKeyDown(object sender, Key key) { Debug.Print("Key down: {0} on device: {1}", key, (sender as Keyboard).DeviceID); diff --git a/Source/OpenTK/Input/IMouse.cs b/Source/OpenTK/Input/IMouse.cs index 71478c1e..9ac2edf6 100644 --- a/Source/OpenTK/Input/IMouse.cs +++ b/Source/OpenTK/Input/IMouse.cs @@ -21,7 +21,7 @@ namespace OpenTK.Input int DeltaX { get; } int DeltaY { get; } - event MouseMoveEvent Move; + //event MouseMoveEvent Move; event MouseButtonDownEvent ButtonDown; event MouseButtonUpEvent ButtonUp; } diff --git a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs index a591882a..3b7d960b 100644 --- a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs +++ b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs @@ -279,10 +279,16 @@ namespace OpenTK.Platform.Windows bool pressed = rin.Data.Keyboard.Message == (int)WindowMessage.KEYDOWN || rin.Data.Keyboard.Message == (int)WindowMessage.SYSKEYDOWN; + + // Find the device where the button was pressed. It can be that the input notification + // came not from a physical keyboard device but from a code-generated input message - in + // that case, the event goes to the default (first) keyboard. + // TODO: Send the event to all keyboards instead of the default one. int index = keyboards.FindIndex(delegate(Keyboard kb) { return kb.DeviceID == rin.Header.Device; }); + if (index == -1) index = 0; // Generic control, shift, alt keys may be sent instead of left/right. // It seems you have to explicitly register left/right events.