Updated Input Logger example. Better handling of mice.

This commit is contained in:
the_fiddler 2007-09-21 21:30:18 +00:00
parent 4bac183f77
commit b660f5af9b
3 changed files with 150 additions and 7 deletions

View file

@ -40,8 +40,19 @@
this.listBox1 = new System.Windows.Forms.ListBox();
this.Mouse = new System.Windows.Forms.TabPage();
this.HID = new System.Windows.Forms.TabPage();
this.ChooseMouse = new System.Windows.Forms.ComboBox();
this.MouseButtons = new System.Windows.Forms.ListBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.MouseX = new System.Windows.Forms.Label();
this.MouseY = new System.Windows.Forms.Label();
this.MouseDeltaX = new System.Windows.Forms.Label();
this.MouseDeltaY = new System.Windows.Forms.Label();
this.tabControl.SuspendLayout();
this.Keyboard.SuspendLayout();
this.Mouse.SuspendLayout();
this.SuspendLayout();
//
// tabControl
@ -144,24 +155,115 @@
//
// Mouse
//
this.Mouse.BackColor = System.Drawing.SystemColors.ControlLight;
this.Mouse.Controls.Add(this.MouseDeltaY);
this.Mouse.Controls.Add(this.MouseDeltaX);
this.Mouse.Controls.Add(this.MouseY);
this.Mouse.Controls.Add(this.MouseX);
this.Mouse.Controls.Add(this.textBox4);
this.Mouse.Controls.Add(this.textBox3);
this.Mouse.Controls.Add(this.textBox2);
this.Mouse.Controls.Add(this.textBox1);
this.Mouse.Controls.Add(this.MouseButtons);
this.Mouse.Controls.Add(this.ChooseMouse);
this.Mouse.Location = new System.Drawing.Point(4, 22);
this.Mouse.Name = "Mouse";
this.Mouse.Padding = new System.Windows.Forms.Padding(3);
this.Mouse.Size = new System.Drawing.Size(424, 339);
this.Mouse.Size = new System.Drawing.Size(424, 352);
this.Mouse.TabIndex = 1;
this.Mouse.Text = "Mouse";
this.Mouse.UseVisualStyleBackColor = true;
//
// HID
//
this.HID.Location = new System.Drawing.Point(4, 22);
this.HID.Name = "HID";
this.HID.Padding = new System.Windows.Forms.Padding(3);
this.HID.Size = new System.Drawing.Size(424, 339);
this.HID.Size = new System.Drawing.Size(424, 352);
this.HID.TabIndex = 2;
this.HID.Text = "HID";
this.HID.UseVisualStyleBackColor = true;
//
// ChooseMouse
//
this.ChooseMouse.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ChooseMouse.FormattingEnabled = true;
this.ChooseMouse.Location = new System.Drawing.Point(7, 7);
this.ChooseMouse.Name = "ChooseMouse";
this.ChooseMouse.Size = new System.Drawing.Size(409, 21);
this.ChooseMouse.TabIndex = 0;
//
// MouseButtons
//
this.MouseButtons.FormattingEnabled = true;
this.MouseButtons.Location = new System.Drawing.Point(7, 197);
this.MouseButtons.Name = "MouseButtons";
this.MouseButtons.Size = new System.Drawing.Size(409, 147);
this.MouseButtons.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(66, 44);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(73, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(66, 71);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(73, 20);
this.textBox2.TabIndex = 3;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(66, 98);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(73, 20);
this.textBox3.TabIndex = 4;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(66, 125);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(73, 20);
this.textBox4.TabIndex = 5;
//
// MouseX
//
this.MouseX.AutoSize = true;
this.MouseX.Location = new System.Drawing.Point(4, 51);
this.MouseX.Name = "MouseX";
this.MouseX.Size = new System.Drawing.Size(57, 13);
this.MouseX.TabIndex = 6;
this.MouseX.Text = "Position X:";
//
// MouseY
//
this.MouseY.AutoSize = true;
this.MouseY.Location = new System.Drawing.Point(4, 78);
this.MouseY.Name = "MouseY";
this.MouseY.Size = new System.Drawing.Size(57, 13);
this.MouseY.TabIndex = 7;
this.MouseY.Text = "Position Y:";
//
// MouseDeltaX
//
this.MouseDeltaX.AutoSize = true;
this.MouseDeltaX.Location = new System.Drawing.Point(4, 105);
this.MouseDeltaX.Name = "MouseDeltaX";
this.MouseDeltaX.Size = new System.Drawing.Size(45, 13);
this.MouseDeltaX.TabIndex = 8;
this.MouseDeltaX.Text = "Delta X:";
//
// MouseDeltaY
//
this.MouseDeltaY.AutoSize = true;
this.MouseDeltaY.Location = new System.Drawing.Point(4, 132);
this.MouseDeltaY.Name = "MouseDeltaY";
this.MouseDeltaY.Size = new System.Drawing.Size(45, 13);
this.MouseDeltaY.TabIndex = 9;
this.MouseDeltaY.Text = "Delta Y:";
//
// S04_Input_Logger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -174,6 +276,8 @@
this.tabControl.ResumeLayout(false);
this.Keyboard.ResumeLayout(false);
this.Keyboard.PerformLayout();
this.Mouse.ResumeLayout(false);
this.Mouse.PerformLayout();
this.ResumeLayout(false);
}
@ -192,6 +296,16 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox ChooseMouse;
private System.Windows.Forms.ListBox MouseButtons;
private System.Windows.Forms.Label MouseDeltaY;
private System.Windows.Forms.Label MouseDeltaX;
private System.Windows.Forms.Label MouseY;
private System.Windows.Forms.Label MouseX;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
}
}

View file

@ -68,6 +68,20 @@ namespace Examples.Tests
break;
}
// Add available mice to the mouse input logger.
int i = 0;
foreach (Mouse m in driver.Mouse)
{
ChooseMouse.Items.Add(String.Format("Mouse {0} ({1})", ++i, m.Description));
//m.ButtonDown += LogMouseButtonDown;
//m.ButtonUp += LogMouseButtonUp;
//m.Move += LogMouseMove;
}
if (i > 0)
{
ChooseMouse.SelectedIndex = 0;
}
foreach (OpenTK.Input.Keyboard k in driver.Keyboard)
{
k.KeyDown += new KeyDownEvent(LogKeyDown);
@ -75,6 +89,21 @@ namespace Examples.Tests
}
}
void LogMouseButtonDown(IMouse sender, MouseButton button)
{
throw new Exception("The method or operation is not implemented.");
}
void LogMouseButtonUp(IMouse sender, MouseButton button)
{
throw new Exception("The method or operation is not implemented.");
}
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);

View file

@ -91,10 +91,10 @@ namespace OpenTK.Platform.Windows
RegistryKey regkey = Registry.LocalMachine.OpenSubKey(findme);
string deviceDesc =
(string)regkey.GetValue("DeviceDesc");
string deviceClass =
(string)regkey.GetValue("Class");
string deviceDesc = (string)regkey.GetValue("DeviceDesc");
deviceDesc = deviceDesc.Substring(deviceDesc.LastIndexOf(';') + 1);
string deviceClass = (string)regkey.GetValue("Class");
if (!String.IsNullOrEmpty(deviceClass) && deviceClass.ToLower().Equals("mouse"))
{
OpenTK.Input.Mouse mouse = new OpenTK.Input.Mouse();