public virtual void HandleInputStateChange(InputStateChangeEvent inputStateChange) { // Set default var mouse = inputStateChange.State.Mouse; mouse.LastPosition = mouse.Position; mouse.LastScroll = mouse.Scroll; switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: HandleMousePositionChange(mousePositionChange); return; case MouseScrollChangeEvent mouseScrollChange: HandleMouseScrollChange(mouseScrollChange); return; case ButtonStateChangeEvent <MouseButton> mouseButtonStateChange: HandleMouseButtonStateChange(mouseButtonStateChange); return; case ButtonStateChangeEvent <Key> keyboardKeyStateChange: HandleKeyboardKeyStateChange(keyboardKeyStateChange); return; case ButtonStateChangeEvent <JoystickButton> joystickButtonStateChange: HandleJoystickButtonStateChange(joystickButtonStateChange); return; } }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: var mouse = mousePositionChange.State.Mouse; // confine cursor if (Host.Window != null && Host.Window.CursorState.HasFlag(CursorState.Confined)) { float scale = (Host.Window as DesktopWindow)?.Scale ?? 1f; mouse.Position = Vector2.Clamp(mouse.Position, Vector2.Zero, new Vector2(Host.Window.Width * scale, Host.Window.Height * scale)); } break; case ButtonStateChangeEvent <MouseButton> buttonChange: if (buttonChange.Kind == ButtonStateChangeKind.Pressed && Host.Window?.CursorInWindow == false) { return; } break; case MouseScrollChangeEvent _: if (Host.Window?.CursorInWindow == false) { return; } break; } base.HandleInputStateChange(inputStateChange); }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { if (inputStateChange is ReplayInputHandler.ReplayStateChangeEvent <KaraokeSaitenAction> { Input : ReplayInputHandler.ReplayState <KaraokeSaitenAction> replayState } replayStateChanged) { // Deal with replay event // Release event should be trigger first if (replayStateChanged.ReleasedActions.Any() && !replayState.PressedActions.Any()) { foreach (var action in replayStateChanged.ReleasedActions) { KeyBindingContainer.TriggerReleased(action); } } // If any key pressed, the continuous send press event if (replayState.PressedActions.Any()) { foreach (var action in replayState.PressedActions) { KeyBindingContainer.TriggerPressed(action); } } }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case ReplayStateChangeEvent <T> stateChangeEvent: foreach (var action in stateChangeEvent.ReleasedActions) { KeyBindingContainer.TriggerReleased(action); } foreach (var action in stateChangeEvent.PressedActions) { KeyBindingContainer.TriggerPressed(action); } break; case ReplayStatisticsFrameEvent statisticsStateChangeEvent: scoreProcessor?.ResetFromReplayFrame(statisticsStateChangeEvent.Frame); break; default: base.HandleInputStateChange(inputStateChange); break; } }
public virtual void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: HandleMousePositionChange(mousePositionChange); return; case MouseScrollChangeEvent mouseScrollChange: HandleMouseScrollChange(mouseScrollChange); return; case ButtonStateChangeEvent <MouseButton> mouseButtonStateChange: HandleMouseButtonStateChange(mouseButtonStateChange); return; case ButtonStateChangeEvent <Key> keyboardKeyStateChange: HandleKeyboardKeyStateChange(keyboardKeyStateChange); return; case ButtonStateChangeEvent <JoystickButton> joystickButtonStateChange: HandleJoystickButtonStateChange(joystickButtonStateChange); return; } }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: var mouse = mousePositionChange.State.Mouse; // confine cursor if (Host.Window != null && Host.Window.CursorState.HasFlag(CursorState.Confined)) { var clientSize = Host.Window.ClientSize; mouse.Position = Vector2.Clamp(mouse.Position, Vector2.Zero, new Vector2(clientSize.Width, clientSize.Height)); } break; case ButtonStateChangeEvent <MouseButton> buttonChange: if (buttonChange.Kind == ButtonStateChangeKind.Pressed && Host.Window?.CursorInWindow == false) { return; } break; case MouseScrollChangeEvent _: if (Host.Window?.CursorInWindow == false) { return; } break; } base.HandleInputStateChange(inputStateChange); }
public virtual void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: HandleMousePositionChange(mousePositionChange); return; case MouseScrollChangeEvent mouseScrollChange: HandleMouseScrollChange(mouseScrollChange); return; case ButtonStateChangeEvent <MouseButton> mouseButtonStateChange: HandleMouseButtonStateChange(mouseButtonStateChange); return; case ButtonStateChangeEvent <Key> keyboardKeyStateChange: HandleKeyboardKeyStateChange(keyboardKeyStateChange); return; case TouchStateChangeEvent touchChange: var manager = GetButtonEventManagerFor(touchChange.Touch.Source); bool touchWasHandled = manager.HeldDrawable != null; HandleTouchStateChange(touchChange); bool touchIsHandled = manager.HeldDrawable != null; // Produce mouse input if no drawable in the input queue has handled this touch event. // Done for compatibility with components that do not handle touch input directly. if (!touchWasHandled && !touchIsHandled) { HandleMouseTouchStateChange(touchChange); } return; case ButtonStateChangeEvent <TabletPenButton> tabletPenButtonStateChange: HandleTabletPenButtonStateChange(tabletPenButtonStateChange); return; case ButtonStateChangeEvent <TabletAuxiliaryButton> tabletAuxiliaryButtonStateChange: HandleTabletAuxiliaryButtonStateChange(tabletAuxiliaryButtonStateChange); return; case ButtonStateChangeEvent <JoystickButton> joystickButtonStateChange: HandleJoystickButtonStateChange(joystickButtonStateChange); return; case JoystickAxisChangeEvent joystickAxisChangeEvent: HandleJoystickAxisChange(joystickAxisChangeEvent); return; case ButtonStateChangeEvent <MidiKey> midiKeyStateChange: HandleMidiKeyStateChange(midiKeyStateChange); return; } }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MicrophoneVoiceChangeEvent microphoneVoiceChange: HandleMicrophoneStateChange(microphoneVoiceChange); break; } base.HandleInputStateChange(inputStateChange); }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: var mouse = mousePositionChange.State.Mouse; // confine cursor if (Host.Window != null) { RectangleF?cursorConfineRect = null; var clientSize = Host.Window.ClientSize; var windowRect = new RectangleF(0, 0, clientSize.Width, clientSize.Height); if (Host.Window.CursorState.HasFlagFast(CursorState.Confined)) { cursorConfineRect = Host.Window.CursorConfineRect ?? windowRect; } else if (mouseOutsideAllDisplays(mouse.Position)) { // Implicitly confine the cursor to prevent a feedback loop of MouseHandler warping the cursor to an invalid position // and the OS immediately warping it back inside a display. // Window.CursorConfineRect is not used here as that should only be used when confining is explicitly enabled. cursorConfineRect = windowRect; } if (cursorConfineRect.HasValue) { mouse.Position = Vector2.Clamp(mouse.Position, cursorConfineRect.Value.Location, cursorConfineRect.Value.Location + cursorConfineRect.Value.Size - Vector2.One); } } break; case ButtonStateChangeEvent <MouseButton> buttonChange: if (buttonChange.Kind == ButtonStateChangeKind.Pressed && Host.Window?.CursorInWindow.Value == false) { return; } break; case MouseScrollChangeEvent _: if (Host.Window?.CursorInWindow.Value == false) { return; } break; } base.HandleInputStateChange(inputStateChange); }
public virtual void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: HandleMousePositionChange(mousePositionChange); return; case MouseScrollChangeEvent mouseScrollChange: HandleMouseScrollChange(mouseScrollChange); return; case ButtonStateChangeEvent <MouseButton> mouseButtonStateChange: HandleMouseButtonStateChange(mouseButtonStateChange); return; case ButtonStateChangeEvent <Key> keyboardKeyStateChange: HandleKeyboardKeyStateChange(keyboardKeyStateChange); return; case TouchStateChangeEvent touchChange: HandleTouchStateChange(touchChange); // primary touch mapped to mouse. if (touchChange.Touch.Source == TouchSource.Touch1) { new MousePositionAbsoluteInput { Position = touchChange.Touch.Position }.Apply(CurrentState, this); new MouseButtonInput(MouseButton.Left, touchChange.State.Touch.IsActive(touchChange.Touch.Source)).Apply(CurrentState, this); } return; case ButtonStateChangeEvent <JoystickButton> joystickButtonStateChange: HandleJoystickButtonStateChange(joystickButtonStateChange); return; case JoystickAxisChangeEvent joystickAxisChangeEvent: HandleJoystickAxisChange(joystickAxisChangeEvent); return; case ButtonStateChangeEvent <MidiKey> midiKeyStateChange: HandleMidiKeyStateChange(midiKeyStateChange); return; } }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { if (inputStateChange is ReplayStateChangeEvent <T> replayStateChanged) { foreach (var action in replayStateChanged.ReleasedActions) { KeyBindingContainer.TriggerReleased(action); } foreach (var action in replayStateChanged.PressedActions) { KeyBindingContainer.TriggerPressed(action); } } else { base.HandleInputStateChange(inputStateChange); } }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: var mouse = mousePositionChange.State.Mouse; // confine cursor if (Host.Window != null && Host.Window.CursorState.HasFlag(CursorState.Confined)) { mouse.Position = Vector2.Clamp(mouse.Position, Vector2.Zero, new Vector2(Host.Window.Width, Host.Window.Height)); } break; case MouseScrollChangeEvent _: if (Host.Window != null && !Host.Window.CursorInWindow) { return; } break; } base.HandleInputStateChange(inputStateChange); }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { switch (inputStateChange) { case MousePositionChangeEvent mousePositionChange: var mouse = mousePositionChange.State.Mouse; // confine cursor if (Host.Window != null && Host.Window.CursorState.HasFlagFast(CursorState.Confined)) { var clientSize = Host.Window.ClientSize; var cursorConfineRect = Host.Window.CursorConfineRect ?? new RectangleF(0, 0, clientSize.Width, clientSize.Height); mouse.Position = Vector2.Clamp(mouse.Position, cursorConfineRect.Location, cursorConfineRect.Location + cursorConfineRect.Size - Vector2.One); } break; case ButtonStateChangeEvent <MouseButton> buttonChange: if (buttonChange.Kind == ButtonStateChangeKind.Pressed && Host.Window?.CursorInWindow.Value == false) { return; } break; case MouseScrollChangeEvent _: if (Host.Window?.CursorInWindow.Value == false) { return; } break; } base.HandleInputStateChange(inputStateChange); }
public void HandleInputStateChange(InputStateChangeEvent inputStateChange) { }
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange) { if (inputStateChange is ReplayInputHandler.ReplayStateChangeEvent <KaraokeSaitenAction> replayStateChanged && replayStateChanged.Input is ReplayInputHandler.ReplayState <KaraokeSaitenAction> replayState) { // Deal with replay event // Release event should be trigger first if (replayStateChanged.ReleasedActions.Any() && !replayState.PressedActions.Any()) { foreach (var action in replayStateChanged.ReleasedActions) { KeyBindingContainer.TriggerReleased(action); } } // If any key pressed, the continuous send press event if (replayState.PressedActions.Any()) { foreach (var action in replayState.PressedActions) { KeyBindingContainer.TriggerPressed(action); } } } else if (inputStateChange is MicrophoneSoundChangeEvent microphoneSoundChange) { // Deal with realtime microphone event var inputState = microphoneSoundChange.State as IMicrophoneInputState; var lastState = microphoneSoundChange.LastState; var state = inputState?.Microphone; if (state == null) { throw new ArgumentNullException($"{nameof(state)} cannot be null."); } // Convert beatmap's pitch to scale setting. var scale = beatmap.PitchToScale(state.HasSound ? state.Pitch : lastState.Pitch); // TODO : adjust scale by scale += 5; var action = new KaraokeSaitenAction { Scale = scale }; if (lastState.HasSound && !state.HasSound) { KeyBindingContainer.TriggerReleased(action); } else { KeyBindingContainer.TriggerPressed(action); } } else { // Basically should not goes to here base.HandleInputStateChange(inputStateChange); } }