Skip to content

Analog button values from 0.0 to 1.0#133

Closed
mbhatt627 wants to merge 1 commit intoWebPlatformForEmbedded:masterfrom
mbhatt627:BtnValue
Closed

Analog button values from 0.0 to 1.0#133
mbhatt627 wants to merge 1 commit intoWebPlatformForEmbedded:masterfrom
mbhatt627:BtnValue

Conversation

@mbhatt627
Copy link

Analog button should have values from 0.0 to 1.0 instead of only digital value.

https://www.w3.org/TR/gamepad/#dom-gamepadbutton-value

value attribute
For buttons that have an analog sensor, this property MUST represent the amount which the button has been pressed. All button values MUST be linearly normalized to the range [0.0 .. 1.0]. 0.0 MUST mean fully unpressed, and 1.0 MUST mean fully pressed. For buttons without an analog sensor, only the values 0.0 and 1.0 for fully unpressed and fully pressed respectively, MUST be provided.

Copy link
Contributor

@aperezdc aperezdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch looks good and does the correct thing of adding a new function pointer to the interface to avoid breaking the ABI. I have only a couple of very minor comments and after addressing those we would be happy to merge these changes. Thanks!


/*< private >*/
void (*_wpe_reserved1)(void);
void (*analog_button_changed)(void*, enum wpe_gamepad_button, double);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move analog_button_changed to line 143, right below axis_changed, and renumber the _wpe_reservedX so they start with 1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be possible to reuse button_changed for both kinds of buttons value, using double instead of boolean, without breaking the back compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we cannot change the types of parameters or the number of parameters, because that would break both the ABI and the API. Adding a new function is fine, as done in this patch.

* Method called by application (gamepad implementator). It reports to
* WPEWebkit a change in the value of analog @button.
*
* Since: 1.15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 1.15 will be a development one, the first stable version to include this will be 1.16.0 so it's better to write 1.16 here.

@aperezdc
Copy link
Contributor

@mbhatt627 Could you update the PR taking into account the suggestions? Thanks in advance 🙇🏼

ganeshprasads added a commit to ganeshprasads/WPEWebKit that referenced this pull request Dec 12, 2024
This PR dependent on libWPE changes for getting Gamepad button values from 0.0 to 1.0.
WebPlatformForEmbedded/libwpe#133

https://www.w3.org/TR/gamepad/#dom-gamepadbutton-value

value attribute:
For buttons that have an analog sensor, this property MUST represent the amount which the button has been pressed. All button values MUST be linearly normalized to the range [0.0 .. 1.0]. 0.0 MUST mean fully unpressed, and 1.0 MUST mean fully pressed. For buttons without an analog sensor, only the values 0.0 and 1.0 for fully unpressed and fully pressed respectively, MUST be provided.

Original Author: manoj_bhatta@comcast.com
See: WebPlatformForEmbedded#1410
@magomez magomez closed this Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants