DInput Scan Codes

Started by
10 comments, last by Zealot 21 years, 8 months ago
It worked when you converted to an int because an int has a length of 32 bits, a char can only store 7 bits (and a sign bit).
This is why the Left Control worked and the Right didn''t.

DIK_LCONTROL = 0x1D which is 11101 in binary, and so needs 5 bits to represent it.

DIK_RCONTROL = 0x9D which is 10011101 in binary, and so needs 8 bits to represent it. So, because the first bit was used as the sign it was interpreting the value differently.

It would also have worked if you used an unsigned char as this uses all 8 bits (there is no bit reserved for the sign).

It just goes to show ... Don''t ignore the warning messages. :-)

Cheers,
John
John ReynoldsCreative Asylum Ltdwww.creative-asylum.com
Advertisement
LOL carefull...I''m sure the authors of the book don''t really appreciate seeing their code posted for free..

Learn about game programming!Games Programming in C++: Start to Finish

This topic is closed to new replies.

Advertisement