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

Analog button values from 0.0 to 1.0 #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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!

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 🙇🏼

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.

3 participants