void iKeyboardHandler.keyEvent(eKey key, eKeyValue what, ushort unicodeChar, eKeyboardState ks) { // Console.WriteLine( "iKeyboardHandler.keyEvent: {0} {1} {2:x} {3}", key, what, unicodeChar, ks ); if (what != eKeyValue.Pressed) { return; } if (context.renderContext is iDiligentWindow window) { if (handleWindowedModeHotkey(window, key, ks)) { return; } } if (key == eKey.P) { screenshot(); return; } if (context.scene is iKeyPressedHandler hh) { hh.keyPressed(key, ks); } }
protected override void handleKey(eKey key, eKeyValue keyValue) { layout.updateState(key, keyValue); char c = layout.keyChar(key); handler.keyEvent(key, keyValue, c, layout.state); }
void updateState(eKeyboardState bit, eKeyValue keyValue) { switch (keyValue) { case eKeyValue.Pressed: state |= bit; return; case eKeyValue.Released: state &= ~bit; return; } }
void iKeyboardHandler.keyEvent(eKey key, eKeyValue what, ushort unicodeChar, eKeyboardState ks) { if (0 == unicodeChar) { Console.WriteLine("keyEvent: {0} {1} {2}", key, what, ks); } else if (key == 0) { Console.WriteLine("keyEvent: {0} {1} {2}", printKey((char)unicodeChar), what, ks); } else { Console.WriteLine("keyEvent: {0} ({1}) {2} {3}", printKey((char)unicodeChar), key, what, ks); } }
protected override void handleKey(eKey key, eKeyValue keyValue) { layout.updateState(key, keyValue); char c = layout.keyChar(key); if (0 != c) { Console.WriteLine("KeyChar: {0} {1} {2} {3}", charString(c), key, keyValue, time); } else { Console.WriteLine("Key: {0} {1} {2}", key, keyValue, time); } }
protected override void handleButton(eButton button, eKeyValue keyValue) { if (buttonsMap.TryGetValue(button, out var res)) { switch (keyValue) { case eKeyValue.Pressed: setStateBit(res); handler.buttonDown(position.x, position.y, res, buttonsState); break; case eKeyValue.Released: clearStateBit(res); handler.buttonUp(position.x, position.y, res, buttonsState); break; } } }
bool handleKeyOrButton(ushort code, int value) { if (value < 0 || value > 0xFF) { return(true); } eKeyValue keyValue = (eKeyValue)(byte)value; if (Enum.IsDefined(typeof(eKey), code)) { handleKey((eKey)code, keyValue); } else if (Enum.IsDefined(typeof(eButton), code)) { handleButton((eButton)code, keyValue); } return(true); }
void iKeyboardLayout.updateState(eKey key, eKeyValue val) { switch (key) { case eKey.LeftShift: case eKey.RightShift: updateState(eKeyboardState.ShiftDown, val); return; case eKey.LeftCtrl: case eKey.RightCtrl: updateState(eKeyboardState.ControlDown, val); return; case eKey.LeftAlt: case eKey.RightAlt: updateState(eKeyboardState.AltDown, val); return; } }
protected override void handleButton(eButton button, eKeyValue keyValue) { Console.WriteLine("Button: {0} {1} {2}", button, keyValue, time); }
protected override void handleKey(eKey key, eKeyValue keyValue) { Console.WriteLine("Key: {0} {1} {2}", key, keyValue, time); }
/// <summary>Handle EV_KEY events where the key symbolic name starts with "BTN_"</summary> protected virtual void handleButton(eButton button, eKeyValue keyValue) { }
/// <summary>Handle EV_KEY events where the key symbolic name starts with "KEY_"</summary> protected virtual void handleKey(eKey key, eKeyValue keyValue) { }