
Scan code keyboard data
Posted Sunday, 30 December, 2012 - 19:31 by Artfunkel| Project: | The Open Toolkit library |
| Version: | all versions |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | open |
Jump to:
Description
This patch adds scan code support to OpenTK's keyboard system.
- Keyboard events include the scan code
- Scan codes can be checked on the keyboard object (use uint instead of Key)
- Events are now generated even when an unknown key is pressed (you receive Key.Unknown and the scan code)
Example of use:
if (Keyboard[0x11]) // W KeyOffset.Y -= offset; if (Keyboard[0x1E]) // A KeyOffset.X += offset; if (Keyboard[0x1F]) // S KeyOffset.Y += offset; if (Keyboard[0x20]) // D KeyOffset.X -= offset;
The above code allows WASD to be mapped correctly even if the user has a non-QWERTY keyboard layout.


Comments
#1
Hey Artfunkel, do you think you could create a new patch that ignores whitespace changes? It looks like the entire HIDInput.cs file changed, but it was probably just the line ending characters or something like that.
I think svn diff -x --ignore-space-change or -x --ignore-all-space should do the trick.. If it doesn't work out, it's not a huge deal, but I had a bunch of changes to HIDInput.cs, so it would make for some manual conflict finding.
Thanks!
-Andy
#2
Whoops.
http://pastebin.com/jE4trTK4
#3
Thanks, will take a look tomorrow!
#4
Sorry for the delay. I applied the patch locally and was testing it and found that it crashes the Mono vm on my mac.. Unfortunately without a stack trace, which is making it sort of a pain to track down.
The call that seems to do it in is:
OpenTK.Input.Keyboard.GetState()[Key.A]I'll look into it a bit more. Just wanted to give you an update since it's been a few days.
#5
I ended up bushing the branch with the diff here:
https://github.com/andykorth/opentk/tree/ScanCodeKeyboardBranch
And the applied patch:
https://github.com/andykorth/opentk/commit/0f64af130a1c132ae66b1d6e82f7e...