public void Process() { // If the pointer is inactive, make sure it is exited if necessary. if (!IsPointerActiveAndAvailable()) { TryExitPointer(); } // Save the previous Game Object GameObject previousObject = GetCurrentGameObject(); //if (mFindKeyCodeButton && Time.unscaledTime - mTimeKeyCodeDown > 0.8f) //{ // mFindKeyCodeButton = false; //} //if(!mFindKeyCodeButton) CastRay(); UpdateCurrentObject(previousObject); UpdatePointer(previousObject); // True during the frame that the trigger has been pressed. bool triggerDown = false; // True if the trigger is held down. bool triggering = false; if (IsPointerActiveAndAvailable()) { triggerDown = Pointer.TriggerDown; triggering = Pointer.Triggering; } bool handlePendingClickRequired = !triggering; // Handle input if (!triggerDown && triggering) { HandleDrag(); } else if (triggerDown && !CurrentEventData.eligibleForClick) { // New trigger action. HandleTriggerDown(); mTimeKeyCodeDown = Time.unscaledTime; //#if SVR_KEYBOARD // mFindKeyCodeButton = CurrentEventData.pointerCurrentRaycast.gameObject != null // && (CurrentEventData.pointerCurrentRaycast.gameObject.GetComponentInParent<IVRCommon.Keyboard.Widet.KeyCodeButton>() != null // || CurrentEventData.pointerCurrentRaycast.gameObject.GetComponent<IVRCommon.Keyboard.Widet.KeyCodeButton>() != null); //#endif } else if (handlePendingClickRequired) { //mFindKeyCodeButton = false; // Check if there is a pending click to handle. HandlePendingClick(); } ScrollInput.HandleScroll(GetCurrentGameObject(), CurrentEventData, Pointer, EventExecutor); }
public void ReceiveScrollInput(ScrollInput input) { switch (input) { case (ScrollInput.LEFT): cellScrollOffsetX--; break; case (ScrollInput.RIGHT): cellScrollOffsetX++; break; case (ScrollInput.UP): cellScrollOffsetY++; break; case (ScrollInput.DOWN): cellScrollOffsetY--; break; } }
private AnalogEventHandler ScrollEventHandler(ScrollInput input, KeyBindings keyBindings, Mouse mouse) { return((stateX, stateY, previousStateX, previousStateY) => { var speed = mouse.GetCursorSpeed(stateY, Gamepad.MinAnalogLimit, Gamepad.MinAnalogDeadzone, Gamepad.MaxAnalogLimit, Gamepad.MaxAnalogDeadzone) * keyBindings.Current.ScrollSpeedMultiplier; speed = input.InvertY ? -speed : speed; if (speed != 0) { mouse.Scroll((UInt32)speed); } }); }
public void Process() { // If the pointer is inactive, make sure it is exited if necessary. if (!IsPointerActiveAndAvailable()) { TryExitPointer(); } // Save the previous Game Object GameObject previousObject = GetCurrentGameObject(); CastRay(); UpdateCurrentObject(previousObject); UpdatePointer(previousObject); // True during the frame that the trigger has been pressed. bool triggerDown = false; // True if the trigger is held down. bool triggering = false; if (IsPointerActiveAndAvailable()) { triggerDown = Pointer.TriggerDown; triggering = Pointer.Triggering; } bool handlePendingClickRequired = !triggering; // Handle input if (!triggerDown && triggering) { HandleDrag(); } else if (triggerDown && !CurrentEventData.eligibleForClick) { // New trigger action. HandleTriggerDown(); } else if (handlePendingClickRequired) { // Check if there is a pending click to handle. HandlePendingClick(); } ScrollInput.HandleScroll(GetCurrentGameObject(), CurrentEventData, Pointer, EventExecutor); }
private void SetPropertyValueAnalogInput(String propertyValue, Object configuration, PropertyInfo configurationProperty) { if (propertyValue == "Cursor") { var cursor = new CursorInput(); configurationProperty.SetValue(configuration, cursor); } else if (propertyValue == "Scroll") { var scroll = new ScrollInput(); configurationProperty.SetValue(configuration, scroll); } else if (propertyValue == "WASD") { var wasdKeys = new DirectionalKeysInput(KeyboardKeyCode.W, KeyboardKeyCode.S, KeyboardKeyCode.A, KeyboardKeyCode.D); configurationProperty.SetValue(configuration, wasdKeys); } else if (propertyValue == "ArrowKeys") { var arrowKeys = new DirectionalKeysInput(KeyboardKeyCode.UpArrow, KeyboardKeyCode.DownArrow, KeyboardKeyCode.LeftArrow, KeyboardKeyCode.RightArrow); configurationProperty.SetValue(configuration, arrowKeys); } }
public override void Load() { _sounds = Directory.GetFiles("Assets/SoundPlayer").Where(x => x.Contains(".wav")).Select(x => x.Replace("Assets/", "")).ToArray(); _uiController = new Controller(); CenterAnchor centerAnchor = new CenterAnchor(); _uiController.Add(centerAnchor); _controlButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_playButton), OnClick = () => { SoundLayer layer = Context.SoundManager.GetLayer("main"); if (layer == null) { return; } if (layer.Status == SoundStatus.Playing) { layer.Pause(); } else { layer.Resume(); } } }; centerAnchor.AddChild(_controlButton, new Rectangle(0, Context.Settings.RenderHeight / 2 - 36, 0, 0)); BasicButton loopButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_loopButton) }; loopButton.OnClick = () => { SoundLayer layer = Context.SoundManager.GetLayer("main"); if (layer == null) { return; } layer.Looping = !layer.Looping; loopButton.Tint = layer.Looping ? Color.Green : Color.White; }; centerAnchor.AddChild(loopButton, new Rectangle(-40, Context.Settings.RenderHeight / 2 - 36, 0, 0)); _soundBar = new ScrollInput(Vector3.Zero, new Vector2(Context.Settings.RenderWidth - 40, 10)) { KeepSelectorInside = true, SelectorRatio = 3 }; centerAnchor.AddChild(_soundBar, new Rectangle(0, Context.Settings.RenderHeight / 2 - 10, 0, 0)); _soundBarInfo = new BasicText(Context.AssetLoader.Get <Font>(_defaultFont), 13, "N/A", Color.White, Vector3.Zero); centerAnchor.AddChild(_soundBarInfo, new Rectangle(100, Context.Settings.RenderHeight / 2 - 30, 0, 0)); CornerAnchor cornerAnchor = new CornerAnchor(); _uiController.Add(cornerAnchor); for (int i = 0; i < _sounds.Length; i++) { int iCopy = i; ClickableLabel addSoundText = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _sounds[i], Color.White, Vector3.Zero) { OnClick = () => { if (_append) { Context.SoundManager.PlayQueue(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main"); } else { Context.SoundManager.Play(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main"); } } }; cornerAnchor.AddChild(addSoundText, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); } BasicButton appendButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_addButton) }; appendButton.OnClick = () => { _append = !_append; appendButton.Tint = _append ? Color.Green : Color.White; }; cornerAnchor.AddChild(appendButton, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); PlayerVolumeControl volumeControl = new PlayerVolumeControl(Vector3.Zero, new Vector2(100, 20)); cornerAnchor.AddChild(volumeControl, AnchorLocation.TopRight, new Rectangle(0, 20, 20, 0)); }
public void Process() { // If the pointer is inactive, make sure it is exited if necessary. if (!IsPointerActiveAndAvailable()) { TryExitPointer(); } // Save the previous Game Object GameObject previousObject = GetCurrentGameObject(); CastRay(); UpdateCurrentObject(previousObject); UpdatePointer(previousObject); // // True during the frame that the trigger has been pressed. // bool triggerDown = false; // // True if the trigger is held down. // bool triggering = false; if (IsPointerActiveAndAvailable()) { //triggerDown = Pointer.TriggerDown; //triggering = Pointer.Triggering; // triggering; // triggerDown; if (!CheckControllerDown() && CheckController()) { HandleDrag(); } else if (CheckControllerDown() && !CurrentEventData.eligibleForClick) { // New trigger action. HandleTriggerDown(); } else if (!CheckController()) { // Check if there is a pending click to handle. HandlePendingClick(); } // triggerDown = (Pointer.TriggerDown) ? (Pointer.TriggerDown) : (Input.anyKeyDown && Input.inputString.Equals(System.Environment.NewLine)) ? (Input.anyKeyDown && Input.inputString.Equals(System.Environment.NewLine)) : Input.GetButtonDown("Fire1") ? true : Input.GetMouseButtonDown(0); // // True if the trigger is held down. // //triggering = (Pointer.Triggering) ? (Pointer.Triggering) : (Input.anyKey && Input.inputString.Equals(System.Environment.NewLine)) ? (Input.anyKey && Input.inputString.Equals(System.Environment.NewLine)) : Input.GetButton("Fire1") ? true : Input.GetMouseButton(0); // // triggering = (Pointer.Triggering) ? (Pointer.Triggering) : Input.anyKey; // // } // if (SceneManager.GetActiveScene ().buildIndex == 2) { // GameManager.printte (triggerDown + "////" + triggering); // } // bool handlePendingClickRequired = !triggering; // // // Handle input // if (!triggerDown && triggering) { // HandleDrag(); // } else if (triggerDown && !CurrentEventData.eligibleForClick) { // // New trigger action. // HandleTriggerDown(); // } else if (handlePendingClickRequired) { // // Check if there is a pending click to handle. // HandlePendingClick(); // } } ScrollInput.HandleScroll(GetCurrentGameObject(), CurrentEventData, Pointer, EventExecutor); }