I already understand how to work with Keyboard
and KeyboardState
, but when debugging I happened to take a look at the KeyboardState
's non-public members via the VS debugger. I expected to see a large list of values, but instead, only saw 8 uints at a static level, and another 8 uints per instance:
Non-Public members (static)
stateMask0 uint 976757505
stateMask1 uint 67108863
stateMask2 uint 3221225470
stateMask3 uint 4294967295
stateMask4 uint 196863
stateMask5 uint 4244635647
stateMask6 uint 4160752641
stateMask7 uint 1876688932
Non-Public members (instance)
currentState0 uint 0
currentState1 uint 0
currentState2 uint 0
currentState3 uint 1048576
currentState4 uint 0
currentState5 uint 0
currentState6 uint 0
currentState7 uint 0
There are 32 bits per uint, so having 8 of them essentially acts as a field of 256 boolean values, which loosely corresponds with the Keys
enum type, so I assume that the static values act as a way to test which buttons are present on a device. However, XNA supports up to 4 keyboards, so I'm not sure how it both translates this to a button state, nor how it can differentiate between different keyboards in this way.