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

Implement amplitude parameter to Input.vibrate_handheld #9582

Closed
skysphr opened this issue Apr 23, 2024 · 1 comment · Fixed by godotengine/godot#91143
Closed

Implement amplitude parameter to Input.vibrate_handheld #9582

skysphr opened this issue Apr 23, 2024 · 1 comment · Fixed by godotengine/godot#91143

Comments

@skysphr
Copy link

skysphr commented Apr 23, 2024

Describe the project you are working on

An Android application which implements a vibration feature.

Describe the problem or limitation you are having in your project

On Android, Input.vibrate_handheld uses DEFAULT_AMPLITUDE to vibrate, which can be very strong.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

An additional parameter to Input.vibrate_handheld could be added so that amplitude is also controllable. As per the documentation, createOneShot, which Godot uses to implement vibrate_handheld, accepts two parameters, a duration in milliseconds and an integer amplitude between 1 and 255, of which only the duration is currently exposed. DEFAULT_AMPLITUDE (currently used by Godot) is defined as -1 in the spec.

On IOS, I believe a parameter called HapticIntensity can be added to the HapticPattern used by Godot. Possible values range from 0 to 1 as per this document, which I consider more elegant than Android's 8 bit range, and could be used by Godot as well.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The function would be called like this: Input.vibrate_handheld(int duration_ms=500, float amplitude=1.0).

If this enhancement will not be used often, can it be worked around with a few lines of script?

No. The only workaround is building a separate plugin with the included functionality.

Is there a reason why this should be core and not an add-on in the asset library?

Everything is already pretty much there, the function only misses an additional parameter.

@Calinou
Copy link
Member

Calinou commented Apr 24, 2024

Feel free to open a pull request for this (for both iOS and Android) 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants