On Wed, Jun 27, 2018 at 11:24 AM John Found johnfound@asm32.info wrote:
While reading the code in wineX11.drv/keyboard.c I noticed the following fragment from the function X11DRV_KeymapNotify:
for (vkey = VK_LSHIFT; vkey <= VK_RMENU; vkey++) { int m = vkey - VK_LSHIFT;
if (modifiers[m].vkey && !(keystate[vkey] & 0x80) != !modifiers[m].pressed)
{ TRACE( "Adjusting state for vkey %#.2x. State before %#.2x\n", modifiers[m].vkey, keystate[vkey]); update_key_state( keystate, vkey, modifiers[m].pressed ); changed = TRUE; } }
Can someone explain what the condition pointed by >>> is doing? (Unfortunately, my C skills are pretty low...)
Why not simply "(modifiers[m].vkey && (keystate[vkey] & 0x80) != modifiers[m].pressed)"?
I don't immediately know what this if statement is for, but I can tell you that the ! operator converts a value of zero to 1 and a nonzero value to 0. So, if keystate[vkey] & 0x80 is 0 then modifiers[m].pressed must be nonzero and vice versa.
-Alex