Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gamepad: move the cursor continuously while holding the right stick. #262

Closed
wants to merge 3 commits into from
Closed

Conversation

js-john
Copy link
Contributor

@js-john js-john commented Apr 13, 2020

Thank you very much, I learned a lot from your refactored code!
But there is a problem: if timer is removed, the cursor will only move when the x or y values of the right stick changed. This means when you hold the right stick, the cursor will not move.
I want to add the timer back. Is that OK?

@osy osy added this to the v1.0 RC1 milestone Apr 13, 2020
@osy
Copy link
Contributor

osy commented Apr 13, 2020

I tend to try to avoid any timers as recommended by Apple: https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/MinimizeTimerUse.html

Since VMCursor is a UIDynamicItem I think the best way is to use startMovement when thumbstick moves. Then use a UIDynamicAnimator to set a velocity (with 0 friction) based on how far the thumbstick is from the center. I can attempt this later if I have time or you can try it.

For scrolling, we can make a new UIDynamicItem to track it and share the same logic.

@js-john
Copy link
Contributor Author

js-john commented Apr 15, 2020

I tend to try to avoid any timers as recommended by Apple: https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/MinimizeTimerUse.html

Since VMCursor is a UIDynamicItem I think the best way is to use startMovement when thumbstick moves. Then use a UIDynamicAnimator to set a velocity (with 0 friction) based on how far the thumbstick is from the center. I can attempt this later if I have time or you can try it.

For scrolling, we can make a new UIDynamicItem to track it and share the same logic.

ok, I am working on this.

@osy osy closed this in 8420341 Apr 17, 2020
osy pushed a commit that referenced this pull request Apr 17, 2020
@js-john js-john deleted the gamepad branch November 1, 2021 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants