summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/java_library_common.mk17
-rw-r--r--android_webview/libwebviewchromium.gypi1
-rw-r--r--build/config/android/rules.gni4
-rwxr-xr-xbuild/get_landmines.py1
-rw-r--r--content/browser/android/content_view_core_impl.cc47
-rw-r--r--content/browser/android/gesture_event_type.h27
-rw-r--r--content/browser/android/gesture_event_type_list.h33
-rw-r--r--content/browser/android/popup_item_type_list.h23
-rw-r--r--content/browser/gamepad/canonical_axis_index_list.h16
-rw-r--r--content/browser/gamepad/canonical_button_index_list.h28
-rw-r--r--content/browser/gamepad/gamepad_standard_mappings.cc16
-rw-r--r--content/browser/gamepad/gamepad_standard_mappings.h52
-rw-r--r--content/browser/gamepad/gamepad_standard_mappings_linux.cc338
-rw-r--r--content/browser/gamepad/gamepad_standard_mappings_mac.mm396
-rw-r--r--content/browser/gamepad/gamepad_standard_mappings_win.cc183
-rw-r--r--content/browser/renderer_host/input/selection_event_type.h17
-rw-r--r--content/browser/renderer_host/input/selection_event_type_list.h23
-rw-r--r--content/child/assert_matching_enums.cc18
-rw-r--r--content/content.gyp80
-rw-r--r--content/public/android/BUILD.gn105
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/GestureEventType.template13
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java21
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/SpeechRecognitionError.template11
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/GamepadDevice.java4
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/GamepadMappings.java62
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/input/SelectionEventType.template13
-rw-r--r--content/public/android/java/src/org/chromium/content/common/ResultCodes.template13
-rw-r--r--content/public/android/java/src/org/chromium/content/common/TopControlsState.template12
-rw-r--r--content/public/common/result_codes.h25
-rw-r--r--content/public/common/result_codes_list.h30
-rw-r--r--content/public/common/screen_orientation_values.h14
-rw-r--r--content/public/common/screen_orientation_values_list.h24
-rw-r--r--content/public/common/speech_recognition_error.h30
-rw-r--r--content/public/common/speech_recognition_error_list.h38
-rw-r--r--content/public/common/top_controls_state.h8
-rw-r--r--content/public/common/top_controls_state_list.h19
-rw-r--r--content/renderer/render_view_impl_android.cc9
37 files changed, 1041 insertions, 730 deletions
diff --git a/android_webview/java_library_common.mk b/android_webview/java_library_common.mk
index 870c4bf..6403691 100644
--- a/android_webview/java_library_common.mk
+++ b/android_webview/java_library_common.mk
@@ -42,19 +42,18 @@ LOCAL_GENERATED_SOURCES := \
$(call intermediates-dir-for,GYP,shared)/enums/bitmap_format_java/org/chromium/ui/gfx/BitmapFormat.java \
$(call intermediates-dir-for,GYP,shared)/enums/cert_verify_status_android_java/org/chromium/net/CertVerifyStatusAndroid.java \
$(call intermediates-dir-for,GYP,shared)/enums/certificate_mime_types_java/org/chromium/net/CertificateMimeType.java \
-$(call intermediates-dir-for,GYP,shared)/enums/content_gamepad_mapping/org/chromium/content/browser/input/CanonicalAxisIndex.java \
-$(call intermediates-dir-for,GYP,shared)/enums/content_gamepad_mapping/org/chromium/content/browser/input/CanonicalButtonIndex.java \
-$(call intermediates-dir-for,GYP,shared)/enums/gesture_event_type_java/org/chromium/content/browser/GestureEventType.java \
-$(call intermediates-dir-for,GYP,shared)/enums/popup_item_type_java/org/chromium/content/browser/input/PopupItemType.java \
$(call intermediates-dir-for,GYP,shared)/enums/private_key_types_java/org/chromium/net/PrivateKeyType.java \
-$(call intermediates-dir-for,GYP,shared)/enums/result_codes_java/org/chromium/content_public/common/ResultCode.java \
-$(call intermediates-dir-for,GYP,shared)/enums/screen_orientation_values_java/org/chromium/content_public/common/ScreenOrientationValues.java \
-$(call intermediates-dir-for,GYP,shared)/enums/selection_event_type_java/org/chromium/content/browser/input/SelectionEventType.java \
-$(call intermediates-dir-for,GYP,shared)/enums/speech_recognition_error_java/org/chromium/content_public/common/SpeechRecognitionErrorCode.java \
-$(call intermediates-dir-for,GYP,shared)/enums/top_controls_state_java/org/chromium/content_public/common/TopControlsState.java \
$(call intermediates-dir-for,GYP,shared)/enums/window_open_disposition_java/org/chromium/ui/WindowOpenDisposition.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/base/ApplicationState.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/base/MemoryPressureLevelList.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/GestureEventType.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/SpeechRecognitionError.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/input/CanonicalAxisIndex.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/input/CanonicalButtonIndex.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/input/PopupItemType.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/browser/input/SelectionEventType.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content/common/ResultCodes.java \
+$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/content_public/common/ScreenOrientationValues.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/media/AndroidImageFormat.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/net/NetError.java \
$(call intermediates-dir-for,GYP,shared)/templates/org/chromium/ui/base/PageTransitionTypes.java \
diff --git a/android_webview/libwebviewchromium.gypi b/android_webview/libwebviewchromium.gypi
index 43e5df1..c6df549 100644
--- a/android_webview/libwebviewchromium.gypi
+++ b/android_webview/libwebviewchromium.gypi
@@ -22,7 +22,6 @@
'../content/content.gyp:screen_orientation_values_java',
'../content/content.gyp:selection_event_type_java',
'../content/content.gyp:speech_recognition_error_java',
- '../content/content.gyp:top_controls_state_java',
'../media/media.gyp:media_android_imageformat_list',
'../net/net.gyp:cert_verify_status_android_java',
'../net/net.gyp:certificate_mime_types_java',
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 4b5d62b..3c09a58 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -301,7 +301,7 @@ template("java_cpp_enum") {
assert(defined(invoker.outputs))
action("${target_name}__generate_enum") {
- sources = invoker.sources
+ sources = rebase_path(invoker.sources, root_build_dir)
script = "//build/android/gyp/java_cpp_enum.py"
gen_dir = "${target_gen_dir}/${target_name}/enums"
outputs = get_path_info(
@@ -313,7 +313,7 @@ template("java_cpp_enum") {
foreach(output, rebase_path(outputs, root_build_dir)) {
args += ["--assert_file", output]
}
- args += rebase_path(invoker.sources, root_build_dir)
+ args += sources
}
generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
diff --git a/build/get_landmines.py b/build/get_landmines.py
index f15d8db..8fa5a3b 100755
--- a/build/get_landmines.py
+++ b/build/get_landmines.py
@@ -58,7 +58,6 @@ def print_landmines():
print 'ninja dependency cycle: crbug.com/408192'
if platform() == 'android':
print 'Clobber: To delete stale generated .java files.'
- print 'Delete stale generated .java files again. crbug.com/349592'
def main():
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index d002203..9cd9679 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -70,17 +70,10 @@ using blink::WebInputEvent;
// Describes the type and enabled state of a select popup item.
namespace {
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
-enum PopupItemType {
- // Popup item is of type group
- POPUP_ITEM_TYPE_GROUP,
-
- // Popup item is disabled
- POPUP_ITEM_TYPE_DISABLED,
-
- // Popup item is enabled
- POPUP_ITEM_TYPE_ENABLED,
+enum {
+#define DEFINE_POPUP_ITEM_TYPE(name, value) POPUP_ITEM_TYPE_##name = value,
+#include "content/browser/android/popup_item_type_list.h"
+#undef DEFINE_POPUP_ITEM_TYPE
};
} //namespace
@@ -115,37 +108,37 @@ ScopedJavaLocalRef<jobject> CreateJavaRect(
int ToGestureEventType(WebInputEvent::Type type) {
switch (type) {
case WebInputEvent::GestureScrollBegin:
- return GESTURE_EVENT_TYPE_SCROLL_START;
+ return SCROLL_START;
case WebInputEvent::GestureScrollEnd:
- return GESTURE_EVENT_TYPE_SCROLL_END;
+ return SCROLL_END;
case WebInputEvent::GestureScrollUpdate:
- return GESTURE_EVENT_TYPE_SCROLL_BY;
+ return SCROLL_BY;
case WebInputEvent::GestureFlingStart:
- return GESTURE_EVENT_TYPE_FLING_START;
+ return FLING_START;
case WebInputEvent::GestureFlingCancel:
- return GESTURE_EVENT_TYPE_FLING_CANCEL;
+ return FLING_CANCEL;
case WebInputEvent::GestureShowPress:
- return GESTURE_EVENT_TYPE_SHOW_PRESS;
+ return SHOW_PRESS;
case WebInputEvent::GestureTap:
- return GESTURE_EVENT_TYPE_SINGLE_TAP_CONFIRMED;
+ return SINGLE_TAP_CONFIRMED;
case WebInputEvent::GestureTapUnconfirmed:
- return GESTURE_EVENT_TYPE_SINGLE_TAP_UNCONFIRMED;
+ return SINGLE_TAP_UNCONFIRMED;
case WebInputEvent::GestureTapDown:
- return GESTURE_EVENT_TYPE_TAP_DOWN;
+ return TAP_DOWN;
case WebInputEvent::GestureTapCancel:
- return GESTURE_EVENT_TYPE_TAP_CANCEL;
+ return TAP_CANCEL;
case WebInputEvent::GestureDoubleTap:
- return GESTURE_EVENT_TYPE_DOUBLE_TAP;
+ return DOUBLE_TAP;
case WebInputEvent::GestureLongPress:
- return GESTURE_EVENT_TYPE_LONG_PRESS;
+ return LONG_PRESS;
case WebInputEvent::GestureLongTap:
- return GESTURE_EVENT_TYPE_LONG_TAP;
+ return LONG_TAP;
case WebInputEvent::GesturePinchBegin:
- return GESTURE_EVENT_TYPE_PINCH_BEGIN;
+ return PINCH_BEGIN;
case WebInputEvent::GesturePinchEnd:
- return GESTURE_EVENT_TYPE_PINCH_END;
+ return PINCH_END;
case WebInputEvent::GesturePinchUpdate:
- return GESTURE_EVENT_TYPE_PINCH_BY;
+ return PINCH_BY;
case WebInputEvent::GestureTwoFingerTap:
case WebInputEvent::GestureScrollUpdateWithoutPropagation:
default:
diff --git a/content/browser/android/gesture_event_type.h b/content/browser/android/gesture_event_type.h
index ce87c90..d41311c 100644
--- a/content/browser/android/gesture_event_type.h
+++ b/content/browser/android/gesture_event_type.h
@@ -7,31 +7,10 @@
namespace content {
-// This file contains a list of GestureEventType's usable by ContentViewCore,
-// providing a direct mapping to and from their corresponding
-// blink::WebGestureEvent types.
-//
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser
enum GestureEventType {
- GESTURE_EVENT_TYPE_SHOW_PRESS,
- GESTURE_EVENT_TYPE_DOUBLE_TAP,
- GESTURE_EVENT_TYPE_SINGLE_TAP_UP,
- GESTURE_EVENT_TYPE_SINGLE_TAP_CONFIRMED,
- GESTURE_EVENT_TYPE_SINGLE_TAP_UNCONFIRMED,
- GESTURE_EVENT_TYPE_LONG_PRESS,
- GESTURE_EVENT_TYPE_SCROLL_START,
- GESTURE_EVENT_TYPE_SCROLL_BY,
- GESTURE_EVENT_TYPE_SCROLL_END,
- GESTURE_EVENT_TYPE_FLING_START,
- GESTURE_EVENT_TYPE_FLING_CANCEL,
- GESTURE_EVENT_TYPE_FLING_END,
- GESTURE_EVENT_TYPE_PINCH_BEGIN,
- GESTURE_EVENT_TYPE_PINCH_BY,
- GESTURE_EVENT_TYPE_PINCH_END,
- GESTURE_EVENT_TYPE_TAP_CANCEL,
- GESTURE_EVENT_TYPE_LONG_TAP,
- GESTURE_EVENT_TYPE_TAP_DOWN,
+#define DEFINE_GESTURE_EVENT_TYPE(name, value) name = value,
+#include "content/browser/android/gesture_event_type_list.h"
+#undef DEFINE_GESTURE_EVENT_TYPE
};
} // namespace content
diff --git a/content/browser/android/gesture_event_type_list.h b/content/browser/android/gesture_event_type_list.h
new file mode 100644
index 0000000..85af616
--- /dev/null
+++ b/content/browser/android/gesture_event_type_list.h
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards because this file
+// is meant to be included inside a macro to generate enum values.
+
+// This file contains a list of GestureEventType's usable by ContentViewCore,
+// providing a direct mapping to and from their corresponding
+// blink::WebGestureEvent types.
+
+#ifndef DEFINE_GESTURE_EVENT_TYPE
+#error "Please define DEFINE_GESTURE_EVENT_TYPE before including this file."
+#endif
+
+DEFINE_GESTURE_EVENT_TYPE(SHOW_PRESS, 0)
+DEFINE_GESTURE_EVENT_TYPE(DOUBLE_TAP, 1)
+DEFINE_GESTURE_EVENT_TYPE(SINGLE_TAP_UP, 2)
+DEFINE_GESTURE_EVENT_TYPE(SINGLE_TAP_CONFIRMED, 3)
+DEFINE_GESTURE_EVENT_TYPE(SINGLE_TAP_UNCONFIRMED, 4)
+DEFINE_GESTURE_EVENT_TYPE(LONG_PRESS, 5)
+DEFINE_GESTURE_EVENT_TYPE(SCROLL_START, 6)
+DEFINE_GESTURE_EVENT_TYPE(SCROLL_BY, 7)
+DEFINE_GESTURE_EVENT_TYPE(SCROLL_END, 8)
+DEFINE_GESTURE_EVENT_TYPE(FLING_START, 9)
+DEFINE_GESTURE_EVENT_TYPE(FLING_CANCEL, 10)
+DEFINE_GESTURE_EVENT_TYPE(FLING_END, 11)
+DEFINE_GESTURE_EVENT_TYPE(PINCH_BEGIN, 12)
+DEFINE_GESTURE_EVENT_TYPE(PINCH_BY, 13)
+DEFINE_GESTURE_EVENT_TYPE(PINCH_END, 14)
+DEFINE_GESTURE_EVENT_TYPE(TAP_CANCEL, 15)
+DEFINE_GESTURE_EVENT_TYPE(LONG_TAP, 16)
+DEFINE_GESTURE_EVENT_TYPE(TAP_DOWN, 17)
diff --git a/content/browser/android/popup_item_type_list.h b/content/browser/android/popup_item_type_list.h
new file mode 100644
index 0000000..3f50490
--- /dev/null
+++ b/content/browser/android/popup_item_type_list.h
@@ -0,0 +1,23 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards because this file
+// is meant to be included inside a macro to generate enum values.
+
+// This file contains a list of sync PopupItemTypes which describe the type
+// and enabled state of a select popup item. List is used by Android when
+// displaying a new select popup menu.
+
+#ifndef DEFINE_POPUP_ITEM_TYPE
+#error "Please define DEFINE_POPUP_ITEM_TYPE before including this file."
+#endif
+
+// Popup item is of type group
+DEFINE_POPUP_ITEM_TYPE(GROUP, 0)
+
+// Popup item is disabled
+DEFINE_POPUP_ITEM_TYPE(DISABLED, 1)
+
+// Popup item is enabled
+DEFINE_POPUP_ITEM_TYPE(ENABLED, 2)
diff --git a/content/browser/gamepad/canonical_axis_index_list.h b/content/browser/gamepad/canonical_axis_index_list.h
new file mode 100644
index 0000000..58b85a6
--- /dev/null
+++ b/content/browser/gamepad/canonical_axis_index_list.h
@@ -0,0 +1,16 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards, it's included
+// inside a macro to generate enum values.
+
+// This file defines the canonical axes mapping order for gamepad-like devices.
+
+// TODO(SaurabhK): Consolidate with CanonicalAxisIndex enum in
+// gamepad_standard_mappings.h, crbug.com/351558.
+CANONICAL_AXIS_INDEX(AXIS_LEFT_STICK_X, 0)
+CANONICAL_AXIS_INDEX(AXIS_LEFT_STICK_Y, 1)
+CANONICAL_AXIS_INDEX(AXIS_RIGHT_STICK_X, 2)
+CANONICAL_AXIS_INDEX(AXIS_RIGHT_STICK_Y, 3)
+CANONICAL_AXIS_INDEX(NUM_CANONICAL_AXES, 4)
diff --git a/content/browser/gamepad/canonical_button_index_list.h b/content/browser/gamepad/canonical_button_index_list.h
new file mode 100644
index 0000000..153ce0e
--- /dev/null
+++ b/content/browser/gamepad/canonical_button_index_list.h
@@ -0,0 +1,28 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards, it's included
+// inside a macro to generate enum values.
+// This defines the canonical button mapping order for gamepad-like devices.
+
+// TODO(SaurabhK): Consolidate with CanonicalButtonIndex enum in
+// gamepad_standard_mappings.h, crbug.com/351558.
+CANONICAL_BUTTON_INDEX(BUTTON_PRIMARY, 0)
+CANONICAL_BUTTON_INDEX(BUTTON_SECONDARY, 1)
+CANONICAL_BUTTON_INDEX(BUTTON_TERTIARY, 2)
+CANONICAL_BUTTON_INDEX(BUTTON_QUATERNARY, 3)
+CANONICAL_BUTTON_INDEX(BUTTON_LEFT_SHOULDER, 4)
+CANONICAL_BUTTON_INDEX(BUTTON_RIGHT_SHOULDER, 5)
+CANONICAL_BUTTON_INDEX(BUTTON_LEFT_TRIGGER, 6)
+CANONICAL_BUTTON_INDEX(BUTTON_RIGHT_TRIGGER, 7)
+CANONICAL_BUTTON_INDEX(BUTTON_BACK_SELECT, 8)
+CANONICAL_BUTTON_INDEX(BUTTON_START, 9)
+CANONICAL_BUTTON_INDEX(BUTTON_LEFT_THUMBSTICK, 10)
+CANONICAL_BUTTON_INDEX(BUTTON_RIGHT_THUMBSTICK, 11)
+CANONICAL_BUTTON_INDEX(BUTTON_DPAD_UP, 12)
+CANONICAL_BUTTON_INDEX(BUTTON_DPAD_DOWN, 13)
+CANONICAL_BUTTON_INDEX(BUTTON_DPAD_LEFT, 14)
+CANONICAL_BUTTON_INDEX(BUTTON_DPAD_RIGHT, 15)
+CANONICAL_BUTTON_INDEX(BUTTON_META, 16)
+CANONICAL_BUTTON_INDEX(NUM_CANONICAL_BUTTONS, 17) \ No newline at end of file
diff --git a/content/browser/gamepad/gamepad_standard_mappings.cc b/content/browser/gamepad/gamepad_standard_mappings.cc
index 687d4ce1..7f159e1 100644
--- a/content/browser/gamepad/gamepad_standard_mappings.cc
+++ b/content/browser/gamepad/gamepad_standard_mappings.cc
@@ -51,14 +51,14 @@ void DpadFromAxis(blink::WebGamepad* mapped, float dir) {
left = dir >= .4f && dir <= 1.f;
}
- mapped->buttons[BUTTON_INDEX_DPAD_UP].pressed = 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].value = right ? 1.f : 0.f;
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN].pressed = 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].value = left ? 1.f : 0.f;
+ mapped->buttons[kButtonDpadUp].pressed = up;
+ mapped->buttons[kButtonDpadUp].value = up ? 1.f : 0.f;
+ mapped->buttons[kButtonDpadRight].pressed = right;
+ mapped->buttons[kButtonDpadRight].value = right ? 1.f : 0.f;
+ mapped->buttons[kButtonDpadDown].pressed = down;
+ mapped->buttons[kButtonDpadDown].value = down ? 1.f : 0.f;
+ mapped->buttons[kButtonDpadLeft].pressed = left;
+ mapped->buttons[kButtonDpadLeft].value = left ? 1.f : 0.f;
}
} // namespace content
diff --git a/content/browser/gamepad/gamepad_standard_mappings.h b/content/browser/gamepad/gamepad_standard_mappings.h
index d4908ef..5a71cc8 100644
--- a/content/browser/gamepad/gamepad_standard_mappings.h
+++ b/content/browser/gamepad/gamepad_standard_mappings.h
@@ -24,39 +24,33 @@ GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
// general, err towards leaving it *unmapped* so that content can handle
// appropriately.
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
-// GENERATED_JAVA_PREFIX_TO_STRIP: BUTTON_INDEX_
enum CanonicalButtonIndex {
- BUTTON_INDEX_PRIMARY,
- BUTTON_INDEX_SECONDARY,
- BUTTON_INDEX_TERTIARY,
- BUTTON_INDEX_QUATERNARY,
- BUTTON_INDEX_LEFT_SHOULDER,
- BUTTON_INDEX_RIGHT_SHOULDER,
- BUTTON_INDEX_LEFT_TRIGGER,
- BUTTON_INDEX_RIGHT_TRIGGER,
- BUTTON_INDEX_BACK_SELECT,
- BUTTON_INDEX_START,
- BUTTON_INDEX_LEFT_THUMBSTICK,
- BUTTON_INDEX_RIGHT_THUMBSTICK,
- BUTTON_INDEX_DPAD_UP,
- BUTTON_INDEX_DPAD_DOWN,
- BUTTON_INDEX_DPAD_LEFT,
- BUTTON_INDEX_DPAD_RIGHT,
- BUTTON_INDEX_META,
- BUTTON_INDEX_COUNT
+ kButtonPrimary,
+ kButtonSecondary,
+ kButtonTertiary,
+ kButtonQuaternary,
+ kButtonLeftShoulder,
+ kButtonRightShoulder,
+ kButtonLeftTrigger,
+ kButtonRightTrigger,
+ kButtonBackSelect,
+ kButtonStart,
+ kButtonLeftThumbstick,
+ kButtonRightThumbstick,
+ kButtonDpadUp,
+ kButtonDpadDown,
+ kButtonDpadLeft,
+ kButtonDpadRight,
+ kButtonMeta,
+ kNumButtons
};
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
-// GENERATED_JAVA_PREFIX_TO_STRIP: AXIS_INDEX_
enum CanonicalAxisIndex {
- AXIS_INDEX_LEFT_STICK_X,
- AXIS_INDEX_LEFT_STICK_Y,
- AXIS_INDEX_RIGHT_STICK_X,
- AXIS_INDEX_RIGHT_STICK_Y,
- AXIS_INDEX_COUNT
+ kAxisLeftStickX,
+ kAxisLeftStickY,
+ kAxisRightStickX,
+ kAxisRightStickY,
+ kNumAxes
};
// Matches XInput's trigger deadzone
diff --git a/content/browser/gamepad/gamepad_standard_mappings_linux.cc b/content/browser/gamepad/gamepad_standard_mappings_linux.cc
index a085242..2465938 100644
--- a/content/browser/gamepad/gamepad_standard_mappings_linux.cc
+++ b/content/browser/gamepad/gamepad_standard_mappings_linux.cc
@@ -8,182 +8,186 @@ namespace content {
namespace {
-void MapperXInputStyleGamepad(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperXInputStyleGamepad(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[8];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[6];
+ mapped->buttons[kButtonStart] = input.buttons[7];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[9];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[10];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]);
+ mapped->buttons[kButtonMeta] = input.buttons[8];
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[4];
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperLakeviewResearch(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperLakeviewResearch(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[4]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device
- mapped->axesLength = AXIS_INDEX_COUNT;
+ 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];
+ mapped->buttons[kButtonBackSelect] = input.buttons[9];
+ mapped->buttons[kButtonStart] = input.buttons[8];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[5]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[5]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[4]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[4]);
+ mapped->buttonsLength = kNumButtons - 1; // no Meta on this device
+ mapped->axesLength = kNumAxes;
}
-void MapperPlaystationSixAxis(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperPlaystationSixAxis(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[12]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[13]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisToButton(input.axes[8]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisToButton(input.axes[10]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = AxisToButton(input.axes[9]);
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[16];
-
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonPrimary] = input.buttons[14];
+ mapped->buttons[kButtonSecondary] = input.buttons[13];
+ mapped->buttons[kButtonTertiary] = input.buttons[15];
+ mapped->buttons[kButtonQuaternary] = input.buttons[12];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[10];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[11];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[12]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[13]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[0];
+ mapped->buttons[kButtonStart] = input.buttons[3];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[1];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[2];
+ mapped->buttons[kButtonDpadUp] = AxisToButton(input.axes[8]);
+ mapped->buttons[kButtonDpadDown] = AxisToButton(input.axes[10]);
+ mapped->buttons[kButtonDpadLeft] = input.buttons[7];
+ mapped->buttons[kButtonDpadRight] = AxisToButton(input.axes[9]);
+ mapped->buttons[kButtonMeta] = input.buttons[16];
+
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperDualshock4(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperDualshock4(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
enum Dualshock4Buttons {
- DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
- DUALSHOCK_BUTTON_COUNT
+ kTouchpadButton = kNumButtons,
+ kNumDualshock4Buttons
};
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
-
- mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonPrimary] = input.buttons[1];
+ mapped->buttons[kButtonSecondary] = input.buttons[2];
+ mapped->buttons[kButtonTertiary] = input.buttons[0];
+ mapped->buttons[kButtonQuaternary] = input.buttons[3];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[4];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[5];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[8];
+ mapped->buttons[kButtonStart] = input.buttons[9];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[10];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[11];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]);
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->buttons[kTouchpadButton] = input.buttons[13];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
+
+ mapped->buttonsLength = kNumDualshock4Buttons;
+ mapped->axesLength = kNumAxes;
}
-void MapperXGEAR(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
+void MapperXGEAR(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[4]);
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2];
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonPrimary] = input.buttons[2];
+ mapped->buttons[kButtonSecondary] = input.buttons[1];
+ 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];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[5]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[5]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[4]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[4]);
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[2];
+ mapped->buttonsLength = kNumButtons - 1; // no Meta on this device
+ mapped->axesLength = kNumAxes;
}
-void MapperDragonRiseGeneric(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+
+void MapperDragonRiseGeneric(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[5]);
- mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
- mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[6]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[6]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[5]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[5]);
+ mapped->axes[kAxisLeftStickX] = input.axes[0];
+ mapped->axes[kAxisLeftStickY] = input.axes[1];
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[4];
+ mapped->buttonsLength = kNumButtons - 1; // no Meta on this device
+ mapped->axesLength = kNumAxes;
}
-void MapperOnLiveWireless(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperOnLiveWireless(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[8];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
-
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[6];
+ mapped->buttons[kButtonStart] = input.buttons[7];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[9];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[10];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]);
+ mapped->buttons[kButtonMeta] = input.buttons[8];
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[4];
+
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
+void MapperADT1(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
- mapped->buttons[BUTTON_INDEX_START] = NullButton();
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[6]);
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[6];
-
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[5]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
+ mapped->buttons[kButtonBackSelect] = NullButton();
+ mapped->buttons[kButtonStart] = NullButton();
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[7];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[8];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]);
+ mapped->buttons[kButtonMeta] = input.buttons[6];
+
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
struct MappingData {
@@ -191,23 +195,21 @@ struct MappingData {
const char* const product_id;
GamepadStandardMappingFunction function;
} AvailableMappings[] = {
- // http://www.linux-usb.org/usb.ids
- {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB
- {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Controller
- {"045e",
- "028f",
- MapperXInputStyleGamepad}, // Xbox 360 Wireless Controller
- {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310
- {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510
- {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710
- {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS
- {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4
- {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter
- {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866
- {"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller
- {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth)
- {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired)
- {"18d1", "2c40", MapperADT1}, // ADT-1 Controller
+ // http://www.linux-usb.org/usb.ids
+ { "0079", "0006", MapperDragonRiseGeneric }, // DragonRise Generic USB
+ { "045e", "028e", MapperXInputStyleGamepad }, // Xbox 360 Controller
+ { "045e", "028f", MapperXInputStyleGamepad }, // Xbox 360 Wireless Controller
+ { "046d", "c21d", MapperXInputStyleGamepad }, // Logitech F310
+ { "046d", "c21e", MapperXInputStyleGamepad }, // Logitech F510
+ { "046d", "c21f", MapperXInputStyleGamepad }, // Logitech F710
+ { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS
+ { "054c", "05c4", MapperDualshock4 }, // Playstation Dualshock 4
+ { "0925", "0005", MapperLakeviewResearch }, // SmartJoy PLUS Adapter
+ { "0925", "8866", MapperLakeviewResearch }, // WiseGroup MP-8866
+ { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller
+ { "2378", "1008", MapperOnLiveWireless }, // OnLive Controller (Bluetooth)
+ { "2378", "100a", MapperOnLiveWireless }, // OnLive Controller (Wired)
+ { "18d1", "2c40", MapperADT1 }, // ADT-1 Controller
};
} // namespace
diff --git a/content/browser/gamepad/gamepad_standard_mappings_mac.mm b/content/browser/gamepad/gamepad_standard_mappings_mac.mm
index ebb08ed..50bdbc0 100644
--- a/content/browser/gamepad/gamepad_standard_mappings_mac.mm
+++ b/content/browser/gamepad/gamepad_standard_mappings_mac.mm
@@ -8,233 +8,245 @@ namespace content {
namespace {
-void MapperXbox360Gamepad(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperXbox360Gamepad(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[12];
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[10];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[9];
+ mapped->buttons[kButtonStart] = input.buttons[8];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[6];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[7];
+ mapped->buttons[kButtonDpadUp] = input.buttons[11];
+ mapped->buttons[kButtonDpadDown] = input.buttons[12];
+ mapped->buttons[kButtonDpadLeft] = input.buttons[13];
+ mapped->buttons[kButtonDpadRight] = input.buttons[14];
+ mapped->buttons[kButtonMeta] = input.buttons[10];
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[4];
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperPlaystationSixAxis(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperPlaystationSixAxis(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11];
+ mapped->buttons[kButtonPrimary] = input.buttons[14];
+ mapped->buttons[kButtonSecondary] = input.buttons[13];
+ mapped->buttons[kButtonTertiary] = input.buttons[15];
+ mapped->buttons[kButtonQuaternary] = input.buttons[12];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[10];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] =
- ButtonFromButtonAndAxis(input.buttons[8], input.axes[14]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] =
- ButtonFromButtonAndAxis(input.buttons[9], input.axes[15]);
+ mapped->buttons[kButtonLeftTrigger] = ButtonFromButtonAndAxis(
+ input.buttons[8], input.axes[14]);
+ mapped->buttons[kButtonRightTrigger] = ButtonFromButtonAndAxis(
+ input.buttons[9], input.axes[15]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2];
+ mapped->buttons[kButtonBackSelect] = input.buttons[0];
+ mapped->buttons[kButtonStart] = input.buttons[3];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[1];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[2];
// The SixAxis Dpad is pressure sensative
- mapped->buttons[BUTTON_INDEX_DPAD_UP] =
- ButtonFromButtonAndAxis(input.buttons[4], input.axes[10]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] =
- ButtonFromButtonAndAxis(input.buttons[6], input.axes[12]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] =
- ButtonFromButtonAndAxis(input.buttons[7], input.axes[13]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- ButtonFromButtonAndAxis(input.buttons[5], input.axes[11]);
+ mapped->buttons[kButtonDpadUp] = ButtonFromButtonAndAxis(
+ input.buttons[4], input.axes[10]);
+ mapped->buttons[kButtonDpadDown] = ButtonFromButtonAndAxis(
+ input.buttons[6], input.axes[12]);
+ mapped->buttons[kButtonDpadLeft] = ButtonFromButtonAndAxis(
+ input.buttons[7], input.axes[13]);
+ mapped->buttons[kButtonDpadRight] = ButtonFromButtonAndAxis(
+ input.buttons[5], input.axes[11]);
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[16];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonMeta] = input.buttons[16];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperDualshock4(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperDualshock4(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
enum Dualshock4Buttons {
- DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
- DUALSHOCK_BUTTON_COUNT
+ kTouchpadButton = kNumButtons,
+ kNumDualshock4Buttons
};
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[1];
+ mapped->buttons[kButtonSecondary] = input.buttons[2];
+ mapped->buttons[kButtonTertiary] = input.buttons[0];
+ mapped->buttons[kButtonQuaternary] = input.buttons[3];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[4];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[5];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[8];
+ mapped->buttons[kButtonStart] = input.buttons[9];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[10];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[11];
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->buttons[kTouchpadButton] = input.buttons[13];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumDualshock4Buttons;
+ mapped->axesLength = kNumAxes;
}
-void MapperDirectInputStyle(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperDirectInputStyle(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[1];
+ mapped->buttons[kButtonSecondary] = input.buttons[2];
+ mapped->buttons[kButtonTertiary] = input.buttons[0];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons - 1; /* no meta */
+ mapped->axesLength = kNumAxes;
}
-void MapperMacallyIShock(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperMacallyIShock(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
enum IShockButtons {
- ISHOCK_BUTTON_C = BUTTON_INDEX_COUNT,
- ISHOCK_BUTTON_D,
- ISHOCK_BUTTON_E,
- ISHOCK_BUTTON_COUNT,
+ kButtonC = kNumButtons,
+ kButtonD,
+ kButtonE,
+ kNumIShockButtons
};
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[5];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[12];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[15];
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[16];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[17];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[11];
- mapped->buttons[ISHOCK_BUTTON_C] = input.buttons[8];
- mapped->buttons[ISHOCK_BUTTON_D] = input.buttons[18];
- mapped->buttons[ISHOCK_BUTTON_E] = input.buttons[19];
- mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
- mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = -input.axes[5];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[6];
+ mapped->buttons[kButtonPrimary] = input.buttons[6];
+ mapped->buttons[kButtonSecondary] = input.buttons[5];
+ mapped->buttons[kButtonTertiary] = input.buttons[7];
+ mapped->buttons[kButtonQuaternary] = input.buttons[4];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[14];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[12];
+ mapped->buttons[kButtonLeftTrigger] = input.buttons[15];
+ mapped->buttons[kButtonRightTrigger] = input.buttons[13];
+ mapped->buttons[kButtonBackSelect] = input.buttons[9];
+ mapped->buttons[kButtonStart] = input.buttons[10];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[16];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[17];
+ mapped->buttons[kButtonDpadUp] = input.buttons[0];
+ mapped->buttons[kButtonDpadDown] = input.buttons[1];
+ mapped->buttons[kButtonDpadLeft] = input.buttons[2];
+ mapped->buttons[kButtonDpadRight] = input.buttons[3];
+ mapped->buttons[kButtonMeta] = input.buttons[11];
+ mapped->buttons[kButtonC] = input.buttons[8];
+ mapped->buttons[kButtonD] = input.buttons[18];
+ mapped->buttons[kButtonE] = input.buttons[19];
+ mapped->axes[kAxisLeftStickX] = input.axes[0];
+ mapped->axes[kAxisLeftStickY] = input.axes[1];
+ mapped->axes[kAxisRightStickX] = -input.axes[5];
+ mapped->axes[kAxisRightStickY] = input.axes[6];
- mapped->buttonsLength = ISHOCK_BUTTON_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumIShockButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperXGEAR(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
+void MapperXGEAR(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
+ 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[AXIS_INDEX_RIGHT_STICK_X] = input.axes[5];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2];
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->axes[kAxisRightStickX] = input.axes[5];
+ mapped->axes[kAxisRightStickY] = input.axes[2];
+ mapped->buttonsLength = kNumButtons - 1; /* no meta */
+ mapped->axesLength = kNumAxes;
}
-void MapperSmartJoyPLUS(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperSmartJoyPLUS(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[2];
+ mapped->buttons[kButtonTertiary] = input.buttons[3];
+ mapped->buttons[kButtonQuaternary] = input.buttons[0];
+ mapped->buttons[kButtonStart] = input.buttons[8];
+ mapped->buttons[kButtonBackSelect] = input.buttons[9];
+ 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[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->axes[kAxisRightStickY] = input.axes[5];
+ mapped->buttonsLength = kNumButtons - 1; /* no meta */
+ mapped->axesLength = kNumAxes;
}
-void MapperDragonRiseGeneric(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperDragonRiseGeneric(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
DpadFromAxis(mapped, input.axes[9]);
- mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
- mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->axes[kAxisLeftStickX] = input.axes[0];
+ mapped->axes[kAxisLeftStickY] = input.axes[1];
+ mapped->axes[kAxisRightStickX] = input.axes[2];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
+ mapped->buttonsLength = kNumButtons - 1; /* no meta */
+ mapped->axesLength = kNumAxes;
}
-void MapperOnLiveWireless(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperOnLiveWireless(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
+ mapped->buttons[kButtonPrimary] = input.buttons[0];
+ mapped->buttons[kButtonSecondary] = input.buttons[1];
+ mapped->buttons[kButtonTertiary] = input.buttons[3];
+ mapped->buttons[kButtonQuaternary] = input.buttons[4];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[7];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[10];
+ mapped->buttons[kButtonStart] = input.buttons[11];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[4];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
+void MapperADT1(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
- mapped->buttons[BUTTON_INDEX_START] = NullButton();
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[0];
+ mapped->buttons[kButtonSecondary] = input.buttons[1];
+ mapped->buttons[kButtonTertiary] = input.buttons[3];
+ mapped->buttons[kButtonQuaternary] = input.buttons[4];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[7];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
+ mapped->buttons[kButtonBackSelect] = NullButton();
+ mapped->buttons[kButtonStart] = NullButton();
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
struct MappingData {
@@ -242,22 +254,22 @@ struct MappingData {
const char* const product_id;
GamepadStandardMappingFunction function;
} AvailableMappings[] = {
- // http://www.linux-usb.org/usb.ids
- {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB
- {"045e", "028e", MapperXbox360Gamepad}, // Xbox 360 Controller
- {"045e", "028f", MapperXbox360Gamepad}, // Xbox 360 Wireless Controller
- {"046d", "c216", MapperDirectInputStyle}, // Logitech F310, D mode
- {"046d", "c218", MapperDirectInputStyle}, // Logitech F510, D mode
- {"046d", "c219", MapperDirectInputStyle}, // Logitech F710, D mode
- {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS
- {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4
- {"0925", "0005", MapperSmartJoyPLUS}, // SmartJoy PLUS Adapter
- {"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller
- {"2222", "0060", MapperDirectInputStyle}, // Macally iShockX, analog mode
- {"2222", "4010", MapperMacallyIShock}, // Macally iShock
- {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth)
- {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired)
- {"18d1", "2c40", MapperADT1}, // ADT-1 Controller
+ // http://www.linux-usb.org/usb.ids
+ { "0079", "0006", MapperDragonRiseGeneric }, // DragonRise Generic USB
+ { "045e", "028e", MapperXbox360Gamepad }, // Xbox 360 Controller
+ { "045e", "028f", MapperXbox360Gamepad }, // Xbox 360 Wireless Controller
+ { "046d", "c216", MapperDirectInputStyle }, // Logitech F310, D mode
+ { "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode
+ { "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode
+ { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS
+ { "054c", "05c4", MapperDualshock4 }, // Playstation Dualshock 4
+ { "0925", "0005", MapperSmartJoyPLUS }, // SmartJoy PLUS Adapter
+ { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller
+ { "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode
+ { "2222", "4010", MapperMacallyIShock }, // Macally iShock
+ { "2378", "1008", MapperOnLiveWireless }, // OnLive Controller (Bluetooth)
+ { "2378", "100a", MapperOnLiveWireless }, // OnLive Controller (Wired)
+ { "18d1", "2c40", MapperADT1 }, // ADT-1 Controller
};
} // namespace
diff --git a/content/browser/gamepad/gamepad_standard_mappings_win.cc b/content/browser/gamepad/gamepad_standard_mappings_win.cc
index 93c1851..f79b451 100644
--- a/content/browser/gamepad/gamepad_standard_mappings_win.cc
+++ b/content/browser/gamepad/gamepad_standard_mappings_win.cc
@@ -8,116 +8,121 @@ namespace content {
namespace {
-void MapperLogitechDualAction(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperLogitechDualAction(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[1];
+ mapped->buttons[kButtonSecondary] = input.buttons[2];
+ mapped->buttons[kButtonTertiary] = input.buttons[0];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void Mapper2Axes8Keys(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void Mapper2Axes8Keys(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[1]);
- mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[1]);
- mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[0]);
- mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
- AxisPositiveAsButton(input.axes[0]);
+ mapped->buttons[kButtonPrimary] = input.buttons[2];
+ mapped->buttons[kButtonSecondary] = input.buttons[1];
+ mapped->buttons[kButtonTertiary] = input.buttons[3];
+ mapped->buttons[kButtonQuaternary] = input.buttons[0];
+ mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[1]);
+ mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[1]);
+ mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[0]);
+ mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[0]);
// Missing buttons
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = blink::WebGamepadButton();
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = blink::WebGamepadButton();
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = blink::WebGamepadButton();
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = blink::WebGamepadButton();
- mapped->buttons[BUTTON_INDEX_META] = blink::WebGamepadButton();
+ mapped->buttons[kButtonLeftTrigger] = blink::WebGamepadButton();
+ mapped->buttons[kButtonRightTrigger] = blink::WebGamepadButton();
+ mapped->buttons[kButtonLeftThumbstick] = blink::WebGamepadButton();
+ mapped->buttons[kButtonRightThumbstick] = blink::WebGamepadButton();
+ mapped->buttons[kButtonMeta] = blink::WebGamepadButton();
- mapped->buttonsLength = BUTTON_INDEX_COUNT - 1;
+ mapped->buttonsLength = kNumButtons - 1;
mapped->axesLength = 0;
}
-void MapperDualshock4(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperDualshock4(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
enum Dualshock4Buttons {
- DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
- DUALSHOCK_BUTTON_COUNT
+ kTouchpadButton = kNumButtons,
+ kNumDualshock4Buttons
};
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[1];
+ mapped->buttons[kButtonSecondary] = input.buttons[2];
+ mapped->buttons[kButtonTertiary] = input.buttons[0];
+ mapped->buttons[kButtonQuaternary] = input.buttons[3];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[4];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[5];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[8];
+ mapped->buttons[kButtonStart] = input.buttons[9];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[10];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[11];
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->buttons[kTouchpadButton] = input.buttons[13];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumDualshock4Buttons;
+ mapped->axesLength = kNumAxes;
}
-void MapperOnLiveWireless(const blink::WebGamepad& input,
- blink::WebGamepad* mapped) {
+void MapperOnLiveWireless(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10];
- mapped->buttons[BUTTON_INDEX_START] = input.buttons[11];
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
+ mapped->buttons[kButtonPrimary] = input.buttons[0];
+ mapped->buttons[kButtonSecondary] = input.buttons[1];
+ mapped->buttons[kButtonTertiary] = input.buttons[3];
+ mapped->buttons[kButtonQuaternary] = input.buttons[4];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[7];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
+ mapped->buttons[kButtonBackSelect] = input.buttons[10];
+ mapped->buttons[kButtonStart] = input.buttons[11];
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->axes[kAxisRightStickX] = input.axes[3];
+ mapped->axes[kAxisRightStickY] = input.axes[4];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
-void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
+void MapperADT1(
+ const blink::WebGamepad& input,
+ blink::WebGamepad* mapped) {
*mapped = input;
- mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0];
- mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
- mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
- mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4];
- mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
- mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
- mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[4]);
- mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[3]);
- mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
- mapped->buttons[BUTTON_INDEX_START] = NullButton();
- mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13];
- mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14];
- mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
- mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
+ mapped->buttons[kButtonPrimary] = input.buttons[0];
+ mapped->buttons[kButtonSecondary] = input.buttons[1];
+ mapped->buttons[kButtonTertiary] = input.buttons[3];
+ mapped->buttons[kButtonQuaternary] = input.buttons[4];
+ mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
+ mapped->buttons[kButtonRightShoulder] = input.buttons[7];
+ mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[4]);
+ mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[3]);
+ mapped->buttons[kButtonBackSelect] = NullButton();
+ mapped->buttons[kButtonStart] = NullButton();
+ mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
+ mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
+ mapped->buttons[kButtonMeta] = input.buttons[12];
+ mapped->axes[kAxisRightStickY] = input.axes[5];
DpadFromAxis(mapped, input.axes[9]);
- mapped->buttonsLength = BUTTON_INDEX_COUNT;
- mapped->axesLength = AXIS_INDEX_COUNT;
+ mapped->buttonsLength = kNumButtons;
+ mapped->axesLength = kNumAxes;
}
struct MappingData {
@@ -125,13 +130,13 @@ struct MappingData {
const char* const product_id;
GamepadStandardMappingFunction function;
} AvailableMappings[] = {
- // http://www.linux-usb.org/usb.ids
- {"046d", "c216", MapperLogitechDualAction}, // Logitech DualAction
- {"0079", "0011", Mapper2Axes8Keys}, // 2Axes 8Keys Game Pad
- {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4
- {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth)
- {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired)
- {"18d1", "2c40", MapperADT1}, // ADT-1 Controller
+ // http://www.linux-usb.org/usb.ids
+ { "046d", "c216", MapperLogitechDualAction }, // Logitech DualAction
+ { "0079", "0011", Mapper2Axes8Keys }, // 2Axes 8Keys Game Pad
+ { "054c", "05c4", MapperDualshock4 }, // Playstation Dualshock 4
+ { "2378", "1008", MapperOnLiveWireless }, // OnLive Controller (Bluetooth)
+ { "2378", "100a", MapperOnLiveWireless }, // OnLive Controller (Wired)
+ { "18d1", "2c40", MapperADT1 }, // ADT-1 Controller
};
} // namespace
diff --git a/content/browser/renderer_host/input/selection_event_type.h b/content/browser/renderer_host/input/selection_event_type.h
index 567259f..0bf7673 100644
--- a/content/browser/renderer_host/input/selection_event_type.h
+++ b/content/browser/renderer_host/input/selection_event_type.h
@@ -7,21 +7,10 @@
namespace content {
-// This file contains a list of events relating to selection and insertion, used
-// for notifying Java when the renderer selection has changed.
-//
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content.browser.input
enum SelectionEventType {
- SELECTION_SHOWN,
- SELECTION_CLEARED,
- SELECTION_DRAG_STARTED,
- SELECTION_DRAG_STOPPED,
- INSERTION_SHOWN,
- INSERTION_MOVED,
- INSERTION_TAPPED,
- INSERTION_CLEARED,
- INSERTION_DRAG_STARTED,
+#define DEFINE_SELECTION_EVENT_TYPE(name, value) name = value,
+#include "content/browser/renderer_host/input/selection_event_type_list.h"
+#undef DEFINE_SELECTION_EVENT_TYPE
};
} // namespace content
diff --git a/content/browser/renderer_host/input/selection_event_type_list.h b/content/browser/renderer_host/input/selection_event_type_list.h
new file mode 100644
index 0000000..b4f3852
--- /dev/null
+++ b/content/browser/renderer_host/input/selection_event_type_list.h
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards because this file
+// is meant to be included inside a macro to generate enum values.
+
+// This file contains a list of events relating to selection and insertion, used
+// for notifying Java when the renderer selection has changed.
+
+#ifndef DEFINE_SELECTION_EVENT_TYPE
+#error "Please define DEFINE_SELECTION_EVENT_TYPE before including this file."
+#endif
+
+DEFINE_SELECTION_EVENT_TYPE(SELECTION_SHOWN, 0)
+DEFINE_SELECTION_EVENT_TYPE(SELECTION_CLEARED, 1)
+DEFINE_SELECTION_EVENT_TYPE(SELECTION_DRAG_STARTED, 2)
+DEFINE_SELECTION_EVENT_TYPE(SELECTION_DRAG_STOPPED, 3)
+DEFINE_SELECTION_EVENT_TYPE(INSERTION_SHOWN, 4)
+DEFINE_SELECTION_EVENT_TYPE(INSERTION_MOVED, 5)
+DEFINE_SELECTION_EVENT_TYPE(INSERTION_TAPPED, 6)
+DEFINE_SELECTION_EVENT_TYPE(INSERTION_CLEARED, 7)
+DEFINE_SELECTION_EVENT_TYPE(INSERTION_DRAG_STARTED, 8)
diff --git a/content/child/assert_matching_enums.cc b/content/child/assert_matching_enums.cc
index 89ff842..af08746 100644
--- a/content/child/assert_matching_enums.cc
+++ b/content/child/assert_matching_enums.cc
@@ -20,23 +20,23 @@ namespace content {
// ScreenOrientationValues
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockDefault,
- SCREEN_ORIENTATION_VALUES_DEFAULT);
+ DEFAULT);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockPortraitPrimary,
- SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY);
+ PORTRAIT_PRIMARY);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockPortraitSecondary,
- SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY);
+ PORTRAIT_SECONDARY);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockLandscapePrimary,
- SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY);
+ LANDSCAPE_PRIMARY);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockLandscapeSecondary,
- SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY);
+ LANDSCAPE_SECONDARY);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockAny,
- SCREEN_ORIENTATION_VALUES_ANY);
+ ANY);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockLandscape,
- SCREEN_ORIENTATION_VALUES_LANDSCAPE);
+ LANDSCAPE);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockPortrait,
- SCREEN_ORIENTATION_VALUES_PORTRAIT);
+ PORTRAIT);
COMPILE_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockNatural,
- SCREEN_ORIENTATION_VALUES_NATURAL);
+ NATURAL);
// SupportsType
COMPILE_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::IsNotSupported,
diff --git a/content/content.gyp b/content/content.gyp
index 388ada8c..1ed85be 100644
--- a/content/content.gyp
+++ b/content/content.gyp
@@ -464,68 +464,88 @@
],
},
{
- 'target_name': 'content_gamepad_mapping',
- 'type': 'none',
- 'variables': {
- 'source_file': 'browser/gamepad/gamepad_standard_mappings.h',
- },
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
- },
- {
'target_name': 'gesture_event_type_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/browser/GestureEventType.template',
+ ],
'variables': {
- 'source_file': 'browser/android/gesture_event_type.h',
+ 'package_name': 'org/chromium/content/browser',
+ 'template_deps': ['browser/android/gesture_event_type_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'popup_item_type_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/browser/input/PopupItemType.template',
+ ],
'variables': {
- 'source_file': 'browser/android/content_view_core_impl.cc',
+ 'package_name': 'org/chromium/content/browser/input',
+ 'template_deps': ['browser/android/popup_item_type_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'result_codes_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/common/ResultCodes.template',
+ ],
'variables': {
- 'source_file': 'public/common/result_codes.h',
+ 'package_name': 'org/chromium/content/common',
+ 'template_deps': ['public/common/result_codes_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'selection_event_type_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/browser/input/SelectionEventType.template',
+ ],
'variables': {
- 'source_file': 'browser/renderer_host/input/selection_event_type.h',
+ 'package_name': 'org/chromium/content/browser/input',
+ 'template_deps': ['browser/renderer_host/input/selection_event_type_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'speech_recognition_error_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/browser/SpeechRecognitionError.template',
+ ],
'variables': {
- 'source_file': 'public/common/speech_recognition_error.h',
+ 'package_name': 'org/chromium/content/browser',
+ 'template_deps': ['public/common/speech_recognition_error_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'top_controls_state_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/common/TopControlsState.template',
+ ],
'variables': {
- 'source_file': 'public/common/top_controls_state.h',
+ 'package_name': 'org/chromium/content/common',
+ 'template_deps': ['public/common/top_controls_state_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'screen_orientation_values_java',
'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content_public/common/ScreenOrientationValues.template',
+ ],
'variables': {
- 'source_file': 'public/common/screen_orientation_values.h',
+ 'package_name': 'org/chromium/content_public/common',
+ 'template_deps': ['public/common/screen_orientation_values_list.h'],
},
- 'includes': [ '../build/android/java_cpp_enum.gypi' ],
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
},
{
'target_name': 'java_set_jni_headers',
@@ -570,6 +590,22 @@
}],
],
},
+ {
+ 'target_name': 'content_gamepad_mapping',
+ 'type': 'none',
+ 'sources': [
+ 'public/android/java/src/org/chromium/content/browser/input/CanonicalButtonIndex.template',
+ 'public/android/java/src/org/chromium/content/browser/input/CanonicalAxisIndex.template',
+ ],
+ 'variables': {
+ 'package_name': 'org/chromium/content/browser/input',
+ 'template_deps': [
+ 'browser/gamepad/canonical_axis_index_list.h',
+ 'browser/gamepad/canonical_button_index_list.h',
+ ],
+ },
+ 'includes': [ '../build/android/java_cpp_template.gypi' ],
+ },
],
}], # OS == "android"
],
diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn
index 19340b8..81615c3 100644
--- a/content/public/android/BUILD.gn
+++ b/content/public/android/BUILD.gn
@@ -42,7 +42,14 @@ android_library("content_java") {
srcjar_deps = [
":common_aidl",
- ":content_public_android_java_enums_srcjar",
+ ":content_gamepad_mapping_java",
+ ":gesture_event_type_java",
+ ":popup_item_type_java",
+ ":result_codes_java",
+ ":selection_event_type_java",
+ ":speech_recognition_error_java",
+ ":top_controls_state_java",
+ ":screen_orientation_values_java",
]
DEPRECATED_java_in_dir = "java/src"
@@ -103,27 +110,85 @@ java_strings_grd("content_strings_grd") {
]
}
-java_cpp_enum("content_public_android_java_enums_srcjar") {
+java_cpp_template("gesture_event_type_java") {
sources = [
- "//content/browser/android/content_view_core_impl.cc",
- "//content/browser/android/gesture_event_type.h",
- "//content/browser/renderer_host/input/selection_event_type.h",
- "//content/browser/gamepad/gamepad_standard_mappings.h",
- "//content/public/common/result_codes.h",
- "//content/public/common/screen_orientation_values.h",
- "//content/public/common/speech_recognition_error.h",
- "//content/public/common/top_controls_state.h",
+ "java/src/org/chromium/content/browser/GestureEventType.template",
]
- outputs = [
- "org/chromium/content/browser/GestureEventType.java",
- "org/chromium/content/browser/input/CanonicalAxisIndex.java",
- "org/chromium/content/browser/input/CanonicalButtonIndex.java",
- "org/chromium/content/browser/input/PopupItemType.java",
- "org/chromium/content/browser/input/SelectionEventType.java",
- "org/chromium/content_public/common/ResultCode.java",
- "org/chromium/content_public/common/ScreenOrientationValues.java",
- "org/chromium/content_public/common/SpeechRecognitionErrorCode.java",
- "org/chromium/content_public/common/TopControlsState.java",
+ package_name = "org/chromium/content/browser"
+ inputs = [
+ "//content/browser/android/gesture_event_type_list.h"
+ ]
+}
+
+java_cpp_template("popup_item_type_java") {
+ sources = [
+ "java/src/org/chromium/content/browser/input/PopupItemType.template",
+ ]
+ package_name = "org/chromium/content/browser/input"
+ inputs = [
+ "//content/browser/android/popup_item_type_list.h"
+ ]
+}
+
+java_cpp_template("result_codes_java") {
+ sources = [
+ "java/src/org/chromium/content/common/ResultCodes.template",
+ ]
+ package_name = "org/chromium/content/common"
+ inputs = [
+ "//content/public/common/result_codes_list.h"
+ ]
+}
+
+java_cpp_template("selection_event_type_java") {
+ sources = [
+ "java/src/org/chromium/content/browser/input/SelectionEventType.template",
+ ]
+ package_name = "org/chromium/content/browser/input"
+ inputs = [
+ "//content/browser/renderer_host/input/selection_event_type_list.h"
+ ]
+}
+
+java_cpp_template("speech_recognition_error_java") {
+ sources = [
+ "java/src/org/chromium/content/browser/SpeechRecognitionError.template",
+ ]
+ package_name = "org/chromium/content/browser"
+ inputs = [
+ "//content/public/common/speech_recognition_error_list.h"
+ ]
+}
+
+java_cpp_template("top_controls_state_java") {
+ sources = [
+ "java/src/org/chromium/content/common/TopControlsState.template",
+ ]
+ package_name = "org/chromium/content/common"
+ inputs = [
+ "//content/public/common/top_controls_state_list.h"
+ ]
+}
+
+java_cpp_template("screen_orientation_values_java") {
+ sources = [
+ "java/src/org/chromium/content_public/common/ScreenOrientationValues.template",
+ ]
+ package_name = "org/chromium/content_public/common"
+ inputs = [
+ "//content/public/common/screen_orientation_values_list.h"
+ ]
+}
+
+java_cpp_template("content_gamepad_mapping_java") {
+ sources = [
+ "java/src/org/chromium/content/browser/input/CanonicalAxisIndex.template",
+ "java/src/org/chromium/content/browser/input/CanonicalButtonIndex.template",
+ ]
+ package_name = "org/chromium/content/common"
+ inputs = [
+ "//content/browser/gamepad/canonical_axis_index_list.h",
+ "//content/browser/gamepad/canonical_button_index_list.h",
]
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/GestureEventType.template b/content/public/android/java/src/org/chromium/content/browser/GestureEventType.template
new file mode 100644
index 0000000..ba116f9
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/GestureEventType.template
@@ -0,0 +1,13 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+public class GestureEventType {
+#define DEFINE_GESTURE_EVENT_TYPE(name, value) \
+ public static final int name = value;
+#include "content/browser/android/gesture_event_type_list.h"
+#undef DEFINE_GESTURE_EVENT_TYPE
+}
+
diff --git a/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java b/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
index 77d60e57..7df3c65 100644
--- a/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
+++ b/content/public/android/java/src/org/chromium/content/browser/SpeechRecognition.java
@@ -19,7 +19,6 @@ import android.speech.SpeechRecognizer;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
-import org.chromium.content_public.common.SpeechRecognitionErrorCode;
import java.util.ArrayList;
import java.util.List;
@@ -90,30 +89,30 @@ public class SpeechRecognition {
@Override
public void onError(int error) {
- int code = SpeechRecognitionErrorCode.NONE;
+ int code = SpeechRecognitionError.NONE;
// Translate Android SpeechRecognizer errors to Web Speech API errors.
switch(error) {
case SpeechRecognizer.ERROR_AUDIO:
- code = SpeechRecognitionErrorCode.AUDIO;
+ code = SpeechRecognitionError.AUDIO;
break;
case SpeechRecognizer.ERROR_CLIENT:
- code = SpeechRecognitionErrorCode.ABORTED;
+ code = SpeechRecognitionError.ABORTED;
break;
case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
- code = SpeechRecognitionErrorCode.NOT_ALLOWED;
+ code = SpeechRecognitionError.NOT_ALLOWED;
break;
case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
case SpeechRecognizer.ERROR_NETWORK:
case SpeechRecognizer.ERROR_SERVER:
- code = SpeechRecognitionErrorCode.NETWORK;
+ code = SpeechRecognitionError.NETWORK;
break;
case SpeechRecognizer.ERROR_NO_MATCH:
- code = SpeechRecognitionErrorCode.NO_MATCH;
+ code = SpeechRecognitionError.NO_MATCH;
break;
case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
- code = SpeechRecognitionErrorCode.NO_SPEECH;
+ code = SpeechRecognitionError.NO_SPEECH;
break;
default:
assert false;
@@ -143,7 +142,7 @@ public class SpeechRecognition {
// We assume that onResults is called only once, at the end of a session, thus we
// terminate. If one day the recognition provider changes dictation mode behavior to
// call onResults several times, we should terminate only if (!mContinuous).
- terminate(SpeechRecognitionErrorCode.NONE);
+ terminate(SpeechRecognitionError.NONE);
}
@Override
@@ -238,7 +237,7 @@ public class SpeechRecognition {
mState = STATE_IDLE;
}
- if (error != SpeechRecognitionErrorCode.NONE)
+ if (error != SpeechRecognitionError.NONE)
nativeOnRecognitionError(mNativeSpeechRecognizerImplAndroid, error);
mRecognizer.destroy();
@@ -271,7 +270,7 @@ public class SpeechRecognition {
return;
mRecognizer.cancel();
- terminate(SpeechRecognitionErrorCode.ABORTED);
+ terminate(SpeechRecognitionError.ABORTED);
}
@CalledByNative
diff --git a/content/public/android/java/src/org/chromium/content/browser/SpeechRecognitionError.template b/content/public/android/java/src/org/chromium/content/browser/SpeechRecognitionError.template
new file mode 100644
index 0000000..d3a7074
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/SpeechRecognitionError.template
@@ -0,0 +1,11 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+public class SpeechRecognitionError {
+#define DEFINE_SPEECH_RECOGNITION_ERROR(x,y) public static final int x = y;
+#include "content/public/common/speech_recognition_error_list.h"
+#undef DEFINE_SPEECH_RECOGNITION_ERROR
+}
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/GamepadDevice.java b/content/public/android/java/src/org/chromium/content/browser/input/GamepadDevice.java
index 9665dc0..ca534bf 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/GamepadDevice.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/GamepadDevice.java
@@ -30,9 +30,9 @@ class GamepadDevice {
// All axis values must be linearly normalized to the range [-1.0 .. 1.0].
// As appropriate, -1.0 should correspond to "up" or "left", and 1.0
// should correspond to "down" or "right".
- private final float[] mAxisValues = new float[CanonicalAxisIndex.COUNT];
+ private final float[] mAxisValues = new float[CanonicalAxisIndex.NUM_CANONICAL_AXES];
- private final float[] mButtonsValues = new float[CanonicalButtonIndex.COUNT];;
+ private final float[] mButtonsValues = new float[CanonicalButtonIndex.NUM_CANONICAL_BUTTONS];;
// When the user agent recognizes the attached inputDevice, it is recommended
// that it be remapped to a canonical ordering when possible. Devices that are
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/GamepadMappings.java b/content/public/android/java/src/org/chromium/content/browser/input/GamepadMappings.java
index 5fe418f..99e28f9 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/GamepadMappings.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/GamepadMappings.java
@@ -45,10 +45,10 @@ class GamepadMappings {
float b = rawButtons[KeyEvent.KEYCODE_BUTTON_B];
float x = rawButtons[KeyEvent.KEYCODE_BUTTON_X];
float y = rawButtons[KeyEvent.KEYCODE_BUTTON_Y];
- mappedButtons[CanonicalButtonIndex.PRIMARY] = a;
- mappedButtons[CanonicalButtonIndex.SECONDARY] = b;
- mappedButtons[CanonicalButtonIndex.TERTIARY] = x;
- mappedButtons[CanonicalButtonIndex.QUATERNARY] = y;
+ mappedButtons[CanonicalButtonIndex.BUTTON_PRIMARY] = a;
+ mappedButtons[CanonicalButtonIndex.BUTTON_SECONDARY] = b;
+ mappedButtons[CanonicalButtonIndex.BUTTON_TERTIARY] = x;
+ mappedButtons[CanonicalButtonIndex.BUTTON_QUATERNARY] = y;
}
private static void mapCommonStartSelectMetaButtons(
@@ -56,23 +56,23 @@ class GamepadMappings {
float start = rawButtons[KeyEvent.KEYCODE_BUTTON_START];
float select = rawButtons[KeyEvent.KEYCODE_BUTTON_SELECT];
float mode = rawButtons[KeyEvent.KEYCODE_BUTTON_MODE];
- mappedButtons[CanonicalButtonIndex.START] = start;
- mappedButtons[CanonicalButtonIndex.BACK_SELECT] = select;
- mappedButtons[CanonicalButtonIndex.META] = mode;
+ mappedButtons[CanonicalButtonIndex.BUTTON_START] = start;
+ mappedButtons[CanonicalButtonIndex.BUTTON_BACK_SELECT] = select;
+ mappedButtons[CanonicalButtonIndex.BUTTON_META] = mode;
}
private static void mapCommonThumbstickButtons(float[] mappedButtons, float[] rawButtons) {
float thumbL = rawButtons[KeyEvent.KEYCODE_BUTTON_THUMBL];
float thumbR = rawButtons[KeyEvent.KEYCODE_BUTTON_THUMBR];
- mappedButtons[CanonicalButtonIndex.LEFT_THUMBSTICK] = thumbL;
- mappedButtons[CanonicalButtonIndex.RIGHT_THUMBSTICK] = thumbR;
+ mappedButtons[CanonicalButtonIndex.BUTTON_LEFT_THUMBSTICK] = thumbL;
+ mappedButtons[CanonicalButtonIndex.BUTTON_RIGHT_THUMBSTICK] = thumbR;
}
private static void mapCommonTriggerButtons(float[] mappedButtons, float[] rawButtons) {
float l1 = rawButtons[KeyEvent.KEYCODE_BUTTON_L1];
float r1 = rawButtons[KeyEvent.KEYCODE_BUTTON_R1];
- mappedButtons[CanonicalButtonIndex.LEFT_TRIGGER] = l1;
- mappedButtons[CanonicalButtonIndex.RIGHT_TRIGGER] = r1;
+ mappedButtons[CanonicalButtonIndex.BUTTON_LEFT_TRIGGER] = l1;
+ mappedButtons[CanonicalButtonIndex.BUTTON_RIGHT_TRIGGER] = r1;
}
private static void mapCommonDpadButtons(float[] mappedButtons, float[] rawButtons) {
@@ -80,32 +80,32 @@ class GamepadMappings {
float dpadUp = rawButtons[KeyEvent.KEYCODE_DPAD_UP];
float dpadLeft = rawButtons[KeyEvent.KEYCODE_DPAD_LEFT];
float dpadRight = rawButtons[KeyEvent.KEYCODE_DPAD_RIGHT];
- mappedButtons[CanonicalButtonIndex.DPAD_DOWN] = dpadDown;
- mappedButtons[CanonicalButtonIndex.DPAD_UP] = dpadUp;
- mappedButtons[CanonicalButtonIndex.DPAD_LEFT] = dpadLeft;
- mappedButtons[CanonicalButtonIndex.DPAD_RIGHT] = dpadRight;
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_DOWN] = dpadDown;
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_UP] = dpadUp;
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_LEFT] = dpadLeft;
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_RIGHT] = dpadRight;
}
private static void mapXYAxes(float[] mappedAxes, float[] rawAxes) {
- mappedAxes[CanonicalAxisIndex.LEFT_STICK_X] = rawAxes[MotionEvent.AXIS_X];
- mappedAxes[CanonicalAxisIndex.LEFT_STICK_Y] = rawAxes[MotionEvent.AXIS_Y];
+ mappedAxes[CanonicalAxisIndex.AXIS_LEFT_STICK_X] = rawAxes[MotionEvent.AXIS_X];
+ mappedAxes[CanonicalAxisIndex.AXIS_LEFT_STICK_Y] = rawAxes[MotionEvent.AXIS_Y];
}
private static void mapRXAndRYAxesToRightStick(float[] mappedAxes, float[] rawAxes) {
- mappedAxes[CanonicalAxisIndex.RIGHT_STICK_X] = rawAxes[MotionEvent.AXIS_RX];
- mappedAxes[CanonicalAxisIndex.RIGHT_STICK_Y] = rawAxes[MotionEvent.AXIS_RY];
+ mappedAxes[CanonicalAxisIndex.AXIS_RIGHT_STICK_X] = rawAxes[MotionEvent.AXIS_RX];
+ mappedAxes[CanonicalAxisIndex.AXIS_RIGHT_STICK_Y] = rawAxes[MotionEvent.AXIS_RY];
}
private static void mapZAndRZAxesToRightStick(float[] mappedAxes, float[] rawAxes) {
- mappedAxes[CanonicalAxisIndex.RIGHT_STICK_X] = rawAxes[MotionEvent.AXIS_Z];
- mappedAxes[CanonicalAxisIndex.RIGHT_STICK_Y] = rawAxes[MotionEvent.AXIS_RZ];
+ mappedAxes[CanonicalAxisIndex.AXIS_RIGHT_STICK_X] = rawAxes[MotionEvent.AXIS_Z];
+ mappedAxes[CanonicalAxisIndex.AXIS_RIGHT_STICK_Y] = rawAxes[MotionEvent.AXIS_RZ];
}
private static void mapTriggerAxexToShoulderButtons(float[] mappedButtons, float[] rawAxes) {
float lTrigger = rawAxes[MotionEvent.AXIS_LTRIGGER];
float rTrigger = rawAxes[MotionEvent.AXIS_RTRIGGER];
- mappedButtons[CanonicalButtonIndex.LEFT_SHOULDER] = lTrigger;
- mappedButtons[CanonicalButtonIndex.RIGHT_SHOULDER] = rTrigger;
+ mappedButtons[CanonicalButtonIndex.BUTTON_LEFT_SHOULDER] = lTrigger;
+ mappedButtons[CanonicalButtonIndex.BUTTON_RIGHT_SHOULDER] = rTrigger;
}
private static float negativeAxisValueAsButton(float input) {
@@ -119,10 +119,10 @@ class GamepadMappings {
private static void mapHatAxisToDpadButtons(float[] mappedButtons, float[] rawAxes) {
float hatX = rawAxes[MotionEvent.AXIS_HAT_X];
float hatY = rawAxes[MotionEvent.AXIS_HAT_Y];
- mappedButtons[CanonicalButtonIndex.DPAD_LEFT] = negativeAxisValueAsButton(hatX);
- mappedButtons[CanonicalButtonIndex.DPAD_RIGHT] = positiveAxisValueAsButton(hatX);
- mappedButtons[CanonicalButtonIndex.DPAD_UP] = negativeAxisValueAsButton(hatY);
- mappedButtons[CanonicalButtonIndex.DPAD_DOWN] = positiveAxisValueAsButton(hatY);
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_LEFT] = negativeAxisValueAsButton(hatX);
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_RIGHT] = positiveAxisValueAsButton(hatX);
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_UP] = negativeAxisValueAsButton(hatY);
+ mappedButtons[CanonicalButtonIndex.BUTTON_DPAD_DOWN] = positiveAxisValueAsButton(hatY);
}
/**
@@ -159,10 +159,10 @@ class GamepadMappings {
float b = rawButtons[KeyEvent.KEYCODE_BUTTON_B];
float x = rawButtons[KeyEvent.KEYCODE_BUTTON_X];
float y = rawButtons[KeyEvent.KEYCODE_BUTTON_Y];
- mappedButtons[CanonicalButtonIndex.PRIMARY] = x;
- mappedButtons[CanonicalButtonIndex.SECONDARY] = y;
- mappedButtons[CanonicalButtonIndex.TERTIARY] = a;
- mappedButtons[CanonicalButtonIndex.QUATERNARY] = b;
+ mappedButtons[CanonicalButtonIndex.BUTTON_PRIMARY] = x;
+ mappedButtons[CanonicalButtonIndex.BUTTON_SECONDARY] = y;
+ mappedButtons[CanonicalButtonIndex.BUTTON_TERTIARY] = a;
+ mappedButtons[CanonicalButtonIndex.BUTTON_QUATERNARY] = b;
mapCommonTriggerButtons(mappedButtons, rawButtons);
mapCommonThumbstickButtons(mappedButtons, rawButtons);
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/SelectionEventType.template b/content/public/android/java/src/org/chromium/content/browser/input/SelectionEventType.template
new file mode 100644
index 0000000..673e966
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/input/SelectionEventType.template
@@ -0,0 +1,13 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser.input;
+
+public class SelectionEventType {
+#define DEFINE_SELECTION_EVENT_TYPE(name, value) \
+ public static final int name = value;
+#include "content/browser/renderer_host/input/selection_event_type_list.h"
+#undef DEFINE_SELECTION_EVENT_TYPE
+}
+
diff --git a/content/public/android/java/src/org/chromium/content/common/ResultCodes.template b/content/public/android/java/src/org/chromium/content/common/ResultCodes.template
new file mode 100644
index 0000000..5670b92
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/common/ResultCodes.template
@@ -0,0 +1,13 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.common;
+
+public class ResultCodes {
+#define RESULT_CODE(label, value) public static final int \
+ RESULT_CODE_ ## label = value;
+#include "content/public/common/result_codes_list.h"
+#undef RESULT_CODE
+}
+
diff --git a/content/public/android/java/src/org/chromium/content/common/TopControlsState.template b/content/public/android/java/src/org/chromium/content/common/TopControlsState.template
new file mode 100644
index 0000000..65e0414
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/common/TopControlsState.template
@@ -0,0 +1,12 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.common;
+
+public class TopControlsState {
+#define DEFINE_TOP_CONTROLS_STATE(name, value) public static final int name = value;
+#include "content/public/common/top_controls_state_list.h"
+#undef DEFINE_TOP_CONTROLS_STATE
+}
+
diff --git a/content/public/common/result_codes.h b/content/public/common/result_codes.h
index d0963a3b..1bf625d 100644
--- a/content/public/common/result_codes.h
+++ b/content/public/common/result_codes.h
@@ -7,30 +7,11 @@
namespace content {
-// This file consolidates all the return codes for the browser and renderer
-// process. The return code is the value that:
-// a) is returned by main() or winmain(), or
-// b) specified in the call for ExitProcess() or TerminateProcess(), or
-// c) the exception value that causes a process to terminate.
-//
-// It is advisable to not use negative numbers because the Windows API returns
-// it as an unsigned long and the exception values have high numbers. For
-// example EXCEPTION_ACCESS_VIOLATION value is 0xC0000005.
-//
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content_public.common
enum ResultCode {
- // Process terminated normally.
- RESULT_CODE_NORMAL_EXIT,
- // Process was killed by user or system.
- RESULT_CODE_KILLED,
-
- // Process hung.
- RESULT_CODE_HUNG,
-
- // A bad message caused the process termination.
- RESULT_CODE_KILLED_BAD_MESSAGE,
+#define RESULT_CODE(label, value) RESULT_CODE_ ## label = value,
+#include "content/public/common/result_codes_list.h"
+#undef RESULT_CODE
// Last return code (keep this last).
RESULT_CODE_LAST_CODE
diff --git a/content/public/common/result_codes_list.h b/content/public/common/result_codes_list.h
new file mode 100644
index 0000000..589fb45
--- /dev/null
+++ b/content/public/common/result_codes_list.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Intentionally no include guards because this file is meant to be included
+// inside a macro to generate enum values.
+
+// This file consolidates all the return codes for the browser and renderer
+// process. The return code is the value that:
+// a) is returned by main() or winmain(), or
+// b) specified in the call for ExitProcess() or TerminateProcess(), or
+// c) the exception value that causes a process to terminate.
+//
+// It is advisable to not use negative numbers because the Windows API returns
+// it as an unsigned long and the exception values have high numbers. For
+// example EXCEPTION_ACCESS_VIOLATION value is 0xC0000005.
+
+#include "build/build_config.h"
+
+// Process terminated normally.
+RESULT_CODE(NORMAL_EXIT, 0)
+
+// Process was killed by user or system.
+RESULT_CODE(KILLED, 1)
+
+// Process hung.
+RESULT_CODE(HUNG, 2)
+
+// A bad message caused the process termination.
+RESULT_CODE(KILLED_BAD_MESSAGE, 3)
diff --git a/content/public/common/screen_orientation_values.h b/content/public/common/screen_orientation_values.h
index 422344d..fe421a2 100644
--- a/content/public/common/screen_orientation_values.h
+++ b/content/public/common/screen_orientation_values.h
@@ -7,18 +7,10 @@
namespace content {
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content_public.common
enum ScreenOrientationValues {
- SCREEN_ORIENTATION_VALUES_DEFAULT,
- SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY,
- SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY,
- SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY,
- SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY,
- SCREEN_ORIENTATION_VALUES_ANY,
- SCREEN_ORIENTATION_VALUES_LANDSCAPE,
- SCREEN_ORIENTATION_VALUES_PORTRAIT,
- SCREEN_ORIENTATION_VALUES_NATURAL,
+#define DEFINE_SCREEN_ORIENTATION_VALUE(name, value) name = value,
+#include "content/public/common/screen_orientation_values_list.h"
+#undef DEFINE_SCREEN_ORIENTATION_VALUE
};
} // namespace content
diff --git a/content/public/common/screen_orientation_values_list.h b/content/public/common/screen_orientation_values_list.h
new file mode 100644
index 0000000..46ef678
--- /dev/null
+++ b/content/public/common/screen_orientation_values_list.h
@@ -0,0 +1,24 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_VALUES_LIST_H_
+#define CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_VALUES_LIST_H_
+
+#ifndef DEFINE_SCREEN_ORIENTATION_VALUE
+#error "DEFINE_SCREEN_ORIENTATION_VALUE should be defined before including this"
+#endif
+
+// These values are defined with macros so that a Java class can be generated
+// for them.
+DEFINE_SCREEN_ORIENTATION_VALUE(DEFAULT, 0)
+DEFINE_SCREEN_ORIENTATION_VALUE(PORTRAIT_PRIMARY, 1)
+DEFINE_SCREEN_ORIENTATION_VALUE(PORTRAIT_SECONDARY, 2)
+DEFINE_SCREEN_ORIENTATION_VALUE(LANDSCAPE_PRIMARY, 3)
+DEFINE_SCREEN_ORIENTATION_VALUE(LANDSCAPE_SECONDARY, 4)
+DEFINE_SCREEN_ORIENTATION_VALUE(ANY, 5)
+DEFINE_SCREEN_ORIENTATION_VALUE(LANDSCAPE, 6)
+DEFINE_SCREEN_ORIENTATION_VALUE(PORTRAIT, 7)
+DEFINE_SCREEN_ORIENTATION_VALUE(NATURAL, 8)
+
+#endif // CONTENT_PUBLIC_COMMON_SCREEN_ORIENTATION_VALUES_LIST_H_
diff --git a/content/public/common/speech_recognition_error.h b/content/public/common/speech_recognition_error.h
index bbd73c7..a12bc40 100644
--- a/content/public/common/speech_recognition_error.h
+++ b/content/public/common/speech_recognition_error.h
@@ -7,34 +7,10 @@
namespace content {
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content_public.common
-// GENERATED_JAVA_PREFIX_TO_STRIP: SPEECH_RECOGNITION_ERROR_
enum SpeechRecognitionErrorCode {
- // There was no error.
- SPEECH_RECOGNITION_ERROR_NONE,
-
- // The user or a script aborted speech input.
- SPEECH_RECOGNITION_ERROR_ABORTED,
-
- // There was an error with recording audio.
- SPEECH_RECOGNITION_ERROR_AUDIO,
-
- // There was a network error.
- SPEECH_RECOGNITION_ERROR_NETWORK,
-
- // Not allowed for privacy or security reasons.
- SPEECH_RECOGNITION_ERROR_NOT_ALLOWED,
-
- // No speech heard before timeout.
- SPEECH_RECOGNITION_ERROR_NO_SPEECH,
-
- // Speech was heard, but could not be interpreted.
- SPEECH_RECOGNITION_ERROR_NO_MATCH,
-
- // There was an error in the speech recognition grammar.
- SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR,
- SPEECH_RECOGNITION_ERROR_LAST = SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR,
+#define DEFINE_SPEECH_RECOGNITION_ERROR(x, y) SPEECH_RECOGNITION_ERROR_##x = y,
+#include "content/public/common/speech_recognition_error_list.h"
+#undef DEFINE_SPEECH_RECOGNITION_ERROR
};
// Error details for the SPEECH_RECOGNITION_ERROR_AUDIO error.
diff --git a/content/public/common/speech_recognition_error_list.h b/content/public/common/speech_recognition_error_list.h
new file mode 100644
index 0000000..8a9614e
--- /dev/null
+++ b/content/public/common/speech_recognition_error_list.h
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards, it's included
+// inside a macro to generate enum values.
+
+#ifndef DEFINE_SPEECH_RECOGNITION_ERROR
+#error "DEFINE_SPEECH_RECOGNITION_ERROR must be defined before including this."
+#endif
+
+// There was no error.
+DEFINE_SPEECH_RECOGNITION_ERROR(NONE, 0)
+
+// The user or a script aborted speech input.
+DEFINE_SPEECH_RECOGNITION_ERROR(ABORTED, 1)
+
+// There was an error with recording audio.
+DEFINE_SPEECH_RECOGNITION_ERROR(AUDIO, 2)
+
+// There was a network error.
+DEFINE_SPEECH_RECOGNITION_ERROR(NETWORK, 3)
+
+// Not allowed for privacy or security reasons.
+DEFINE_SPEECH_RECOGNITION_ERROR(NOT_ALLOWED, 4)
+
+// No speech heard before timeout.
+DEFINE_SPEECH_RECOGNITION_ERROR(NO_SPEECH, 5)
+
+// Speech was heard, but could not be interpreted.
+DEFINE_SPEECH_RECOGNITION_ERROR(NO_MATCH, 6)
+
+// There was an error in the speech recognition grammar.
+DEFINE_SPEECH_RECOGNITION_ERROR(BAD_GRAMMAR, 7)
+
+// Reports the highest value. Update when adding a new error code.
+DEFINE_SPEECH_RECOGNITION_ERROR(LAST, 7)
+
diff --git a/content/public/common/top_controls_state.h b/content/public/common/top_controls_state.h
index 7f71e6e..31535a0 100644
--- a/content/public/common/top_controls_state.h
+++ b/content/public/common/top_controls_state.h
@@ -7,12 +7,10 @@
namespace content {
-// A Java counterpart will be generated for this enum.
-// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.content_public.common
enum TopControlsState {
- TOP_CONTROLS_STATE_SHOWN = 1,
- TOP_CONTROLS_STATE_HIDDEN = 2,
- TOP_CONTROLS_STATE_BOTH = 3,
+#define DEFINE_TOP_CONTROLS_STATE(name, value) name = value,
+#include "content/public/common/top_controls_state_list.h"
+#undef DEFINE_TOP_CONTROLS_STATE
};
} // namespace content
diff --git a/content/public/common/top_controls_state_list.h b/content/public/common/top_controls_state_list.h
new file mode 100644
index 0000000..c740304
--- /dev/null
+++ b/content/public/common/top_controls_state_list.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_COMMON_TOP_CONTROLS_STATE_LIST_H_
+#define CONTENT_PUBLIC_COMMON_TOP_CONTROLS_STATE_LIST_H_
+
+#ifndef DEFINE_TOP_CONTROLS_STATE
+#error "DEFINE_TOP_CONTROLS_STATE should be defined before including this file"
+#endif
+
+// These values are defined with macros so that a Java class can be generated
+// for them.
+DEFINE_TOP_CONTROLS_STATE(SHOWN, 1)
+DEFINE_TOP_CONTROLS_STATE(HIDDEN, 2)
+DEFINE_TOP_CONTROLS_STATE(BOTH, 3)
+
+#endif // CONTENT_PUBLIC_COMMON_TOP_CONTROLS_STATE_LIST_H_
+
diff --git a/content/renderer/render_view_impl_android.cc b/content/renderer/render_view_impl_android.cc
index 50b10aa..57d1920f5 100644
--- a/content/renderer/render_view_impl_android.cc
+++ b/content/renderer/render_view_impl_android.cc
@@ -14,12 +14,9 @@
namespace content {
// Check content::TopControlsState and cc::TopControlsState are kept in sync.
-COMPILE_ASSERT(int(TOP_CONTROLS_STATE_SHOWN) == int(cc::SHOWN),
- mismatching_enums);
-COMPILE_ASSERT(int(TOP_CONTROLS_STATE_HIDDEN) == int(cc::HIDDEN),
- mismatching_enums);
-COMPILE_ASSERT(int(TOP_CONTROLS_STATE_BOTH) == int(cc::BOTH),
- mismatching_enums);
+COMPILE_ASSERT(int(SHOWN) == int(cc::SHOWN), mismatching_enums);
+COMPILE_ASSERT(int(HIDDEN) == int(cc::HIDDEN), mismatching_enums);
+COMPILE_ASSERT(int(BOTH) == int(cc::BOTH), mismatching_enums);
cc::TopControlsState ContentToCcTopControlsState(
TopControlsState state) {