Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: device/gamepad/gamepad_standard_mappings.cc

Issue 2150173002: Added Touched attribute to GamepadButton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually remove unnecessary test. Not sure what happened last time. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ppapi/shared_impl/ppb_gamepad_shared.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/gamepad/gamepad_standard_mappings.cc
diff --git a/device/gamepad/gamepad_standard_mappings.cc b/device/gamepad/gamepad_standard_mappings.cc
index d76d06dd9f273648fe5955b42719ad43fd958c88..e4aaf696716374c3d5710b0ee0bfe2eabf99d4ea 100644
--- a/device/gamepad/gamepad_standard_mappings.cc
+++ b/device/gamepad/gamepad_standard_mappings.cc
@@ -8,27 +8,33 @@ namespace device {
blink::WebGamepadButton AxisToButton(float input) {
float value = (input + 1.f) / 2.f;
- return blink::WebGamepadButton(value > kDefaultButtonPressedThreshold, value);
+ bool pressed = value > kDefaultButtonPressedThreshold;
+ bool touched = value > 0.0f;
+ return blink::WebGamepadButton(pressed, touched, value);
}
blink::WebGamepadButton AxisNegativeAsButton(float input) {
float value = (input < -0.5f) ? 1.f : 0.f;
- return blink::WebGamepadButton(value > kDefaultButtonPressedThreshold, value);
+ bool pressed = value > kDefaultButtonPressedThreshold;
+ bool touched = value > 0.0f;
+ return blink::WebGamepadButton(pressed, touched, value);
}
blink::WebGamepadButton AxisPositiveAsButton(float input) {
float value = (input > 0.5f) ? 1.f : 0.f;
- return blink::WebGamepadButton(value > kDefaultButtonPressedThreshold, value);
+ bool pressed = value > kDefaultButtonPressedThreshold;
+ bool touched = value > 0.0f;
+ return blink::WebGamepadButton(pressed, touched, value);
}
blink::WebGamepadButton ButtonFromButtonAndAxis(blink::WebGamepadButton button,
float axis) {
float value = (axis + 1.f) / 2.f;
- return blink::WebGamepadButton(button.pressed, value);
+ return blink::WebGamepadButton(button.pressed, button.touched, value);
}
blink::WebGamepadButton NullButton() {
- return blink::WebGamepadButton(false, 0.0);
+ return blink::WebGamepadButton(false, false, 0.0);
}
void DpadFromAxis(blink::WebGamepad* mapped, float dir) {
@@ -49,12 +55,16 @@ void DpadFromAxis(blink::WebGamepad* mapped, float dir) {
}
mapped->buttons[BUTTON_INDEX_DPAD_UP].pressed = up;
+ mapped->buttons[BUTTON_INDEX_DPAD_UP].touched = up;
mapped->buttons[BUTTON_INDEX_DPAD_UP].value = up ? 1.f : 0.f;
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT].pressed = right;
+ mapped->buttons[BUTTON_INDEX_DPAD_RIGHT].touched = right;
mapped->buttons[BUTTON_INDEX_DPAD_RIGHT].value = right ? 1.f : 0.f;
mapped->buttons[BUTTON_INDEX_DPAD_DOWN].pressed = down;
+ mapped->buttons[BUTTON_INDEX_DPAD_DOWN].touched = down;
mapped->buttons[BUTTON_INDEX_DPAD_DOWN].value = down ? 1.f : 0.f;
mapped->buttons[BUTTON_INDEX_DPAD_LEFT].pressed = left;
+ mapped->buttons[BUTTON_INDEX_DPAD_LEFT].touched = left;
mapped->buttons[BUTTON_INDEX_DPAD_LEFT].value = left ? 1.f : 0.f;
}
« no previous file with comments | « no previous file | ppapi/shared_impl/ppb_gamepad_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698