public static KeyModifiers GetModifiers(Keymod mod) { KeyModifiers result = 0; result |= (mod & Keymod.ALT) != 0 ? KeyModifiers.Alt : 0; result |= (mod & Keymod.CTRL) != 0 ? KeyModifiers.Control : 0; result |= (mod & Keymod.SHIFT) != 0 ? KeyModifiers.Shift : 0; return(result); }
// Unfortunately, SDL does not report KeyDown events // when a modifier (e.g. shift, alt, etc) is first pressed. // It reports a keydown+keyup event pair when the modifier // is *released* - which means that we cannot use modifiers // for regular input (e.g. press control to fire a weapon.) // For that reason, we should also poll the keyboard directly // as necessary. // Fixme: this does not appear to work as expected. private void UpdateModifiers() { Keymod mod = SDL.GetModState(); state[Key.LAlt] = (mod & Keymod.LALT) != 0; state[Key.RAlt] = (mod & Keymod.RALT) != 0; state[Key.LControl] = (mod & Keymod.LCTRL) != 0; state[Key.RControl] = (mod & Keymod.RCTRL) != 0; state[Key.LShift] = (mod & Keymod.LSHIFT) != 0; state[Key.RShift] = (mod & Keymod.RSHIFT) != 0; state[Key.Menu] = (mod & Keymod.GUI) != 0; state[Key.CapsLock] = (mod & Keymod.CAPS) != 0; state[Key.NumLock] = (mod & Keymod.NUM) != 0; //state[Key.] = (mod & Keymod.MODE) != 0; }
// Unfortunately, SDL does not report KeyDown events // when a modifier (e.g. shift, alt, etc) is first pressed. // It reports a keydown+keyup event pair when the modifier // is *released* - which means that we cannot use modifiers // for regular input (e.g. press control to fire a weapon.) // For that reason, we should also poll the keyboard directly // as necessary. // Fixme: this does not appear to work as expected. void UpdateModifiers() { Keymod mod = SDL.GetModState(); state.SetKeyState(Key.LAlt, (byte)Scancode.LALT, (mod & Keymod.LALT) != 0); state.SetKeyState(Key.RAlt, (byte)Scancode.RALT, (mod & Keymod.RALT) != 0); state.SetKeyState(Key.LControl, (byte)Scancode.LCTRL, (mod & Keymod.LCTRL) != 0); state.SetKeyState(Key.RControl, (byte)Scancode.RCTRL, (mod & Keymod.CTRL) != 0); state.SetKeyState(Key.LShift, (byte)Scancode.LSHIFT, (mod & Keymod.LSHIFT) != 0); state.SetKeyState(Key.RShift, (byte)Scancode.RSHIFT, (mod & Keymod.RSHIFT) != 0); state.SetKeyState(Key.Menu, (byte)Scancode.APPLICATION, (mod & Keymod.GUI) != 0); state.SetKeyState(Key.CapsLock, (byte)Scancode.CAPSLOCK, (mod & Keymod.CAPS) != 0); state.SetKeyState(Key.NumLock, (byte)Scancode.NUMLOCKCLEAR, (mod & Keymod.NUM) != 0); //state.SetKeyState(Key., (byte)Scancode.MODE, (mod & Keymod.MODE) != 0); }
public static KeyModifiers GetModifiers(Keymod mod) { KeyModifiers result = 0; result |= (mod & Keymod.ALT) != 0 ? KeyModifiers.Alt : 0; result |= (mod & Keymod.CTRL) != 0 ? KeyModifiers.Control : 0; result |= (mod & Keymod.SHIFT) != 0 ? KeyModifiers.Shift : 0; return result; }
public static extern void SDL_SetModState(Keymod modstate);