Permalink
Browse files

Supress printing of some keyboard non-errors.

  • Loading branch information...
andykorth committed Dec 22, 2012
1 parent 39c3f3f commit c98d9e4503cf8f9498a17ddd2d37bb3d0e84511d
Showing with 8 additions and 4 deletions.
  1. +1 −1 Source/Examples/OpenTK/Test/BasicMouseInput.cs
  2. +7 −3 Source/OpenTK/Platform/MacOS/HIDInput.cs
@@ -45,7 +45,7 @@ protected override void OnUpdateFrame(FrameEventArgs e)
// While we are here, test keyboard.
if(OpenTK.Input.Keyboard.GetState()[Key.A]){
- Console.WriteLine("The A key is down!");
+ Console.WriteLine("The A key is down!");
}
if (Keyboard[OpenTK.Input.Key.Escape])
@@ -254,13 +254,17 @@ static KeyboardState UpdateKeyboard(KeyboardState state, IOHIDValueRef val)
int v_int = NativeMethods.IOHIDValueGetIntegerValue(val).ToInt32();
HIDPage page = NativeMethods.IOHIDElementGetUsagePage(elem);
int usage = NativeMethods.IOHIDElementGetUsage(elem);
+
+ // This will supress the debug printing below. Seems like it generates a lot of -1s.
+ // Couldn't find any details in USB spec or Apple docs for this behavior.
+ if(usage < 0 ) return state;
- switch (page)
+ switch (page)
{
case HIDPage.GenericDesktop:
case HIDPage.KeyboardOrKeypad:
- int raw = (int)usage;
- if (raw >= RawKeyMap.Length || raw < 0)
+ int raw = (int) usage;
+ if (raw >= RawKeyMap.Length)
{
Debug.Print("[Warning] Key {0} not mapped.", raw);
return state;

0 comments on commit c98d9e4

Please sign in to comment.