mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 16:05:32 +00:00
Added S04: Input Logger test.
This commit is contained in:
parent
9b05ee1022
commit
93fc9ce367
197
Source/Examples/Tests/S04_Input_Logger.Designer.cs
generated
Normal file
197
Source/Examples/Tests/S04_Input_Logger.Designer.cs
generated
Normal file
|
@ -0,0 +1,197 @@
|
|||
namespace Examples.Tests
|
||||
{
|
||||
partial class S04_Input_Logger
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tabControl = new System.Windows.Forms.TabControl();
|
||||
this.Keyboard = new System.Windows.Forms.TabPage();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.listBox4 = new System.Windows.Forms.ListBox();
|
||||
this.listBox3 = new System.Windows.Forms.ListBox();
|
||||
this.listBox2 = new System.Windows.Forms.ListBox();
|
||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||
this.Mouse = new System.Windows.Forms.TabPage();
|
||||
this.HID = new System.Windows.Forms.TabPage();
|
||||
this.tabControl.SuspendLayout();
|
||||
this.Keyboard.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabControl
|
||||
//
|
||||
this.tabControl.Controls.Add(this.Keyboard);
|
||||
this.tabControl.Controls.Add(this.Mouse);
|
||||
this.tabControl.Controls.Add(this.HID);
|
||||
this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabControl.Name = "tabControl";
|
||||
this.tabControl.SelectedIndex = 0;
|
||||
this.tabControl.Size = new System.Drawing.Size(432, 378);
|
||||
this.tabControl.TabIndex = 0;
|
||||
//
|
||||
// Keyboard
|
||||
//
|
||||
this.Keyboard.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
this.Keyboard.Controls.Add(this.label4);
|
||||
this.Keyboard.Controls.Add(this.label3);
|
||||
this.Keyboard.Controls.Add(this.label2);
|
||||
this.Keyboard.Controls.Add(this.label1);
|
||||
this.Keyboard.Controls.Add(this.listBox4);
|
||||
this.Keyboard.Controls.Add(this.listBox3);
|
||||
this.Keyboard.Controls.Add(this.listBox2);
|
||||
this.Keyboard.Controls.Add(this.listBox1);
|
||||
this.Keyboard.Location = new System.Drawing.Point(4, 22);
|
||||
this.Keyboard.Name = "Keyboard";
|
||||
this.Keyboard.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.Keyboard.Size = new System.Drawing.Size(424, 352);
|
||||
this.Keyboard.TabIndex = 0;
|
||||
this.Keyboard.Text = "Keyboard";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(207, 180);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(61, 13);
|
||||
this.label4.TabIndex = 7;
|
||||
this.label4.Text = "Keyboard 4";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(6, 180);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(61, 13);
|
||||
this.label3.TabIndex = 6;
|
||||
this.label3.Text = "Keyboard 3";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(207, 3);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(61, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Keyboard 2";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(8, 3);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(61, 13);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "Keyboard 1";
|
||||
//
|
||||
// listBox4
|
||||
//
|
||||
this.listBox4.FormattingEnabled = true;
|
||||
this.listBox4.Location = new System.Drawing.Point(210, 197);
|
||||
this.listBox4.Name = "listBox4";
|
||||
this.listBox4.Size = new System.Drawing.Size(206, 147);
|
||||
this.listBox4.TabIndex = 3;
|
||||
//
|
||||
// listBox3
|
||||
//
|
||||
this.listBox3.FormattingEnabled = true;
|
||||
this.listBox3.Location = new System.Drawing.Point(9, 197);
|
||||
this.listBox3.Name = "listBox3";
|
||||
this.listBox3.Size = new System.Drawing.Size(195, 147);
|
||||
this.listBox3.TabIndex = 2;
|
||||
//
|
||||
// listBox2
|
||||
//
|
||||
this.listBox2.FormattingEnabled = true;
|
||||
this.listBox2.Location = new System.Drawing.Point(210, 20);
|
||||
this.listBox2.Name = "listBox2";
|
||||
this.listBox2.Size = new System.Drawing.Size(206, 147);
|
||||
this.listBox2.TabIndex = 1;
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
this.listBox1.FormattingEnabled = true;
|
||||
this.listBox1.Location = new System.Drawing.Point(9, 20);
|
||||
this.listBox1.Name = "listBox1";
|
||||
this.listBox1.Size = new System.Drawing.Size(195, 147);
|
||||
this.listBox1.TabIndex = 0;
|
||||
//
|
||||
// Mouse
|
||||
//
|
||||
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.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.TabIndex = 2;
|
||||
this.HID.Text = "HID";
|
||||
this.HID.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// S04_Input_Logger
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(432, 378);
|
||||
this.Controls.Add(this.tabControl);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Name = "S04_Input_Logger";
|
||||
this.Text = "S04: Input Logger";
|
||||
this.tabControl.ResumeLayout(false);
|
||||
this.Keyboard.ResumeLayout(false);
|
||||
this.Keyboard.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl;
|
||||
private System.Windows.Forms.TabPage Keyboard;
|
||||
private System.Windows.Forms.TabPage Mouse;
|
||||
private System.Windows.Forms.TabPage HID;
|
||||
private System.Windows.Forms.ListBox listBox4;
|
||||
private System.Windows.Forms.ListBox listBox3;
|
||||
private System.Windows.Forms.ListBox listBox2;
|
||||
private System.Windows.Forms.ListBox listBox1;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
|
||||
}
|
||||
}
|
98
Source/Examples/Tests/S04_Input_Logger.cs
Normal file
98
Source/Examples/Tests/S04_Input_Logger.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Platform;
|
||||
using OpenTK.Input;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Examples.Tests
|
||||
{
|
||||
public partial class S04_Input_Logger : Form, IExample
|
||||
{
|
||||
InputDriver driver;
|
||||
Dictionary<IntPtr, ListBox> keyboardListBoxes = new Dictionary<IntPtr, ListBox>(4);
|
||||
|
||||
public S04_Input_Logger()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
WindowInfo info = new WindowInfo(this);
|
||||
driver = new InputDriver(info);
|
||||
Debug.Print("Keyboard count: {0}", driver.Keyboard.Count);
|
||||
|
||||
switch (driver.Keyboard.Count)
|
||||
{
|
||||
case 0:
|
||||
Debug.Print("No keyboard present, or keyboard driver failed to load");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
keyboardListBoxes.Add(driver.Keyboard[0].DeviceID, listBox1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
keyboardListBoxes.Add(driver.Keyboard[0].DeviceID, listBox1);
|
||||
keyboardListBoxes.Add(driver.Keyboard[1].DeviceID, listBox2);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
keyboardListBoxes.Add(driver.Keyboard[0].DeviceID, listBox1);
|
||||
keyboardListBoxes.Add(driver.Keyboard[1].DeviceID, listBox2);
|
||||
keyboardListBoxes.Add(driver.Keyboard[2].DeviceID, listBox3);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
keyboardListBoxes.Add(driver.Keyboard[0].DeviceID, listBox1);
|
||||
keyboardListBoxes.Add(driver.Keyboard[1].DeviceID, listBox2);
|
||||
keyboardListBoxes.Add(driver.Keyboard[2].DeviceID, listBox3);
|
||||
keyboardListBoxes.Add(driver.Keyboard[3].DeviceID, listBox4);
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.Print("Only the first 4 keyboards will be shown in the keyboard logger.");
|
||||
keyboardListBoxes.Add(driver.Keyboard[0].DeviceID, listBox1);
|
||||
keyboardListBoxes.Add(driver.Keyboard[1].DeviceID, listBox2);
|
||||
keyboardListBoxes.Add(driver.Keyboard[2].DeviceID, listBox3);
|
||||
keyboardListBoxes.Add(driver.Keyboard[3].DeviceID, listBox4);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (OpenTK.Input.Keyboard k in driver.Keyboard)
|
||||
{
|
||||
k.KeyDown += new KeyDownEvent(LogKeyDown);
|
||||
k.KeyUp += new KeyUpEvent(LogKeyUp);
|
||||
}
|
||||
}
|
||||
|
||||
void LogKeyDown(object sender, Key key)
|
||||
{
|
||||
Debug.Print("Key down: {0} on device: {1}", key, (sender as Keyboard).DeviceID);
|
||||
keyboardListBoxes[(sender as Keyboard).DeviceID].Items.Add(key);
|
||||
}
|
||||
|
||||
void LogKeyUp(object sender, Key key)
|
||||
{
|
||||
keyboardListBoxes[(sender as Keyboard).DeviceID].Items.Remove(key);
|
||||
}
|
||||
|
||||
#region IExample Members
|
||||
|
||||
public void Launch()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
120
Source/Examples/Tests/S04_Input_Logger.resx
Normal file
120
Source/Examples/Tests/S04_Input_Logger.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in a new issue