Removed Move event from IMouse (too inefficient). Polled input only.
S04 now polls for the mouse position. Keyboard now handles events generated from code and not from physical devices.
This commit is contained in:
parent
626c6324ca
commit
11261553ea
3 changed files with 18 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue