public override void OnInputKey(SInputEvent arg) { if (_earthquake == null) { return; } if (arg.KeyDown(EKeyId.eKI_W)) { _earthquake.Position += Vec3.Right * 4f * FrameTime.Delta; } if (arg.KeyDown(EKeyId.eKI_S)) { _earthquake.Position += -Vec3.Right * 4f * FrameTime.Delta; } if (arg.KeyDown(EKeyId.eKI_A)) { if (_earthquake.MinAmplitude > 0.5f) { _earthquake.MinAmplitude -= 0.5f; _earthquake.MaxAmplitude -= 0.5f; } } if (arg.KeyDown(EKeyId.eKI_D)) { _earthquake.MinAmplitude += 0.5f; _earthquake.MaxAmplitude += 0.5f; } if (arg.KeyDown(EKeyId.eKI_Q)) { _earthquake.Radius -= 0.1f; _earthquake.Radius = MathExtensions.Clamp(_earthquake.Radius, 0.25f, _earthquake.Radius); } if (arg.KeyDown(EKeyId.eKI_E)) { _earthquake.Radius += 0.1f; } if (arg.KeyPressed(EKeyId.eKI_R)) { _earthquake.RandomOffset += 1f; } if (arg.KeyPressed(EKeyId.eKI_F)) { _earthquake.RandomOffset -= 1f; _earthquake.RandomOffset = MathExtensions.Clamp(_earthquake.RandomOffset, 0f, _earthquake.RandomOffset); } if (arg.KeyPressed(EKeyId.eKI_V)) { _earthquake.Visualize = !_earthquake.Visualize; } }
/// <summary> /// Called by CryEngine. Do not call directly. /// </summary> public override bool OnInputEvent(SInputEvent e) { if (e.deviceType == EInputDeviceType.eIDT_Keyboard) { if (e.state == EInputState.eIS_Down) { SInputEventExtentions.KeyDownLog [e.keyId] = true; } if (e.state == EInputState.eIS_Released) { SInputEventExtentions.KeyDownLog [e.keyId] = false; } if (e.KeyDown(EKeyId.eKI_LShift)) { _lShiftDown = true; } if (e.KeyUp(EKeyId.eKI_LShift)) { _lShiftDown = false; } if (e.KeyDown(EKeyId.eKI_RShift)) { _rShiftDown = true; } if (e.KeyUp(EKeyId.eKI_RShift)) { _rShiftDown = false; } // Preprocess keyName to contain valid Chars if (e.keyId == EKeyId.eKI_Space) { e.keyName.key = " "; } if (e.keyName.key.Length == 1) { if (ShiftDown) { e.keyName.key = e.keyName.key.ToUpper(); } if (ShiftDown && Char.IsDigit(e.keyName.key[0])) { e.keyName.key = "=!\"§$%&/()".Substring(e.keyName.key[0] - '0', 1); } } else { string res; e.keyName.key = _charByDescription.TryGetValue(e.keyName.key, out res) ? res : string.Empty; } if (OnKey != null) { OnKey(e); } } else if (e.deviceType == EInputDeviceType.eIDT_Gamepad) { // Set keyName.key = string.Empty to avoid showing up gamepad // presses controller keys in text input forms e.keyName.key = string.Empty; if (e.state == EInputState.eIS_Down) { SInputEventExtentions.KeyDownLog [e.keyId] = true; } if (e.state == EInputState.eIS_Released) { SInputEventExtentions.KeyDownLog [e.keyId] = false; } if (e.state == EInputState.eIS_Changed) { SInputEventExtentions.KeyInputValueLog [e.keyId] = e.value; } if (OnKey != null) { OnKey(e); } } return(false); }
/// <summary> /// Called by CryEngine. Do not call directly. /// </summary> public override bool OnInputEvent(SInputEvent e) { if (e.deviceType == EInputDeviceType.eIDT_Keyboard) { switch (e.state) { case EInputState.eIS_Down: SInputEventExtensions.KeyDownLog[e.keyId] = true; break; case EInputState.eIS_Released: SInputEventExtensions.KeyDownLog[e.keyId] = false; break; } if (e.KeyDown(EKeyId.eKI_LShift)) { _lShiftDown = true; } if (e.KeyUp(EKeyId.eKI_LShift)) { _lShiftDown = false; } if (e.KeyDown(EKeyId.eKI_RShift)) { _rShiftDown = true; } if (e.KeyUp(EKeyId.eKI_RShift)) { _rShiftDown = false; } // Preprocess keyName to contain valid Chars if (e.keyId == EKeyId.eKI_Space) { e.keyName.key = " "; } if (e.keyName.key.Length == 1) { if (ShiftDown) { e.keyName.key = e.keyName.key.ToUpper(); } if (ShiftDown && Char.IsDigit(e.keyName.key[0])) { e.keyName.key = "=!\"§$%&/()".Substring(e.keyName.key[0] - '0', 1); } } else { string res; e.keyName.key = _charByDescription.TryGetValue(e.keyName.key, out res) ? res : string.Empty; } if (OnKey != null) { OnKey(e); } } else if (e.deviceType == EInputDeviceType.eIDT_Gamepad || e.deviceType == EInputDeviceType.eIDT_Mouse) { // Set keyName.key = string.Empty to avoid showing up gamepad // presses controller keys in text input forms e.keyName.key = string.Empty; switch (e.state) { case EInputState.eIS_Down: SInputEventExtensions.KeyDownLog[e.keyId] = true; break; case EInputState.eIS_Released: SInputEventExtensions.KeyDownLog[e.keyId] = false; break; case EInputState.eIS_Changed: SInputEventExtensions.KeyInputValueLog[e.keyId] = e.value; break; } if (OnKey != null) { OnKey(e); } } else if (e.deviceType == EInputDeviceType.eIDT_EyeTracker) { if (e.keyId == EKeyId.eKI_EyeTracker_X) { var axis = GetAxis("EyeTracker"); _axisByName["EyeTracker"] = new Vector2(e.value, axis != null ? axis.y : 0); } if (e.keyId == EKeyId.eKI_EyeTracker_Y) { var axis = GetAxis("EyeTracker"); _axisByName["EyeTracker"] = new Vector2(axis != null ? axis.x : 0, e.value); } } return(false); }