From d985362058bb1c9265a28cbfb7f63f6f356e571b Mon Sep 17 00:00:00 2001 From: thefiddler Date: Mon, 17 Feb 2014 23:28:29 +0100 Subject: [PATCH] [Examples] Display modifier key information --- Source/Examples/OpenTK/Test/GameWindowStates.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Examples/OpenTK/Test/GameWindowStates.cs b/Source/Examples/OpenTK/Test/GameWindowStates.cs index f5cbcfea..2e5ce406 100644 --- a/Source/Examples/OpenTK/Test/GameWindowStates.cs +++ b/Source/Examples/OpenTK/Test/GameWindowStates.cs @@ -42,12 +42,15 @@ namespace Examples.Tests double variable_refresh_timestep_pos = -1; double fixed_update_timestep_pos = -1; + KeyModifiers modifiers; + public GameWindowStates() : base(800, 600, GraphicsMode.Default) { VSync = VSyncMode.On; Keyboard.KeyRepeat = true; KeyDown += KeyDownHandler; + KeyUp += KeyUpHandler; KeyPress += KeyPressHandler; MouseEnter += delegate { mouse_in_window = true; }; @@ -106,6 +109,12 @@ namespace Examples.Tests case Key.Comma: TargetRenderFrequency--; break; case Key.Period: TargetRenderFrequency++; break; } + modifiers = e.Modifiers; + } + + void KeyUpHandler(object sender, KeyboardKeyEventArgs e) + { + modifiers = e.Modifiers; } void MouseMoveHandler(object sender, MouseMoveEventArgs e) @@ -136,10 +145,10 @@ namespace Examples.Tests return offset + gfx.MeasureString(str, TextFont).Width; } - static int DrawKeyboards(Graphics gfx, int line) + int DrawKeyboards(Graphics gfx, int line) { line++; - DrawString(gfx, "Keyboard:", line++); + DrawString(gfx, String.Format("Keyboard ({0}):", modifiers), line++); for (int i = 0; i < 4; i++) { var state = OpenTK.Input.Keyboard.GetState(i);