From 7a064c382a0472391994ea8d446d81c9f3ad9923 Mon Sep 17 00:00:00 2001 From: thefiddler Date: Mon, 21 Jul 2014 17:20:19 +0200 Subject: [PATCH] [Examples] Fixed all warnings --- Source/Examples/OpenGL/1.x/Anaglyph.cs | 3 +- Source/Examples/OpenGL/1.x/DisplayLists.cs | 3 +- Source/Examples/OpenGL/1.x/FramebufferObject.cs | 3 +- Source/Examples/OpenGL/1.x/ImmediateMode.cs | 3 +- Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs | 3 +- Source/Examples/OpenGL/1.x/Picking.cs | 14 +- Source/Examples/OpenGL/1.x/StencilCSG.cs | 11 +- Source/Examples/OpenGL/1.x/TextRendering.cs | 3 +- Source/Examples/OpenGL/1.x/TextureMatrix.cs | 11 +- Source/Examples/OpenGL/1.x/Textures.cs | 3 +- Source/Examples/OpenGL/1.x/VBODynamic.cs | 3 +- Source/Examples/OpenGL/1.x/VBOStatic.cs | 3 +- Source/Examples/OpenGL/1.x/VertexArrays.cs | 21 +- Source/Examples/OpenGL/1.x/VertexLighting.cs | 13 +- Source/Examples/OpenGL/2.x/DDSCubeMap.cs | 20 +- Source/Examples/OpenGL/2.x/GeometryShader.cs | 5 +- .../Examples/OpenGL/2.x/GeometryShaderAdvanced.cs | 5 +- Source/Examples/OpenGL/2.x/JuliaSetFractal.cs | 7 +- Source/Examples/OpenGL/2.x/SimpleGLSL.cs | 5 +- Source/Examples/OpenGL/2.x/SwizzledParallax.cs | 58 +- Source/Examples/OpenGL/3.x/HelloGL3.cs | 3 +- Source/Examples/OpenGLES/2.0/SimpleWindow20.cs | 3 +- Source/Examples/OpenTK.Examples.csproj | 11 +- .../Examples/OpenTK/GameWindow/GameWindowMsaa.cs | 2 +- .../Examples/OpenTK/GameWindow/GameWindowSimple.cs | 2 +- .../OpenTK/GameWindow/GameWindowThreaded.cs | 4 +- .../OpenTK/GameWindow/MouseCursorSimple.cs | 8 +- Source/Examples/OpenTK/Test/BasicMouseInput.cs | 17 +- Source/Examples/OpenTK/Test/GameWindowStates.cs | 2 + .../Examples/OpenTK/Test/InputLogger.Designer.cs | 682 --------------------- Source/Examples/OpenTK/Test/InputLogger.cs | 311 ---------- Source/Examples/OpenTK/Test/InputLogger.resx | 123 ---- Source/Examples/OpenTK/Test/Multithreading.cs | 2 +- .../Examples/OpenTK/Test/TestShaderUtf8Support.cs | 3 +- 34 files changed, 147 insertions(+), 1223 deletions(-) delete mode 100644 Source/Examples/OpenTK/Test/InputLogger.Designer.cs delete mode 100644 Source/Examples/OpenTK/Test/InputLogger.cs delete mode 100644 Source/Examples/OpenTK/Test/InputLogger.resx diff --git a/Source/Examples/OpenGL/1.x/Anaglyph.cs b/Source/Examples/OpenGL/1.x/Anaglyph.cs index 35ce7a1..861742d 100644 --- a/Source/Examples/OpenGL/1.x/Anaglyph.cs +++ b/Source/Examples/OpenGL/1.x/Anaglyph.cs @@ -72,7 +72,8 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Escape]) Exit(); } diff --git a/Source/Examples/OpenGL/1.x/DisplayLists.cs b/Source/Examples/OpenGL/1.x/DisplayLists.cs index 034929e..6297409 100644 --- a/Source/Examples/OpenGL/1.x/DisplayLists.cs +++ b/Source/Examples/OpenGL/1.x/DisplayLists.cs @@ -112,7 +112,8 @@ namespace Examples.Tutorial protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); } diff --git a/Source/Examples/OpenGL/1.x/FramebufferObject.cs b/Source/Examples/OpenGL/1.x/FramebufferObject.cs index 0847a9a..a99fb19 100644 --- a/Source/Examples/OpenGL/1.x/FramebufferObject.cs +++ b/Source/Examples/OpenGL/1.x/FramebufferObject.cs @@ -220,7 +220,8 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Escape]) this.Exit(); } diff --git a/Source/Examples/OpenGL/1.x/ImmediateMode.cs b/Source/Examples/OpenGL/1.x/ImmediateMode.cs index 166ff6e..76d8e9f 100644 --- a/Source/Examples/OpenGL/1.x/ImmediateMode.cs +++ b/Source/Examples/OpenGL/1.x/ImmediateMode.cs @@ -88,7 +88,8 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); return; diff --git a/Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs b/Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs index 4885764..ea3a45b 100644 --- a/Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs +++ b/Source/Examples/OpenGL/1.x/OpenGLDiagnostics.cs @@ -411,7 +411,8 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Escape]) Exit(); } diff --git a/Source/Examples/OpenGL/1.x/Picking.cs b/Source/Examples/OpenGL/1.x/Picking.cs index 67c8323..deb2881 100644 --- a/Source/Examples/OpenGL/1.x/Picking.cs +++ b/Source/Examples/OpenGL/1.x/Picking.cs @@ -24,11 +24,19 @@ namespace Examples.Tutorial [Example("Picking", ExampleCategory.OpenGL, "1.x", Documentation = "Picking")] class Picking : GameWindow { + int mouse_x, mouse_y; + /// Creates a 800x600 window with the specified title. public Picking() : base(800, 600, GraphicsMode.Default, "Picking", GameWindowFlags.Default, DisplayDevice.Default, 1, 1, GraphicsContextFlags.Default) { VSync = VSyncMode.On; + + MouseMove += (sender, e) => + { + mouse_x = e.X; + mouse_y = e.Y; + }; } struct Byte4 @@ -192,7 +200,6 @@ namespace Examples.Tutorial GL.UseProgram(0); */ #endregion Shader - } protected override void OnUnload(EventArgs e) @@ -224,7 +231,8 @@ namespace Examples.Tutorial /// Contains timing information for framerate independent logic. protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Escape]) Exit(); } @@ -256,7 +264,7 @@ namespace Examples.Tutorial // Read Pixel under mouse cursor Byte4 Pixel = new Byte4(); - GL.ReadPixels(Mouse.X, this.Height - Mouse.Y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, ref Pixel); + GL.ReadPixels(mouse_x, this.Height - mouse_y, 1, 1, PixelFormat.Rgba, PixelType.UnsignedByte, ref Pixel); SelectedTriangle = Pixel.ToUInt32(); #endregion Pass 1: Draw Object and pick Triangle diff --git a/Source/Examples/OpenGL/1.x/StencilCSG.cs b/Source/Examples/OpenGL/1.x/StencilCSG.cs index 116fcf0..242be0d 100644 --- a/Source/Examples/OpenGL/1.x/StencilCSG.cs +++ b/Source/Examples/OpenGL/1.x/StencilCSG.cs @@ -42,7 +42,7 @@ namespace Examples.Tutorial : base(800, 600, new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8)) // request 8-bit stencil buffer { base.VSync = VSyncMode.Off; - Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e) + KeyDown += delegate(object sender, KeyboardKeyEventArgs e) { switch (e.Key) { @@ -174,11 +174,10 @@ namespace Examples.Tutorial protected override void OnUpdateFrame(FrameEventArgs e) { - #region Magic numbers for camera - CameraRotX = -Mouse.X * .5f; - CameraRotY = Mouse.Y * .5f; - CameraZoom = Mouse.Wheel * .2f; - #endregion Magic numbers for camera + var mouse = OpenTK.Input.Mouse.GetState(); + CameraRotX = -mouse.X * .5f; + CameraRotY = mouse.Y * .5f; + CameraZoom = mouse.Wheel * .2f; } public void DrawOperandB() diff --git a/Source/Examples/OpenGL/1.x/TextRendering.cs b/Source/Examples/OpenGL/1.x/TextRendering.cs index 9eb975f..016ff54 100644 --- a/Source/Examples/OpenGL/1.x/TextRendering.cs +++ b/Source/Examples/OpenGL/1.x/TextRendering.cs @@ -215,7 +215,8 @@ namespace Examples.Tutorial protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); } diff --git a/Source/Examples/OpenGL/1.x/TextureMatrix.cs b/Source/Examples/OpenGL/1.x/TextureMatrix.cs index 7f98ea1..00d8fa1 100644 --- a/Source/Examples/OpenGL/1.x/TextureMatrix.cs +++ b/Source/Examples/OpenGL/1.x/TextureMatrix.cs @@ -18,6 +18,7 @@ namespace Examples.Tutorial class TextureMatrix : GameWindow { + Vector2 orientation; public TextureMatrix() : base(800, 600, new GraphicsMode(32, 16, 0, 4)) @@ -89,8 +90,12 @@ namespace Examples.Tutorial protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Escape]) Exit(); + + var mouse = OpenTK.Input.Mouse.GetState(); + orientation = new Vector2(mouse.X, mouse.Y); } protected override void OnRenderFrame(FrameEventArgs e) @@ -107,8 +112,8 @@ namespace Examples.Tutorial GL.Translate(0f, 0f, 1.5f); - GL.Rotate(Mouse.X, Vector3.UnitY); - GL.Rotate(Mouse.Y, Vector3.UnitX); + GL.Rotate(orientation.X, Vector3.UnitY); + GL.Rotate(orientation.Y, Vector3.UnitX); GL.CallList(list); diff --git a/Source/Examples/OpenGL/1.x/Textures.cs b/Source/Examples/OpenGL/1.x/Textures.cs index 4ad6081..edfc85c 100644 --- a/Source/Examples/OpenGL/1.x/Textures.cs +++ b/Source/Examples/OpenGL/1.x/Textures.cs @@ -93,7 +93,8 @@ namespace Examples.Tutorial /// There is no need to call the base implementation. protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) this.Exit(); } diff --git a/Source/Examples/OpenGL/1.x/VBODynamic.cs b/Source/Examples/OpenGL/1.x/VBODynamic.cs index 16b012d..3b0fc0b 100644 --- a/Source/Examples/OpenGL/1.x/VBODynamic.cs +++ b/Source/Examples/OpenGL/1.x/VBODynamic.cs @@ -136,7 +136,8 @@ namespace Examples.Tutorial /// Contains timing information for framerate independent logic. protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Escape]) { Exit(); } diff --git a/Source/Examples/OpenGL/1.x/VBOStatic.cs b/Source/Examples/OpenGL/1.x/VBOStatic.cs index 0c43a81..0ae2ea0 100644 --- a/Source/Examples/OpenGL/1.x/VBOStatic.cs +++ b/Source/Examples/OpenGL/1.x/VBOStatic.cs @@ -88,7 +88,8 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) this.Exit(); } diff --git a/Source/Examples/OpenGL/1.x/VertexArrays.cs b/Source/Examples/OpenGL/1.x/VertexArrays.cs index 6f50602..4fe29c8 100644 --- a/Source/Examples/OpenGL/1.x/VertexArrays.cs +++ b/Source/Examples/OpenGL/1.x/VertexArrays.cs @@ -36,7 +36,7 @@ namespace Examples.Tutorial : base(800, 600) { //this.VSync = VSyncMode.On; - this.Keyboard.KeyUp += Keyboard_KeyUp; + KeyUp += Keyboard_KeyUp; } void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e) @@ -107,14 +107,15 @@ namespace Examples.Tutorial /// protected override void OnUpdateFrame(FrameEventArgs e) { - // Escape quits. - if (Keyboard[Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + + if (keyboard[Key.Escape]) { this.Exit(); return; } - if (Keyboard[Key.F11]) + if (keyboard[Key.F11]) if (WindowState != WindowState.Fullscreen) WindowState = WindowState.Fullscreen; else @@ -122,14 +123,14 @@ namespace Examples.Tutorial // Plus/Minus change the target render frequency. // PageUp/PageDown change the target update frequency. - if (Keyboard[Key.Plus] || Keyboard[Key.KeypadAdd]) TargetRenderFrequency++; - if (Keyboard[Key.Minus] || Keyboard[Key.KeypadSubtract]) TargetRenderFrequency--; - if (Keyboard[Key.PageUp]) TargetUpdateFrequency++; - if (Keyboard[Key.PageDown]) TargetUpdateFrequency--; + if (keyboard[Key.Plus] || keyboard[Key.KeypadAdd]) TargetRenderFrequency++; + if (keyboard[Key.Minus] || keyboard[Key.KeypadSubtract]) TargetRenderFrequency--; + if (keyboard[Key.PageUp]) TargetUpdateFrequency++; + if (keyboard[Key.PageDown]) TargetUpdateFrequency--; // Right/Left control the rotation speed and direction. - if (Keyboard[Key.Right]) rotation_speed += 0.5f; - if (Keyboard[Key.Left]) rotation_speed -= 0.5f; + if (keyboard[Key.Right]) rotation_speed += 0.5f; + if (keyboard[Key.Left]) rotation_speed -= 0.5f; } #endregion diff --git a/Source/Examples/OpenGL/1.x/VertexLighting.cs b/Source/Examples/OpenGL/1.x/VertexLighting.cs index fb950f2..2b31bc9 100644 --- a/Source/Examples/OpenGL/1.x/VertexLighting.cs +++ b/Source/Examples/OpenGL/1.x/VertexLighting.cs @@ -100,24 +100,27 @@ namespace Examples.Tutorial /// protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + var mouse = OpenTK.Input.Mouse.GetState(); + + if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); return; } - if (Keyboard[OpenTK.Input.Key.F11]) + if (keyboard[OpenTK.Input.Key.F11]) if (WindowState != WindowState.Fullscreen) WindowState = WindowState.Fullscreen; else WindowState = WindowState.Normal; - if (Mouse[OpenTK.Input.MouseButton.Left]) - x_angle = Mouse.X; + if (mouse[OpenTK.Input.MouseButton.Left]) + x_angle = mouse.X; else x_angle += 0.5f; - zoom = Mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows. + zoom = mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows. // Do not leave x_angle drift too far away, as this will cause inaccuracies. if (x_angle > 360.0f) diff --git a/Source/Examples/OpenGL/2.x/DDSCubeMap.cs b/Source/Examples/OpenGL/2.x/DDSCubeMap.cs index 3e152fd..d8334bc 100644 --- a/Source/Examples/OpenGL/2.x/DDSCubeMap.cs +++ b/Source/Examples/OpenGL/2.x/DDSCubeMap.cs @@ -198,19 +198,21 @@ namespace Examples.Tutorial /// Add your game logic here. /// Contains timing information. /// There is no need to call the base implementation. - protected override void OnUpdateFrame( FrameEventArgs e ) + protected override void OnUpdateFrame(FrameEventArgs e) { - base.OnUpdateFrame( e ); + base.OnUpdateFrame(e); - if ( Keyboard[OpenTK.Input.Key.Escape] ) - this.Exit( ); - if ( Keyboard[OpenTK.Input.Key.Space] ) - Trace.WriteLine( "GL: " + GL.GetError( ) ); + var keyboard = OpenTK.Input.Keyboard.GetState(); + var mouse = OpenTK.Input.Mouse.GetState(); - Trackball.X = Mouse.X; - Trackball.Y = Mouse.Y; - Trackball.Z = Mouse.Wheel * 0.5f; + if (keyboard[OpenTK.Input.Key.Escape]) + this.Exit(); + if (keyboard[OpenTK.Input.Key.Space]) + Trace.WriteLine("GL: " + GL.GetError()); + Trackball.X = mouse.X; + Trackball.Y = mouse.Y; + Trackball.Z = mouse.Scroll.Y * 0.5f; } /// Add your game rendering code here. diff --git a/Source/Examples/OpenGL/2.x/GeometryShader.cs b/Source/Examples/OpenGL/2.x/GeometryShader.cs index 26b9d4c..74b625d 100644 --- a/Source/Examples/OpenGL/2.x/GeometryShader.cs +++ b/Source/Examples/OpenGL/2.x/GeometryShader.cs @@ -195,14 +195,15 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[Key.Space]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Space]) { ErrorCode err = GL.GetError(); //Console.WriteLine(err + " " + Glu.ErrorString((GluErrorCode)err)); Console.WriteLine("GL error code: {0}", err); } - if (Keyboard[Key.Escape]) + if (keyboard[Key.Escape]) this.Exit(); } diff --git a/Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs b/Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs index 6d72e0e..88a8d52 100644 --- a/Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs +++ b/Source/Examples/OpenGL/2.x/GeometryShaderAdvanced.cs @@ -46,7 +46,7 @@ namespace Examples.Tutorial public SimpleGeometryShader2() : base(800, 600) { - Keyboard.KeyDown += Keyboard_KeyDown; + KeyDown += Keyboard_KeyDown; } enum ViewMode @@ -900,7 +900,8 @@ namespace Examples.Tutorial eyePos.X = (float)Math.Cos(elapsed / 3000) * 8; eyePos.Z = (float)Math.Sin(elapsed / 2000) * 8; - if (Keyboard[Key.Space]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Space]) { ErrorCode err = GL.GetError(); //Console.WriteLine(err + " " + Glu.ErrorString((GluErrorCode)err)); diff --git a/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs b/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs index f9c88a2..c896c21 100644 --- a/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs +++ b/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs @@ -157,8 +157,8 @@ namespace Examples.Tutorial bitmap.UnlockBits(data); } #endregion Textures - - Keyboard.KeyUp += Keyboard_KeyUp; + + KeyUp += Keyboard_KeyUp; } int i = 0; @@ -233,7 +233,8 @@ namespace Examples.Tutorial { base.OnUpdateFrame(e); - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); } diff --git a/Source/Examples/OpenGL/2.x/SimpleGLSL.cs b/Source/Examples/OpenGL/2.x/SimpleGLSL.cs index c2eac19..3835ff7 100644 --- a/Source/Examples/OpenGL/2.x/SimpleGLSL.cs +++ b/Source/Examples/OpenGL/2.x/SimpleGLSL.cs @@ -214,10 +214,11 @@ namespace Examples.Tutorial /// protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) this.Exit(); - if (Keyboard[OpenTK.Input.Key.F11]) + if (keyboard[OpenTK.Input.Key.F11]) if (WindowState != WindowState.Fullscreen) WindowState = WindowState.Fullscreen; else diff --git a/Source/Examples/OpenGL/2.x/SwizzledParallax.cs b/Source/Examples/OpenGL/2.x/SwizzledParallax.cs index 6e5bf4e..09dd5d2 100644 --- a/Source/Examples/OpenGL/2.x/SwizzledParallax.cs +++ b/Source/Examples/OpenGL/2.x/SwizzledParallax.cs @@ -224,52 +224,62 @@ namespace Examples.Tutorial base.OnResize( e ); } - /// Add your game logic here. - /// Contains timing information. - /// There is no need to call the base implementation. - protected override void OnUpdateFrame( FrameEventArgs e ) + protected override void OnKeyDown(OpenTK.Input.KeyboardKeyEventArgs e) { - base.OnUpdateFrame( e ); + base.OnKeyDown(e); - if ( Keyboard[OpenTK.Input.Key.Escape] ) - this.Exit( ); - if ( Keyboard[OpenTK.Input.Key.Space] ) - Trace.WriteLine( "GL: " + GL.GetError( ) ); - if ( Keyboard[OpenTK.Input.Key.Q] ) + if (e.Keyboard[OpenTK.Input.Key.Escape]) + this.Exit(); + if (e.Keyboard[OpenTK.Input.Key.Space]) + Trace.WriteLine("GL: " + GL.GetError()); + if (e.Keyboard[OpenTK.Input.Key.Q]) { MaterialScaleAndBiasAndShininess.X += 0.01f; - Trace.WriteLine( "Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y ); + Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y); } - if ( Keyboard[OpenTK.Input.Key.A] ) + if (e.Keyboard[OpenTK.Input.Key.A]) { MaterialScaleAndBiasAndShininess.X -= 0.01f; - Trace.WriteLine( "Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y ); + Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y); } - if ( Keyboard[OpenTK.Input.Key.W] ) + if (e.Keyboard[OpenTK.Input.Key.W]) { MaterialScaleAndBiasAndShininess.Y += 0.01f; - Trace.WriteLine( "Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y ); + Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y); } - if ( Keyboard[OpenTK.Input.Key.S] ) + if (e.Keyboard[OpenTK.Input.Key.S]) { MaterialScaleAndBiasAndShininess.Y -= 0.01f; - Trace.WriteLine( "Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y ); + Trace.WriteLine("Scale: " + MaterialScaleAndBiasAndShininess.X + " Bias: " + MaterialScaleAndBiasAndShininess.Y); } - if ( Keyboard[OpenTK.Input.Key.E] ) + if (e.Keyboard[OpenTK.Input.Key.E]) { MaterialScaleAndBiasAndShininess.Z += 1f; - Trace.WriteLine( "Shininess: " + MaterialScaleAndBiasAndShininess.Z ); + Trace.WriteLine("Shininess: " + MaterialScaleAndBiasAndShininess.Z); } - if ( Keyboard[OpenTK.Input.Key.D] ) + if (e.Keyboard[OpenTK.Input.Key.D]) { MaterialScaleAndBiasAndShininess.Z -= 1f; - Trace.WriteLine( "Shininess: " + MaterialScaleAndBiasAndShininess.Z ); + Trace.WriteLine("Shininess: " + MaterialScaleAndBiasAndShininess.Z); } + } + + protected override void OnMouseMove(OpenTK.Input.MouseMoveEventArgs e) + { + base.OnMouseMove(e); - LightPosition.X = ( -( this.Width / 2 ) + Mouse.X ) / 100f; - LightPosition.Y = ( ( this.Height / 2 ) - Mouse.Y ) / 100f; + LightPosition.X = (-(this.Width / 2) + e.Mouse.X) / 100f; + LightPosition.Y = ((this.Height / 2) - e.Mouse.Y) / 100f; - EyePos.Y = Mouse.Wheel * 0.5f; + EyePos.Y = e.Mouse.Wheel * 0.5f; + } + + /// Add your game logic here. + /// Contains timing information. + /// There is no need to call the base implementation. + protected override void OnUpdateFrame( FrameEventArgs e ) + { + base.OnUpdateFrame( e ); } /// Add your game rendering code here. diff --git a/Source/Examples/OpenGL/3.x/HelloGL3.cs b/Source/Examples/OpenGL/3.x/HelloGL3.cs index 81a64bf..0a9877a 100644 --- a/Source/Examples/OpenGL/3.x/HelloGL3.cs +++ b/Source/Examples/OpenGL/3.x/HelloGL3.cs @@ -202,7 +202,8 @@ void main(void) Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix); GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix); - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) Exit(); } diff --git a/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs b/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs index ac01e84..c147070 100644 --- a/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs +++ b/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs @@ -69,7 +69,8 @@ namespace Examples.Tutorial /// protected override void OnUpdateFrame(FrameEventArgs e) { - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); return; diff --git a/Source/Examples/OpenTK.Examples.csproj b/Source/Examples/OpenTK.Examples.csproj index 7928ff0..cca433b 100644 --- a/Source/Examples/OpenTK.Examples.csproj +++ b/Source/Examples/OpenTK.Examples.csproj @@ -379,9 +379,6 @@ Code - - Form - @@ -476,12 +473,6 @@ Extensions.cs - - InputLogger.cs - - - InputLogger.cs - OpenTK.snk @@ -649,4 +640,4 @@ - + \ No newline at end of file diff --git a/Source/Examples/OpenTK/GameWindow/GameWindowMsaa.cs b/Source/Examples/OpenTK/GameWindow/GameWindowMsaa.cs index afecfcd..38c4ae6 100644 --- a/Source/Examples/OpenTK/GameWindow/GameWindowMsaa.cs +++ b/Source/Examples/OpenTK/GameWindow/GameWindowMsaa.cs @@ -17,7 +17,7 @@ namespace Examples public FullscreenAntialias() : base(800, 600, new GraphicsMode(32, 0, 0, 4)) { - Keyboard.KeyDown += Keyboard_KeyDown; + KeyDown += Keyboard_KeyDown; } #region Keyboard_KeyDown diff --git a/Source/Examples/OpenTK/GameWindow/GameWindowSimple.cs b/Source/Examples/OpenTK/GameWindow/GameWindowSimple.cs index 383fdfa..697e962 100644 --- a/Source/Examples/OpenTK/GameWindow/GameWindowSimple.cs +++ b/Source/Examples/OpenTK/GameWindow/GameWindowSimple.cs @@ -18,7 +18,7 @@ namespace Examples.Tutorial { public SimpleWindow() : base(800, 600) { - Keyboard.KeyDown += Keyboard_KeyDown; + KeyDown += Keyboard_KeyDown; } #region Keyboard_KeyDown diff --git a/Source/Examples/OpenTK/GameWindow/GameWindowThreaded.cs b/Source/Examples/OpenTK/GameWindow/GameWindowThreaded.cs index bcc7183..c60f0af 100644 --- a/Source/Examples/OpenTK/GameWindow/GameWindowThreaded.cs +++ b/Source/Examples/OpenTK/GameWindow/GameWindowThreaded.cs @@ -43,13 +43,13 @@ namespace Examples.Tutorial public ThreadedRendering() : base(800, 600) { - Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e) + KeyDown += delegate(object sender, KeyboardKeyEventArgs e) { if (e.Key == Key.Escape) this.Exit(); }; - Keyboard.KeyUp += delegate(object sender, KeyboardKeyEventArgs e) + KeyUp += delegate(object sender, KeyboardKeyEventArgs e) { if (e.Key == Key.F11) if (this.WindowState == WindowState.Fullscreen) diff --git a/Source/Examples/OpenTK/GameWindow/MouseCursorSimple.cs b/Source/Examples/OpenTK/GameWindow/MouseCursorSimple.cs index 83ef22c..c327658 100644 --- a/Source/Examples/OpenTK/GameWindow/MouseCursorSimple.cs +++ b/Source/Examples/OpenTK/GameWindow/MouseCursorSimple.cs @@ -23,7 +23,7 @@ namespace Examples.Tutorial public MouseCursorSimple() : base(800, 600) { - Keyboard.KeyDown += Keyboard_KeyDown; + KeyDown += Keyboard_KeyDown; using (Bitmap bitmap = new Bitmap("Data/Textures/cursor.png")) { @@ -37,8 +37,8 @@ namespace Examples.Tutorial Cursor = MyCursor; } - Mouse.Move += Mouse_Move; - Mouse.ButtonDown += Mouse_ButtonDown; + MouseMove += Mouse_Move; + MouseDown += Mouse_ButtonDown; } void AddLine(float x, float y) @@ -71,7 +71,7 @@ namespace Examples.Tutorial void Mouse_Move(object sender, MouseMoveEventArgs e) { - if (Mouse[MouseButton.Left]) + if (e.Mouse[MouseButton.Left]) { AddLine(e.X, e.Y); } diff --git a/Source/Examples/OpenTK/Test/BasicMouseInput.cs b/Source/Examples/OpenTK/Test/BasicMouseInput.cs index 5a10472..b40d94c 100644 --- a/Source/Examples/OpenTK/Test/BasicMouseInput.cs +++ b/Source/Examples/OpenTK/Test/BasicMouseInput.cs @@ -28,9 +28,9 @@ namespace Examples.Tests public BasicMouseInput() : base(800, 600) { - Mouse.Move += (sender, e) => + MouseMove += (sender, e) => { - if (Mouse[MouseButton.Left]) + if (e.Mouse[MouseButton.Left]) { // Scale mouse coordinates from // (0, 0):(Width, Height) to @@ -48,7 +48,7 @@ namespace Examples.Tests protected override void OnLoad(EventArgs e) { - this.Mouse.ButtonUp += (object sender, MouseButtonEventArgs buttonEvent) => { + MouseUp += (object sender, MouseButtonEventArgs buttonEvent) => { Console.WriteLine("Mouse button up: " + buttonEvent.Button + " at: " + buttonEvent.Position); }; } @@ -65,10 +65,12 @@ namespace Examples.Tests Console.WriteLine("The A key is down!"); } - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + + if (keyboard[OpenTK.Input.Key.Escape]) this.Exit(); - if (Keyboard[OpenTK.Input.Key.F11]) + if (keyboard[OpenTK.Input.Key.F11]) if (WindowState != WindowState.Fullscreen) WindowState = WindowState.Fullscreen; else @@ -94,8 +96,9 @@ namespace Examples.Tests GL.End(); SwapBuffers(); - - if (Keyboard[Key.Space]) + + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[Key.Space]) { // Simulate high load (4 fps) to check // mouse input behavior diff --git a/Source/Examples/OpenTK/Test/GameWindowStates.cs b/Source/Examples/OpenTK/Test/GameWindowStates.cs index 2c21a54..768f29a 100644 --- a/Source/Examples/OpenTK/Test/GameWindowStates.cs +++ b/Source/Examples/OpenTK/Test/GameWindowStates.cs @@ -14,6 +14,8 @@ using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; using OpenTK.Input; +#pragma warning disable 612,618 // disable obsolete warnings - we need to access these functions + namespace Examples.Tests { [Example("GameWindow States", ExampleCategory.OpenTK, "GameWindow", 4, Documentation = "GameWindowStates")] diff --git a/Source/Examples/OpenTK/Test/InputLogger.Designer.cs b/Source/Examples/OpenTK/Test/InputLogger.Designer.cs deleted file mode 100644 index 8b0e3f5..0000000 --- a/Source/Examples/OpenTK/Test/InputLogger.Designer.cs +++ /dev/null @@ -1,682 +0,0 @@ -namespace Examples.Tests -{ - partial class InputLogger - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - 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.WindowY = new System.Windows.Forms.Label(); - this.WindowX = new System.Windows.Forms.Label(); - this.MouseYWindow = new System.Windows.Forms.TextBox(); - this.MouseXWindow = new System.Windows.Forms.TextBox(); - this.MouseWheelDelta = new System.Windows.Forms.TextBox(); - this.WheelDelta = new System.Windows.Forms.Label(); - this.MouseWheelText = new System.Windows.Forms.TextBox(); - this.MouseWheelLabel = new System.Windows.Forms.Label(); - this.MouseDeltaY = new System.Windows.Forms.Label(); - this.MouseDeltaX = new System.Windows.Forms.Label(); - this.MouseY = new System.Windows.Forms.Label(); - this.MouseX = new System.Windows.Forms.Label(); - this.MouseDYText = new System.Windows.Forms.TextBox(); - this.MouseDXText = new System.Windows.Forms.TextBox(); - this.MouseYText = new System.Windows.Forms.TextBox(); - this.MouseXText = new System.Windows.Forms.TextBox(); - this.MouseButtonsBox = new System.Windows.Forms.ListBox(); - this.ChooseMouse = new System.Windows.Forms.ComboBox(); - this.HID = new System.Windows.Forms.TabPage(); - this.PollTimer = new System.Windows.Forms.Timer(this.components); - this.comboBoxActiveJoystick = new System.Windows.Forms.ComboBox(); - this.textBoxAxis1 = new System.Windows.Forms.TextBox(); - this.textBoxAxis2 = new System.Windows.Forms.TextBox(); - this.textBoxAxis3 = new System.Windows.Forms.TextBox(); - this.textBoxAxis4 = new System.Windows.Forms.TextBox(); - this.textBoxAxis5 = new System.Windows.Forms.TextBox(); - this.textBoxAxis6 = new System.Windows.Forms.TextBox(); - this.textBoxAxis7 = new System.Windows.Forms.TextBox(); - this.textBoxAxis8 = new System.Windows.Forms.TextBox(); - this.textBoxAxis9 = new System.Windows.Forms.TextBox(); - this.textBoxAxis10 = new System.Windows.Forms.TextBox(); - this.labelAxis1 = new System.Windows.Forms.Label(); - this.labelAxis2 = new System.Windows.Forms.Label(); - this.labelAxis3 = new System.Windows.Forms.Label(); - this.labelAxis4 = new System.Windows.Forms.Label(); - this.labelAxis5 = new System.Windows.Forms.Label(); - this.labelAxis6 = new System.Windows.Forms.Label(); - this.labelAxis7 = new System.Windows.Forms.Label(); - this.labelAxis8 = new System.Windows.Forms.Label(); - this.labelAxis9 = new System.Windows.Forms.Label(); - this.labelAxis10 = new System.Windows.Forms.Label(); - this.JoystickButtonsBox = new System.Windows.Forms.ListBox(); - this.tabControl.SuspendLayout(); - this.Keyboard.SuspendLayout(); - this.Mouse.SuspendLayout(); - this.HID.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, 379); - 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(64, 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(64, 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(64, 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(64, 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.BackColor = System.Drawing.SystemColors.ControlLight; - this.Mouse.Controls.Add(this.WindowY); - this.Mouse.Controls.Add(this.WindowX); - this.Mouse.Controls.Add(this.MouseYWindow); - this.Mouse.Controls.Add(this.MouseXWindow); - this.Mouse.Controls.Add(this.MouseWheelDelta); - this.Mouse.Controls.Add(this.WheelDelta); - this.Mouse.Controls.Add(this.MouseWheelText); - this.Mouse.Controls.Add(this.MouseWheelLabel); - 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.MouseDYText); - this.Mouse.Controls.Add(this.MouseDXText); - this.Mouse.Controls.Add(this.MouseYText); - this.Mouse.Controls.Add(this.MouseXText); - this.Mouse.Controls.Add(this.MouseButtonsBox); - 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, 353); - this.Mouse.TabIndex = 1; - this.Mouse.Text = "Mouse"; - // - // WindowY - // - this.WindowY.AutoSize = true; - this.WindowY.Location = new System.Drawing.Point(4, 239); - this.WindowY.Name = "WindowY"; - this.WindowY.Size = new System.Drawing.Size(62, 13); - this.WindowY.TabIndex = 17; - this.WindowY.Text = "Window Y:"; - // - // WindowX - // - this.WindowX.AutoSize = true; - this.WindowX.Location = new System.Drawing.Point(4, 212); - this.WindowX.Name = "WindowX"; - this.WindowX.Size = new System.Drawing.Size(63, 13); - this.WindowX.TabIndex = 16; - this.WindowX.Text = "Window X:"; - // - // MouseYWindow - // - this.MouseYWindow.Location = new System.Drawing.Point(80, 232); - this.MouseYWindow.Name = "MouseYWindow"; - this.MouseYWindow.ReadOnly = true; - this.MouseYWindow.Size = new System.Drawing.Size(73, 22); - this.MouseYWindow.TabIndex = 15; - // - // MouseXWindow - // - this.MouseXWindow.Location = new System.Drawing.Point(80, 205); - this.MouseXWindow.Name = "MouseXWindow"; - this.MouseXWindow.ReadOnly = true; - this.MouseXWindow.Size = new System.Drawing.Size(73, 22); - this.MouseXWindow.TabIndex = 14; - // - // MouseWheelDelta - // - this.MouseWheelDelta.Location = new System.Drawing.Point(80, 178); - this.MouseWheelDelta.Name = "MouseWheelDelta"; - this.MouseWheelDelta.ReadOnly = true; - this.MouseWheelDelta.Size = new System.Drawing.Size(73, 22); - this.MouseWheelDelta.TabIndex = 13; - // - // WheelDelta - // - this.WheelDelta.AutoSize = true; - this.WheelDelta.Location = new System.Drawing.Point(4, 185); - this.WheelDelta.Name = "WheelDelta"; - this.WheelDelta.Size = new System.Drawing.Size(73, 13); - this.WheelDelta.TabIndex = 12; - this.WheelDelta.Text = "Wheel Delta:"; - // - // MouseWheelText - // - this.MouseWheelText.Location = new System.Drawing.Point(80, 152); - this.MouseWheelText.Name = "MouseWheelText"; - this.MouseWheelText.ReadOnly = true; - this.MouseWheelText.Size = new System.Drawing.Size(73, 22); - this.MouseWheelText.TabIndex = 11; - // - // MouseWheelLabel - // - this.MouseWheelLabel.AutoSize = true; - this.MouseWheelLabel.Location = new System.Drawing.Point(4, 159); - this.MouseWheelLabel.Name = "MouseWheelLabel"; - this.MouseWheelLabel.Size = new System.Drawing.Size(43, 13); - this.MouseWheelLabel.TabIndex = 10; - this.MouseWheelLabel.Text = "Wheel:"; - // - // 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:"; - // - // 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(46, 13); - this.MouseDeltaX.TabIndex = 8; - this.MouseDeltaX.Text = "Delta 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(60, 13); - this.MouseY.TabIndex = 7; - this.MouseY.Text = "Position Y:"; - // - // 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(61, 13); - this.MouseX.TabIndex = 6; - this.MouseX.Text = "Position X:"; - // - // MouseDYText - // - this.MouseDYText.Location = new System.Drawing.Point(80, 125); - this.MouseDYText.Name = "MouseDYText"; - this.MouseDYText.ReadOnly = true; - this.MouseDYText.Size = new System.Drawing.Size(73, 22); - this.MouseDYText.TabIndex = 5; - // - // MouseDXText - // - this.MouseDXText.Location = new System.Drawing.Point(80, 98); - this.MouseDXText.Name = "MouseDXText"; - this.MouseDXText.ReadOnly = true; - this.MouseDXText.Size = new System.Drawing.Size(73, 22); - this.MouseDXText.TabIndex = 4; - // - // MouseYText - // - this.MouseYText.Location = new System.Drawing.Point(80, 71); - this.MouseYText.Name = "MouseYText"; - this.MouseYText.ReadOnly = true; - this.MouseYText.Size = new System.Drawing.Size(73, 22); - this.MouseYText.TabIndex = 3; - // - // MouseXText - // - this.MouseXText.Location = new System.Drawing.Point(80, 44); - this.MouseXText.Name = "MouseXText"; - this.MouseXText.ReadOnly = true; - this.MouseXText.Size = new System.Drawing.Size(73, 22); - this.MouseXText.TabIndex = 2; - // - // MouseButtonsBox - // - this.MouseButtonsBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MouseButtonsBox.FormattingEnabled = true; - this.MouseButtonsBox.Location = new System.Drawing.Point(190, 44); - this.MouseButtonsBox.Name = "MouseButtonsBox"; - this.MouseButtonsBox.Size = new System.Drawing.Size(226, 303); - this.MouseButtonsBox.TabIndex = 1; - // - // ChooseMouse - // - this.ChooseMouse.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - 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; - this.ChooseMouse.SelectedIndexChanged += new System.EventHandler(this.ChooseMouse_SelectedIndexChanged); - // - // HID - // - this.HID.Controls.Add(this.labelAxis10); - this.HID.Controls.Add(this.labelAxis9); - this.HID.Controls.Add(this.labelAxis8); - this.HID.Controls.Add(this.labelAxis7); - this.HID.Controls.Add(this.labelAxis6); - this.HID.Controls.Add(this.labelAxis5); - this.HID.Controls.Add(this.labelAxis4); - this.HID.Controls.Add(this.labelAxis3); - this.HID.Controls.Add(this.labelAxis2); - this.HID.Controls.Add(this.labelAxis1); - this.HID.Controls.Add(this.textBoxAxis10); - this.HID.Controls.Add(this.textBoxAxis9); - this.HID.Controls.Add(this.textBoxAxis8); - this.HID.Controls.Add(this.textBoxAxis7); - this.HID.Controls.Add(this.textBoxAxis6); - this.HID.Controls.Add(this.textBoxAxis5); - this.HID.Controls.Add(this.textBoxAxis4); - this.HID.Controls.Add(this.textBoxAxis3); - this.HID.Controls.Add(this.textBoxAxis2); - this.HID.Controls.Add(this.textBoxAxis1); - this.HID.Controls.Add(this.JoystickButtonsBox); - this.HID.Controls.Add(this.comboBoxActiveJoystick); - 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, 353); - this.HID.TabIndex = 2; - this.HID.Text = "HID"; - this.HID.UseVisualStyleBackColor = true; - // - // PollTimer - // - this.PollTimer.Interval = 10; - // - // comboBoxActiveJoystick - // - this.comboBoxActiveJoystick.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.comboBoxActiveJoystick.FormattingEnabled = true; - this.comboBoxActiveJoystick.Location = new System.Drawing.Point(7, 7); - this.comboBoxActiveJoystick.Name = "comboBoxActiveJoystick"; - this.comboBoxActiveJoystick.Size = new System.Drawing.Size(409, 21); - this.comboBoxActiveJoystick.TabIndex = 0; - // - // textBoxAxis1 - // - this.textBoxAxis1.Location = new System.Drawing.Point(55, 43); - this.textBoxAxis1.Name = "textBoxAxis1"; - this.textBoxAxis1.ReadOnly = true; - this.textBoxAxis1.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis1.TabIndex = 2; - // - // textBoxAxis2 - // - this.textBoxAxis2.Location = new System.Drawing.Point(55, 72); - this.textBoxAxis2.Name = "textBoxAxis2"; - this.textBoxAxis2.ReadOnly = true; - this.textBoxAxis2.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis2.TabIndex = 3; - // - // textBoxAxis3 - // - this.textBoxAxis3.Location = new System.Drawing.Point(55, 101); - this.textBoxAxis3.Name = "textBoxAxis3"; - this.textBoxAxis3.ReadOnly = true; - this.textBoxAxis3.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis3.TabIndex = 4; - // - // textBoxAxis4 - // - this.textBoxAxis4.Location = new System.Drawing.Point(55, 130); - this.textBoxAxis4.Name = "textBoxAxis4"; - this.textBoxAxis4.ReadOnly = true; - this.textBoxAxis4.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis4.TabIndex = 5; - // - // textBoxAxis5 - // - this.textBoxAxis5.Location = new System.Drawing.Point(55, 158); - this.textBoxAxis5.Name = "textBoxAxis5"; - this.textBoxAxis5.ReadOnly = true; - this.textBoxAxis5.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis5.TabIndex = 6; - // - // textBoxAxis6 - // - this.textBoxAxis6.Location = new System.Drawing.Point(55, 186); - this.textBoxAxis6.Name = "textBoxAxis6"; - this.textBoxAxis6.ReadOnly = true; - this.textBoxAxis6.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis6.TabIndex = 7; - // - // textBoxAxis7 - // - this.textBoxAxis7.Location = new System.Drawing.Point(55, 214); - this.textBoxAxis7.Name = "textBoxAxis7"; - this.textBoxAxis7.ReadOnly = true; - this.textBoxAxis7.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis7.TabIndex = 8; - // - // textBoxAxis8 - // - this.textBoxAxis8.Location = new System.Drawing.Point(55, 242); - this.textBoxAxis8.Name = "textBoxAxis8"; - this.textBoxAxis8.ReadOnly = true; - this.textBoxAxis8.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis8.TabIndex = 9; - // - // textBoxAxis9 - // - this.textBoxAxis9.Location = new System.Drawing.Point(55, 270); - this.textBoxAxis9.Name = "textBoxAxis9"; - this.textBoxAxis9.ReadOnly = true; - this.textBoxAxis9.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis9.TabIndex = 10; - // - // textBoxAxis10 - // - this.textBoxAxis10.Location = new System.Drawing.Point(55, 298); - this.textBoxAxis10.Name = "textBoxAxis10"; - this.textBoxAxis10.ReadOnly = true; - this.textBoxAxis10.Size = new System.Drawing.Size(129, 22); - this.textBoxAxis10.TabIndex = 11; - // - // labelAxis1 - // - this.labelAxis1.AutoSize = true; - this.labelAxis1.Location = new System.Drawing.Point(4, 46); - this.labelAxis1.Name = "labelAxis1"; - this.labelAxis1.Size = new System.Drawing.Size(39, 13); - this.labelAxis1.TabIndex = 12; - this.labelAxis1.Text = "Axis 1:"; - // - // labelAxis2 - // - this.labelAxis2.AutoSize = true; - this.labelAxis2.Location = new System.Drawing.Point(4, 75); - this.labelAxis2.Name = "labelAxis2"; - this.labelAxis2.Size = new System.Drawing.Size(39, 13); - this.labelAxis2.TabIndex = 13; - this.labelAxis2.Text = "Axis 2:"; - // - // labelAxis3 - // - this.labelAxis3.AutoSize = true; - this.labelAxis3.Location = new System.Drawing.Point(4, 104); - this.labelAxis3.Name = "labelAxis3"; - this.labelAxis3.Size = new System.Drawing.Size(39, 13); - this.labelAxis3.TabIndex = 14; - this.labelAxis3.Text = "Axis 3:"; - // - // labelAxis4 - // - this.labelAxis4.AutoSize = true; - this.labelAxis4.Location = new System.Drawing.Point(4, 133); - this.labelAxis4.Name = "labelAxis4"; - this.labelAxis4.Size = new System.Drawing.Size(39, 13); - this.labelAxis4.TabIndex = 15; - this.labelAxis4.Text = "Axis 4:"; - // - // labelAxis5 - // - this.labelAxis5.AutoSize = true; - this.labelAxis5.Location = new System.Drawing.Point(4, 161); - this.labelAxis5.Name = "labelAxis5"; - this.labelAxis5.Size = new System.Drawing.Size(39, 13); - this.labelAxis5.TabIndex = 16; - this.labelAxis5.Text = "Axis 5:"; - // - // labelAxis6 - // - this.labelAxis6.AutoSize = true; - this.labelAxis6.Location = new System.Drawing.Point(4, 189); - this.labelAxis6.Name = "labelAxis6"; - this.labelAxis6.Size = new System.Drawing.Size(39, 13); - this.labelAxis6.TabIndex = 17; - this.labelAxis6.Text = "Axis 6:"; - // - // labelAxis7 - // - this.labelAxis7.AutoSize = true; - this.labelAxis7.Location = new System.Drawing.Point(4, 217); - this.labelAxis7.Name = "labelAxis7"; - this.labelAxis7.Size = new System.Drawing.Size(39, 13); - this.labelAxis7.TabIndex = 18; - this.labelAxis7.Text = "Axis 7:"; - // - // labelAxis8 - // - this.labelAxis8.AutoSize = true; - this.labelAxis8.Location = new System.Drawing.Point(4, 245); - this.labelAxis8.Name = "labelAxis8"; - this.labelAxis8.Size = new System.Drawing.Size(39, 13); - this.labelAxis8.TabIndex = 18; - this.labelAxis8.Text = "Axis 8:"; - // - // labelAxis9 - // - this.labelAxis9.AutoSize = true; - this.labelAxis9.Location = new System.Drawing.Point(4, 273); - this.labelAxis9.Name = "labelAxis9"; - this.labelAxis9.Size = new System.Drawing.Size(39, 13); - this.labelAxis9.TabIndex = 19; - this.labelAxis9.Text = "Axis 9:"; - // - // labelAxis10 - // - this.labelAxis10.AutoSize = true; - this.labelAxis10.Location = new System.Drawing.Point(4, 301); - this.labelAxis10.Name = "labelAxis10"; - this.labelAxis10.Size = new System.Drawing.Size(45, 13); - this.labelAxis10.TabIndex = 20; - this.labelAxis10.Text = "Axis 10:"; - // - // JoystickButtonsBox - // - this.JoystickButtonsBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.JoystickButtonsBox.FormattingEnabled = true; - this.JoystickButtonsBox.Location = new System.Drawing.Point(190, 43); - this.JoystickButtonsBox.Name = "JoystickButtonsBox"; - this.JoystickButtonsBox.Size = new System.Drawing.Size(226, 303); - this.JoystickButtonsBox.TabIndex = 1; - // - // InputLogger - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(432, 379); - this.Controls.Add(this.tabControl); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.Name = "InputLogger"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "S04: Input Logger"; - this.tabControl.ResumeLayout(false); - this.Keyboard.ResumeLayout(false); - this.Keyboard.PerformLayout(); - this.Mouse.ResumeLayout(false); - this.Mouse.PerformLayout(); - this.HID.ResumeLayout(false); - this.HID.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; - private System.Windows.Forms.ComboBox ChooseMouse; - private System.Windows.Forms.ListBox MouseButtonsBox; - 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 MouseDYText; - private System.Windows.Forms.TextBox MouseDXText; - private System.Windows.Forms.TextBox MouseYText; - private System.Windows.Forms.TextBox MouseXText; - private System.Windows.Forms.TextBox MouseWheelText; - private System.Windows.Forms.Label MouseWheelLabel; - private System.Windows.Forms.TextBox MouseWheelDelta; - private System.Windows.Forms.Label WheelDelta; - private System.Windows.Forms.Timer PollTimer; - private System.Windows.Forms.TextBox MouseXWindow; - private System.Windows.Forms.Label WindowY; - private System.Windows.Forms.Label WindowX; - private System.Windows.Forms.TextBox MouseYWindow; - private System.Windows.Forms.ComboBox comboBoxActiveJoystick; - private System.Windows.Forms.Label labelAxis10; - private System.Windows.Forms.Label labelAxis9; - private System.Windows.Forms.Label labelAxis8; - private System.Windows.Forms.Label labelAxis7; - private System.Windows.Forms.Label labelAxis6; - private System.Windows.Forms.Label labelAxis5; - private System.Windows.Forms.Label labelAxis4; - private System.Windows.Forms.Label labelAxis3; - private System.Windows.Forms.Label labelAxis2; - private System.Windows.Forms.Label labelAxis1; - private System.Windows.Forms.TextBox textBoxAxis10; - private System.Windows.Forms.TextBox textBoxAxis9; - private System.Windows.Forms.TextBox textBoxAxis8; - private System.Windows.Forms.TextBox textBoxAxis7; - private System.Windows.Forms.TextBox textBoxAxis6; - private System.Windows.Forms.TextBox textBoxAxis5; - private System.Windows.Forms.TextBox textBoxAxis4; - private System.Windows.Forms.TextBox textBoxAxis3; - private System.Windows.Forms.TextBox textBoxAxis2; - private System.Windows.Forms.TextBox textBoxAxis1; - private System.Windows.Forms.ListBox JoystickButtonsBox; - - } -} \ No newline at end of file diff --git a/Source/Examples/OpenTK/Test/InputLogger.cs b/Source/Examples/OpenTK/Test/InputLogger.cs deleted file mode 100644 index 3ef5821..0000000 --- a/Source/Examples/OpenTK/Test/InputLogger.cs +++ /dev/null @@ -1,311 +0,0 @@ -#region --- License --- -/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos - * See license.txt for license info - */ -#endregion - -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; -using System.Threading; - -using OpenTK.Graphics; -using OpenTK.Graphics.OpenGL; - -namespace Examples.Tests -{ - [Example("Input Logger", ExampleCategory.OpenTK, "Test", Documentation="InputLogger")] - public partial class InputLogger : Form - { - #region Fields - - Thread thread; - GameWindow hidden; - bool start; - Dictionary keyboardListBoxes = new Dictionary(4); - - #endregion - - #region Constructors - - public InputLogger() - { - InitializeComponent(); - } - - #endregion - - #region GameWindow - - void LaunchGameWindow() - { - hidden = new GameWindow(320, 240, GraphicsMode.Default, "OpenTK | Hidden input window"); - hidden.Load += hidden_Load; - hidden.Unload += hidden_Unload; - hidden.RenderFrame += hidden_RenderFrame; - hidden.Run(60.0, 0.0); - } - - void hidden_RenderFrame(object sender, FrameEventArgs e) - { - GL.Clear(ClearBufferMask.ColorBufferBit); - ((GameWindow)sender).SwapBuffers(); - } - - void hidden_Load(object sender, EventArgs e) - { - hidden.VSync = VSyncMode.On; - start = true; - GL.ClearColor(Color.Black); - } - - void hidden_Unload(object sender, EventArgs e) - { - this.BeginInvoke(on_hidden_unload, sender, e, this); - } - - delegate void CloseTrigger(GameWindow sender, EventArgs e, Form f); - CloseTrigger on_hidden_unload = delegate(GameWindow sender, EventArgs e, Form f) { f.Close(); }; - - #endregion - - #region Protected Members - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - thread = new Thread(LaunchGameWindow); - thread.Start(); - - while (!start) - Thread.Sleep(100); - - keyboardListBoxes.Add(hidden.Keyboard.DeviceID, listBox1); - - // Add available mice to the mouse input logger. - ChooseMouse.Items.Add(String.Format("Mouse {0} ({1})", 0, hidden.Mouse.Description)); - ChooseMouse.SelectedIndex = 0; - - hidden.Mouse.Move += LogMouseMove; - hidden.Mouse.WheelChanged += LogMouseWheelChanged; - hidden.Mouse.ButtonDown += LogMouseButtonDown; - hidden.Mouse.ButtonUp += LogMouseButtonUp; - - hidden.Keyboard.KeyDown += LogKeyDown; - hidden.Keyboard.KeyUp += LogKeyUp; - - #region Joysticks - - foreach (JoystickDevice joystick in hidden.Joysticks) - { - comboBoxActiveJoystick.Items.Add(joystick.Description); - - joystick.Move += delegate(object sender, JoystickMoveEventArgs args) - { - this.BeginInvoke(ControlLogJoystickMoved, this, sender, args); - }; - joystick.ButtonDown += delegate(object sender, JoystickButtonEventArgs args) - { - this.BeginInvoke(ControlLogJoystickButtonDown, this, sender, args); - }; - joystick.ButtonUp += delegate(object sender, JoystickButtonEventArgs args) - { - this.BeginInvoke(ControlLogJoystickButtonUp, this, sender, args); - }; - } - if (comboBoxActiveJoystick.Items.Count > 0) - comboBoxActiveJoystick.SelectedIndex = 0; - - #endregion - } - - protected override void OnClosing(CancelEventArgs e) - { - base.OnClosing(e); - - hidden.Exit(); - - while (hidden.Exists) - Thread.Sleep(100); - - e.Cancel = false; - } - - #endregion - - #region Private Members - - private void ChooseMouse_SelectedIndexChanged(object sender, EventArgs e) - { - MouseButtonsBox.Items.Clear(); - } - - #endregion - - #region Logging Delegates - - #region Mice - - delegate void ControlLogMouseKey(GameWindow input_window, InputLogger control, object sender, MouseButtonEventArgs e); - ControlLogMouseKey ControlLogMouseKeyDown = - delegate(GameWindow input_window, InputLogger control, object sender, MouseButtonEventArgs e) - { - if ((sender as MouseDevice).DeviceID == input_window.Mouse.DeviceID) - { - control.MouseButtonsBox.Items.Add(e.Button); - System.Diagnostics.Debug.Print("Button down: {0}", e.Button); - } - }; - ControlLogMouseKey ControlLogMouseKeyUp = - delegate(GameWindow input_window, InputLogger control, object sender, MouseButtonEventArgs e) - { - if ((sender as MouseDevice).DeviceID == input_window.Mouse.DeviceID) - { - control.MouseButtonsBox.Items.Remove(e.Button); - System.Diagnostics.Debug.Print("Button up: {0}", e.Button); - } - }; - - delegate void ControlLogMouseMove(GameWindow input_window, InputLogger control, object sender, MouseMoveEventArgs e); - ControlLogMouseMove ControlLogMouseMoveChanges = - delegate(GameWindow input_window, InputLogger control, object sender, MouseMoveEventArgs e) - { - control.MouseXText.Text = e.X.ToString(); - control.MouseYText.Text = e.Y.ToString(); - }; - - delegate void ControlLogMouseWheel(GameWindow input_window, InputLogger control, object sender, MouseWheelEventArgs e); - ControlLogMouseWheel ControlLogMouseWheelChanges = - delegate(GameWindow input_window, InputLogger control, object sender, MouseWheelEventArgs e) - { - control.MouseWheelText.Text = e.ValuePrecise.ToString("F2"); - }; - - #endregion - - #region Keyboards - - delegate void ControlLogKeyboard(GameWindow input_window, InputLogger control, OpenTK.Input.KeyboardDevice sender, KeyboardKeyEventArgs e); - ControlLogKeyboard ControlLogKeyboardDown = - delegate(GameWindow input_window, InputLogger control, KeyboardDevice sender, KeyboardKeyEventArgs e) - { - control.keyboardListBoxes[sender.DeviceID].Items.Add(e.Key); - }; - ControlLogKeyboard ControlLogKeyboardUp = - delegate(GameWindow input_window, InputLogger control, KeyboardDevice sender, KeyboardKeyEventArgs e) - { - control.keyboardListBoxes[sender.DeviceID].Items.Remove(e.Key); - }; - - #endregion - - #region Joysticks - - delegate void ControlLogJoystickMove(InputLogger control, object sender, JoystickMoveEventArgs e); - ControlLogJoystickMove ControlLogJoystickMoved = - delegate(InputLogger control, object sender, JoystickMoveEventArgs e) - { - // Yes, there are things such as arrays. Tell that to the visual studio designer! - switch (e.Axis) - { - case JoystickAxis.Axis0: control.textBoxAxis1.Text = e.Value.ToString(); break; - case JoystickAxis.Axis1: control.textBoxAxis2.Text = e.Value.ToString(); break; - case JoystickAxis.Axis2: control.textBoxAxis3.Text = e.Value.ToString(); break; - case JoystickAxis.Axis3: control.textBoxAxis4.Text = e.Value.ToString(); break; - case JoystickAxis.Axis4: control.textBoxAxis5.Text = e.Value.ToString(); break; - case JoystickAxis.Axis5: control.textBoxAxis6.Text = e.Value.ToString(); break; - case JoystickAxis.Axis6: control.textBoxAxis7.Text = e.Value.ToString(); break; - case JoystickAxis.Axis7: control.textBoxAxis8.Text = e.Value.ToString(); break; - case JoystickAxis.Axis8: control.textBoxAxis9.Text = e.Value.ToString(); break; - case JoystickAxis.Axis9: control.textBoxAxis10.Text = e.Value.ToString(); break; - } - }; - - delegate void ControlLogJoystickButton(InputLogger control, object sender, JoystickButtonEventArgs e); - ControlLogJoystickButton ControlLogJoystickButtonDown = - delegate(InputLogger control, object sender, JoystickButtonEventArgs e) - { - if ((sender as JoystickDevice).Description == control.comboBoxActiveJoystick.Text) - { - control.JoystickButtonsBox.Items.Add(e.Button); - System.Diagnostics.Debug.Print("Joystick button down: {0}", e.Button); - } - }; - ControlLogJoystickButton ControlLogJoystickButtonUp = - delegate(InputLogger control, object sender, JoystickButtonEventArgs e) - { - if ((sender as JoystickDevice).Description == control.comboBoxActiveJoystick.Text) - { - control.JoystickButtonsBox.Items.Remove(e.Button); - System.Diagnostics.Debug.Print("Joystick button down: {0}", e.Button); - } - }; - - #endregion - - #endregion - - #region Input Event Handlers - - void LogMouseMove(object sender, MouseMoveEventArgs e) - { - this.BeginInvoke(ControlLogMouseMoveChanges, hidden, this, sender, e); - } - - void LogMouseWheelChanged(object sender, MouseWheelEventArgs e) - { - this.BeginInvoke(ControlLogMouseWheelChanges, hidden, this, sender, e); - } - - void LogMouseButtonDown(object sender, MouseButtonEventArgs e) - { - this.BeginInvoke(ControlLogMouseKeyDown, hidden, this, sender, e); - } - - void LogMouseButtonUp(object sender, MouseButtonEventArgs e) - { - this.BeginInvoke(ControlLogMouseKeyUp, hidden, this, sender, e); - } - - void LogKeyDown(object sender, KeyboardKeyEventArgs key) - { - this.BeginInvoke(ControlLogKeyboardDown, hidden, this, sender, key); - } - - void LogKeyUp(object sender, KeyboardKeyEventArgs key) - { - this.BeginInvoke(ControlLogKeyboardUp, hidden, this, sender, key); - } - - #endregion - - #region public static void Main() - - /// - /// Entry point of this example. - /// - [STAThread] - public static void Main() - { - using (InputLogger example = new InputLogger()) - { - // Get the title and category of this example using reflection. - ExampleAttribute info = ((ExampleAttribute)example.GetType().GetCustomAttributes(false)[0]); - example.Text = String.Format("OpenTK | {0} {1}: {2}", info.Category, info.Difficulty, info.Title); - example.ShowDialog(); - } - } - - #endregion - } -} diff --git a/Source/Examples/OpenTK/Test/InputLogger.resx b/Source/Examples/OpenTK/Test/InputLogger.resx deleted file mode 100644 index b19ade6..0000000 --- a/Source/Examples/OpenTK/Test/InputLogger.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/Source/Examples/OpenTK/Test/Multithreading.cs b/Source/Examples/OpenTK/Test/Multithreading.cs index 77c90f8..7e8383b 100644 --- a/Source/Examples/OpenTK/Test/Multithreading.cs +++ b/Source/Examples/OpenTK/Test/Multithreading.cs @@ -39,7 +39,7 @@ namespace Examples.Tests using (Tutorial.T03_Immediate_Mode_Cube game = new Examples.Tutorial.T03_Immediate_Mode_Cube()) { Utilities.SetWindowTitle(game); - game.Keyboard.KeyUp += delegate(object sender, OpenTK.Input.KeyboardKeyEventArgs e) + game.KeyUp += delegate(object sender, OpenTK.Input.KeyboardKeyEventArgs e) { if (e.Key == OpenTK.Input.Key.F11) { diff --git a/Source/Examples/OpenTK/Test/TestShaderUtf8Support.cs b/Source/Examples/OpenTK/Test/TestShaderUtf8Support.cs index b410fca..f61a3b2 100644 --- a/Source/Examples/OpenTK/Test/TestShaderUtf8Support.cs +++ b/Source/Examples/OpenTK/Test/TestShaderUtf8Support.cs @@ -207,7 +207,8 @@ void main(void) Matrix4.Mult(ref rotation, ref modelviewMatrix, out modelviewMatrix); GL.UniformMatrix4(modelviewMatrixLocation, false, ref modelviewMatrix); - if (Keyboard[OpenTK.Input.Key.Escape]) + var keyboard = OpenTK.Input.Keyboard.GetState(); + if (keyboard[OpenTK.Input.Key.Escape]) Exit(); } -- 2.7.4