Commit 6f1623ce authored by Andrew Walbran's avatar Andrew Walbran Committed by Commit Bot

[gamepad] Use threshold for pressed buttons on Android.

This matches the threshold applied on other platforms in ValueToButton.
Also set the touched state for all non-zero values, and fix a typo in
the comments.

BUG=1073130

Change-Id: Ied8db827b098c95b6a697f1df8a940de1a501166
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245484Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
Cr-Commit-Position: refs/heads/master@{#781281}
parent 78c68989
......@@ -121,15 +121,17 @@ static void JNI_GamepadList_SetGamepadData(
std::vector<float> buttons;
base::android::JavaFloatArrayToFloatVector(env, jbuttons, &buttons);
// Set Gamepad buttonslength to total number of axes on the gamepad
// device. Only return the first buttonsLengthCap if axeslength captured by
// Set Gamepad buttonslength to total number of buttons on the gamepad
// device. Only return the first buttonsLengthCap if buttonslength captured by
// GamepadList is larger than buttonsLengthCap.
pad.buttons_length = std::min(static_cast<int>(buttons.size()),
static_cast<int>(Gamepad::kButtonsLengthCap));
// Copy buttons state to the Gamepad buttons[].
for (unsigned int j = 0; j < pad.buttons_length; j++) {
pad.buttons[j].pressed = buttons[j];
pad.buttons[j].pressed =
buttons[j] > GamepadButton::kDefaultButtonPressedThreshold;
pad.buttons[j].touched = buttons[j] > 0.0f;
pad.buttons[j].value = buttons[j];
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment