Index: content/browser/gamepad/gamepad_standard_mappings_mac.mm |
diff --git a/content/browser/gamepad/gamepad_standard_mappings_mac.mm b/content/browser/gamepad/gamepad_standard_mappings_mac.mm |
index 2c471a248f1f42eb6c880034d4b2d0e86004a2d2..6ca2d5b470cdd613439445e5273a6a59a9cfe339 100644 |
--- a/content/browser/gamepad/gamepad_standard_mappings_mac.mm |
+++ b/content/browser/gamepad/gamepad_standard_mappings_mac.mm |
@@ -14,6 +14,25 @@ float AxisToButton(float input) { |
return (input + 1.f) / 2.f; |
} |
+void DpadFromAxis(WebKit::WebGamepad* mapped, float dir) { |
+ // Dpad is mapped as a direction on one axis, where -1 is up and it |
+ // increases clockwise to 1, which is up + left. It's set to a large (> 1.f) |
+ // number when nothing is depressed, except on start up, sometimes it's 0.0 |
+ // for no data, rather than the large number. |
+ if (dir == 0.0f) { |
+ mapped->buttons[kButtonDpadUp] = 0.f; |
+ mapped->buttons[kButtonDpadDown] = 0.f; |
+ mapped->buttons[kButtonDpadLeft] = 0.f; |
+ mapped->buttons[kButtonDpadRight] = 0.f; |
+ } else { |
+ mapped->buttons[kButtonDpadUp] = (dir >= -1.f && dir < -0.7f) || |
+ (dir >= .95f && dir <= 1.f); |
+ mapped->buttons[kButtonDpadRight] = dir >= -.75f && dir < -.1f; |
+ mapped->buttons[kButtonDpadDown] = dir >= -.2f && dir < .45f; |
+ mapped->buttons[kButtonDpadLeft] = dir >= .4f && dir <= 1.f; |
+ } |
+} |
+ |
void MapperXbox360Gamepad( |
const WebKit::WebGamepad& input, |
WebKit::WebGamepad* mapped) { |
@@ -70,25 +89,7 @@ void MapperDirectInputStyle( |
mapped->buttons[kButtonSecondary] = input.buttons[2]; |
mapped->buttons[kButtonTertiary] = input.buttons[0]; |
mapped->axes[kAxisRightStickY] = input.axes[5]; |
- |
- // Dpad is mapped as a direction on one axis, where -1 is up and it |
- // increases clockwise to 1, which is up + left. It's set to a large (> 1.f) |
- // number when nothing is depressed, except on start up, sometimes it's 0.0 |
- // for no data, rather than the large number. |
- float dir = input.axes[9]; |
- if (dir == 0.0f) { |
- mapped->buttons[kButtonDpadUp] = 0.f; |
- mapped->buttons[kButtonDpadDown] = 0.f; |
- mapped->buttons[kButtonDpadLeft] = 0.f; |
- mapped->buttons[kButtonDpadRight] = 0.f; |
- } else { |
- mapped->buttons[kButtonDpadUp] = (dir >= -1.f && dir < -0.7f) || |
- (dir >= .95f && dir <= 1.f); |
- mapped->buttons[kButtonDpadRight] = dir >= -.75f && dir < -.1f; |
- mapped->buttons[kButtonDpadDown] = dir >= -.2f && dir < .45f; |
- mapped->buttons[kButtonDpadLeft] = dir >= .4f && dir <= 1.f; |
- } |
- |
+ DpadFromAxis(mapped, input.axes[9]); |
mapped->buttonsLength = kNumButtons - 1; /* no meta */ |
mapped->axesLength = kNumAxes; |
} |
@@ -133,6 +134,24 @@ void MapperMacallyIShock( |
mapped->axesLength = kNumAxes; |
} |
+void MapperXGEAR( |
+ const WebKit::WebGamepad& input, |
+ WebKit::WebGamepad* mapped) { |
+ *mapped = input; |
+ mapped->buttons[kButtonPrimary] = input.buttons[2]; |
+ mapped->buttons[kButtonTertiary] = input.buttons[3]; |
+ mapped->buttons[kButtonQuaternary] = input.buttons[0]; |
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[6]; |
+ mapped->buttons[kButtonRightShoulder] = input.buttons[7]; |
+ mapped->buttons[kButtonLeftTrigger] = input.buttons[4]; |
+ mapped->buttons[kButtonRightTrigger] = input.buttons[5]; |
+ DpadFromAxis(mapped, input.axes[9]); |
+ mapped->axes[kAxisRightStickX] = input.axes[5]; |
+ mapped->axes[kAxisRightStickY] = input.axes[2]; |
+ mapped->buttonsLength = kNumButtons - 1; /* no meta */ |
+ mapped->axesLength = kNumAxes; |
+} |
+ |
struct MappingData { |
const char* const vendor_id; |
const char* const product_id; |
@@ -145,6 +164,7 @@ struct MappingData { |
{ "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode |
{ "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode |
{ "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS |
+ { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller |
{ "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode |
{ "2222", "4010", MapperMacallyIShock }, // Macally iShock |
}; |