Win32 disable or get around key repeating (only check if up or down once)

Started by
37 comments, last by BennettSteele 12 years, 3 months ago
DX Just that easy? So how instead of using the


if (lParam & 0x40000000)




I could just check first for the first key-press? also, i think i will use your Wind-Proc method, but keep the key-class i made... that way i can organize the keys and allow re-defining keys.
Advertisement

Oh! I think i get it... so what does lParam & 0x000000000 mean?

if (lParam & 0x40000000) tests whether or not the leftmost bit of lParam is set (& is the bitwise AND operator, and should not be confused with the logical AND operator &&)
0x... is a Hexadecimal number. 0x40000000 (hex) = 01000000000000000000000000000000 (binary) = 1073741824 (decimal). In C++, there are ways to natively write numbers in decimal, hexadecimal, and octal (but not binary) formats, and I chose hexadecimal for this case because it's easy to read. Like RulerOfNothing said, the & operator is the bitwise AND operator. Googling "C++ operators" should give you plenty to read, as should "bitwise AND".
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Oh! so bits 0-15 (16 bits) is the same as 0x40000000 because the 4 is a power of 2? so the 4 counts for 16 bits?
One thing you should remember about hexadecimal is that each hexadecimal digit corresponds to 4 bits, so if you have a 8-digit hexadecimal number, it is actually 32 bits long.

Oh! so bits 0-15 (16 bits) is the same as 0x40000000 because the 4 is a power of 2? so the 4 counts for 16 bits?


Nope. I'm really not sure what it is you were trying to say there either. You should google hexadecimal and how to convert between hex and binary (and decimal).
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Oh well... so would using


if (lParam & 0x00000000)


Checks for no key repeats?
lParam & 0x0000000 will always evaluate to zero because of how AND operators work.
So what is the value for checking if it was the first key press?

This topic is closed to new replies.

Advertisement