Add special button to gamepad mapping and rename to reflect that it's a map of the standard HTML5 button layout, not anything XInput-specific

This commit is contained in:
Cameron Gutman 2016-02-16 15:49:59 -05:00
parent fe0120ca16
commit 5577587718

View File

@ -4,16 +4,17 @@
#include <Limelight.h> #include <Limelight.h>
static const unsigned short k_XInputButtonMapping[] = { static const unsigned short k_StandardGamepadButtonMapping[] = {
A_FLAG, B_FLAG, X_FLAG, Y_FLAG, A_FLAG, B_FLAG, X_FLAG, Y_FLAG,
LB_FLAG, RB_FLAG, LB_FLAG, RB_FLAG,
0, 0, // Triggers 0, 0, // Triggers
BACK_FLAG, PLAY_FLAG, BACK_FLAG, PLAY_FLAG,
LS_CLK_FLAG, RS_CLK_FLAG, LS_CLK_FLAG, RS_CLK_FLAG,
UP_FLAG, DOWN_FLAG, LEFT_FLAG, RIGHT_FLAG UP_FLAG, DOWN_FLAG, LEFT_FLAG, RIGHT_FLAG,
SPECIAL_FLAG
}; };
static const unsigned int k_XInputTriggerButtonIndexes[] = { static const unsigned int k_StandardGamepadTriggerButtonIndexes[] = {
6, 7 6, 7
}; };
@ -44,21 +45,21 @@ void MoonlightInstance::PollGamepads() {
// Handle buttons and triggers // Handle buttons and triggers
for (unsigned int i = 0; i < padData.buttons_length; i++) { for (unsigned int i = 0; i < padData.buttons_length; i++) {
if (i >= sizeof(k_XInputButtonMapping) / sizeof(k_XInputButtonMapping[0])) { if (i >= sizeof(k_StandardGamepadButtonMapping) / sizeof(k_StandardGamepadButtonMapping[0])) {
// Ignore unmapped buttons // Ignore unmapped buttons
break; break;
} }
// Handle triggers first // Handle triggers first
if (i == k_XInputTriggerButtonIndexes[0]) { if (i == k_StandardGamepadTriggerButtonIndexes[0]) {
leftTrigger = padData.buttons[i] * 0xFF; leftTrigger = padData.buttons[i] * 0xFF;
} }
else if (i == k_XInputTriggerButtonIndexes[1]) { else if (i == k_StandardGamepadTriggerButtonIndexes[1]) {
rightTrigger = padData.buttons[i] * 0xFF; rightTrigger = padData.buttons[i] * 0xFF;
} }
// Now normal buttons // Now normal buttons
else if (padData.buttons[i] > 0.5f) { else if (padData.buttons[i] > 0.5f) {
buttonFlags |= k_XInputButtonMapping[i]; buttonFlags |= k_StandardGamepadButtonMapping[i];
} }
} }