Commit 2a816fed authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

exo: gamepad: Send raw scancode to ARC

This CL modifies exo to send raw gamepad scancode to ARC when
ExoRawGamepadInfo is enabled. ARC can identify if it's raw scancode
by whether the gamepad was initialized by gamepad_added or
gamepad_added_with_device_info.

Previously, Exo was sending Web Gamepad keycode to ARC, but this will be
deprecated as a part of the effort to improve ARC Gampad compatibility.
Design doc: go/arc-improved-gamepad

TEST=manual(--enable-features=ExoRawGamepadInfo to /etc/chrome_dev.conf)
BUG=b:130597086

Change-Id: Ied4da69655623a243b9e1caa681212138d46918e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612857Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661276}
parent 5b818b54
...@@ -15,11 +15,14 @@ class GamepadDelegate { ...@@ -15,11 +15,14 @@ class GamepadDelegate {
// Called when the user moved an axis of the gamepad. Valid axes are defined // Called when the user moved an axis of the gamepad. Valid axes are defined
// by the W3C 'standard gamepad' specification. // by the W3C 'standard gamepad' specification.
virtual void OnAxis(int axis, double value) = 0; virtual void OnAxis(int axis, int raw_axis, double value) = 0;
// Called when the user pressed or moved a button of the gamepad. // Called when the user pressed or moved a button of the gamepad.
// Valid buttons are defined by the W3C 'standard gamepad' specification. // Valid buttons are defined by the W3C 'standard gamepad' specification.
virtual void OnButton(int button, bool pressed, double value) = 0; virtual void OnButton(int button,
int raw_button,
bool pressed,
double value) = 0;
// Called after all gamepad information of this frame has been set and the // Called after all gamepad information of this frame has been set and the
// client should evaluate the updated state. // client should evaluate the updated state.
......
...@@ -97,10 +97,11 @@ void GamingSeat::OnGamepadEvent(const ui::GamepadEvent& event) { ...@@ -97,10 +97,11 @@ void GamingSeat::OnGamepadEvent(const ui::GamepadEvent& event) {
switch (event.type()) { switch (event.type()) {
case ui::GamepadEventType::BUTTON: case ui::GamepadEventType::BUTTON:
it->second->OnButton(event.code(), event.value(), event.value()); it->second->OnButton(event.code(), event.raw_code(), event.value(),
event.value());
break; break;
case ui::GamepadEventType::AXIS: case ui::GamepadEventType::AXIS:
it->second->OnAxis(event.code(), event.value()); it->second->OnAxis(event.code(), event.raw_code(), event.value());
break; break;
case ui::GamepadEventType::FRAME: case ui::GamepadEventType::FRAME:
it->second->OnFrame(); it->second->OnFrame();
......
...@@ -37,8 +37,8 @@ class MockGamepadDelegate : public GamepadDelegate { ...@@ -37,8 +37,8 @@ class MockGamepadDelegate : public GamepadDelegate {
// Overridden from GamepadDelegate: // Overridden from GamepadDelegate:
MOCK_METHOD0(OnRemoved, void()); MOCK_METHOD0(OnRemoved, void());
MOCK_METHOD2(OnAxis, void(int, double)); MOCK_METHOD3(OnAxis, void(int, int, double));
MOCK_METHOD3(OnButton, void(int, bool, double)); MOCK_METHOD4(OnButton, void(int, int, bool, double));
MOCK_METHOD0(OnFrame, void()); MOCK_METHOD0(OnFrame, void());
}; };
......
...@@ -69,21 +69,28 @@ class WaylandGamepadDelegate : public GamepadDelegate { ...@@ -69,21 +69,28 @@ class WaylandGamepadDelegate : public GamepadDelegate {
wl_resource_set_user_data(gamepad_resource_, nullptr); wl_resource_set_user_data(gamepad_resource_, nullptr);
delete this; delete this;
} }
void OnAxis(int axis, double value) override { void OnAxis(int axis, int raw_axis, double value) override {
if (!gamepad_resource_) { if (!gamepad_resource_) {
return; return;
} }
// TODO(tetsui): Send raw axis index when kRawGamepadInfoFeature is enabled.
zcr_gamepad_v2_send_axis(gamepad_resource_, NowInMilliseconds(), axis, zcr_gamepad_v2_send_axis(gamepad_resource_, NowInMilliseconds(), axis,
wl_fixed_from_double(value)); wl_fixed_from_double(value));
} }
void OnButton(int button, bool pressed, double value) override { void OnButton(int button,
int raw_button,
bool pressed,
double value) override {
if (!gamepad_resource_) { if (!gamepad_resource_) {
return; return;
} }
uint32_t state = pressed ? ZCR_GAMEPAD_V2_BUTTON_STATE_PRESSED uint32_t state = pressed ? ZCR_GAMEPAD_V2_BUTTON_STATE_PRESSED
: ZCR_GAMEPAD_V2_BUTTON_STATE_RELEASED; : ZCR_GAMEPAD_V2_BUTTON_STATE_RELEASED;
zcr_gamepad_v2_send_button(gamepad_resource_, NowInMilliseconds(), button, zcr_gamepad_v2_send_button(
state, wl_fixed_from_double(value)); gamepad_resource_, NowInMilliseconds(),
base::FeatureList::IsEnabled(kRawGamepadInfoFeature) ? raw_button
: button,
state, wl_fixed_from_double(value));
} }
void OnFrame() override { void OnFrame() override {
if (!gamepad_resource_) { if (!gamepad_resource_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment