Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial pass at event mapping #4678

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions ui/ozone/platform/starboard/platform_event_source_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace starboard {
constexpr auto kSbKeyToDomCodeMap = base::MakeFixedFlatMap<SbKey, ui::DomCode>({
// Convenience keys for keyboard support.
{kSbKeySpace, ui::DomCode::MEDIA_PLAY_PAUSE},
// {kSbKeySpace, ui::DomCode::SPACE}, Should this be space or play/pause

// Keys which are used by the Cast SDK.
{kSbKeyReturn, ui::DomCode::ENTER},
Expand Down Expand Up @@ -60,6 +61,141 @@ constexpr auto kSbKeyToDomCodeMap = base::MakeFixedFlatMap<SbKey, ui::DomCode>({
{kSbKeyChannelDown, ui::DomCode::CHANNEL_DOWN},
{kSbKeyClosedCaption, ui::DomCode::CLOSED_CAPTION_TOGGLE},
{kSbKeyRecord, ui::DomCode::MEDIA_RECORD},

// 0-9, a-z
{kSbKey0, ui::DomCode::DIGIT0},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to create a new function of class that is self contained and does the translation. You can add unit test and submit it main.

Take a look at: https://source.chromium.org/chromium/chromium/src/+/main:ui/events/x/x11_event_translation.cc
or
https://source.chromium.org/chromium/chromium/src/+/main:ui/events/fuchsia/pointer_events_handler.cc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, in particular to the unit test part (unit tests for an opinionated mapping can be straightforward, and that's fine).

{kSbKey1, ui::DomCode::DIGIT1},
{kSbKey2, ui::DomCode::DIGIT2},
{kSbKey3, ui::DomCode::DIGIT3},
{kSbKey4, ui::DomCode::DIGIT4},
{kSbKey5, ui::DomCode::DIGIT5},
{kSbKey6, ui::DomCode::DIGIT6},
{kSbKey7, ui::DomCode::DIGIT7},
{kSbKey8, ui::DomCode::DIGIT8},
{kSbKey9, ui::DomCode::DIGIT9},
{kSbKeyA, ui::DomCode::US_A},
{kSbKeyB, ui::DomCode::US_B},
{kSbKeyC, ui::DomCode::US_C},
{kSbKeyD, ui::DomCode::US_D},
{kSbKeyE, ui::DomCode::US_E},
{kSbKeyF, ui::DomCode::US_F},
{kSbKeyG, ui::DomCode::US_G},
{kSbKeyH, ui::DomCode::US_H},
{kSbKeyI, ui::DomCode::US_I},
{kSbKeyJ, ui::DomCode::US_J},
{kSbKeyK, ui::DomCode::US_K},
{kSbKeyL, ui::DomCode::US_L},
{kSbKeyM, ui::DomCode::US_M},
{kSbKeyN, ui::DomCode::US_N},
{kSbKeyO, ui::DomCode::US_O},
{kSbKeyP, ui::DomCode::US_P},
{kSbKeyQ, ui::DomCode::US_Q},
{kSbKeyR, ui::DomCode::US_R},
{kSbKeyS, ui::DomCode::US_S},
{kSbKeyT, ui::DomCode::US_T},
{kSbKeyU, ui::DomCode::US_U},
{kSbKeyV, ui::DomCode::US_V},
{kSbKeyW, ui::DomCode::US_W},
{kSbKeyX, ui::DomCode::US_X},
{kSbKeyY, ui::DomCode::US_Y},
{kSbKeyZ, ui::DomCode::US_Z},

// Numpad keys
{kSbKeyNumpad0, ui::DomCode::NUMPAD0},
{kSbKeyNumpad1, ui::DomCode::NUMPAD1},
{kSbKeyNumpad2, ui::DomCode::NUMPAD2},
{kSbKeyNumpad3, ui::DomCode::NUMPAD3},
{kSbKeyNumpad4, ui::DomCode::NUMPAD4},
{kSbKeyNumpad5, ui::DomCode::NUMPAD5},
{kSbKeyNumpad6, ui::DomCode::NUMPAD6},
{kSbKeyNumpad7, ui::DomCode::NUMPAD7},
{kSbKeyNumpad8, ui::DomCode::NUMPAD8},
{kSbKeyNumpad9, ui::DomCode::NUMPAD9},
{kSbKeyMultiply, ui::DomCode::NUMPAD_MULTIPLY},
{kSbKeyAdd, ui::DomCode::NUMPAD_ADD},
{kSbKeySubtract, ui::DomCode::NUMPAD_SUBTRACT},
{kSbKeyDecimal, ui::DomCode::NUMPAD_DECIMAL},
{kSbKeyDivide, ui::DomCode::NUMPAD_DIVIDE},
{kSbKeyNumlock, ui::DomCode::NUM_LOCK},

// function keys
{kSbKeyF1, ui::DomCode::F1},
{kSbKeyF2, ui::DomCode::F2},
{kSbKeyF3, ui::DomCode::F3},
{kSbKeyF4, ui::DomCode::F4},
{kSbKeyF5, ui::DomCode::F5},
{kSbKeyF6, ui::DomCode::F6},
{kSbKeyF7, ui::DomCode::F7},
{kSbKeyF8, ui::DomCode::F8},
{kSbKeyF9, ui::DomCode::F9},
{kSbKeyF10, ui::DomCode::F10},
{kSbKeyF11, ui::DomCode::F11},
{kSbKeyF12, ui::DomCode::F12},
{kSbKeyF13, ui::DomCode::F13},
{kSbKeyF14, ui::DomCode::F14},
{kSbKeyF15, ui::DomCode::F15},
{kSbKeyF16, ui::DomCode::F16},
{kSbKeyF17, ui::DomCode::F17},
{kSbKeyF18, ui::DomCode::F18},
{kSbKeyF19, ui::DomCode::F19},
{kSbKeyF20, ui::DomCode::F20},
{kSbKeyF21, ui::DomCode::F21},
{kSbKeyF22, ui::DomCode::F22},
{kSbKeyF23, ui::DomCode::F23},
{kSbKeyF24, ui::DomCode::F24},

// Browser keys
{kSbKeyBrowserBack, ui::DomCode::BROWSER_BACK},
{kSbKeyBrowserForward, ui::DomCode::BROWSER_FORWARD},
{kSbKeyBrowserRefresh, ui::DomCode::BROWSER_REFRESH},
{kSbKeyBrowserStop, ui::DomCode::BROWSER_STOP},
{kSbKeyBrowserSearch, ui::DomCode::BROWSER_SEARCH},
{kSbKeyBrowserFavorites, ui::DomCode::BROWSER_FAVORITES},
{kSbKeyBrowserHome, ui::DomCode::BROWSER_HOME},

// Left/Right specific keys
{kSbKeyLwin, ui::DomCode::META_LEFT},
{kSbKeyRwin, ui::DomCode::META_RIGHT},
{kSbKeyLshift, ui::DomCode::SHIFT_LEFT},
{kSbKeyRshift, ui::DomCode::SHIFT_RIGHT},
{kSbKeyLcontrol, ui::DomCode::CONTROL_LEFT},
{kSbKeyRcontrol, ui::DomCode::CONTROL_RIGHT},

// Oem keys
{kSbKeyOemPlus, ui::DomCode::EQUAL},
{kSbKeyOemComma, ui::DomCode::COMMA},
{kSbKeyOem1, ui::DomCode::SEMICOLON},
{kSbKeyOem2, ui::DomCode::SLASH},
{kSbKeyOem4, ui::DomCode::BRACKET_LEFT},
{kSbKeyOem5, ui::DomCode::BACKSLASH},
{kSbKeyOem6, ui::DomCode::BRACKET_RIGHT},

// Volume keys
{kSbKeyVolumeMute, ui::DomCode::VOLUME_MUTE},
{kSbKeyVolumeDown, ui::DomCode::VOLUME_DOWN},
{kSbKeyVolumeUp, ui::DomCode::VOLUME_UP},

// Brightness keys
{kSbKeyBrightnessDown, ui::DomCode::BRIGHTNESS_DOWN},
{kSbKeyBrightnessUp, ui::DomCode::BRIGHTNESS_UP},
{kSbKeyKbdBrightnessDown, ui::DomCode::BRIGHTNESS_DOWN},
{kSbKeyKbdBrightnessUp, ui::DomCode::BRIGHTNESS_UP},

{kSbKeyPrior, ui::DomCode::PAGE_UP},
{kSbKeyNext, ui::DomCode::PAGE_DOWN},
{kSbKeyEnd, ui::DomCode::END},
{kSbKeyHome, ui::DomCode::HOME},
{kSbKeyPrint, ui::DomCode::PRINT},
{kSbKeyExecute, ui::DomCode::OPEN},
{kSbKeyInsert, ui::DomCode::INSERT},
{kSbKeyDelete, ui::DomCode::DEL},
{kSbKeyCapital, ui::DomCode::CAPS_LOCK},

{kSbKeySleep, ui::DomCode::SLEEP},
{kSbKeyPower, ui::DomCode::POWER},
{kSbKeyCancel, ui::DomCode::ABORT},
{kSbKeyTab, ui::DomCode::TAB},
{kSbKeyEscape, ui::DomCode::ESCAPE},
});
// Hack: replace this when implementing event handling
static scoped_refptr<base::TaskRunner> g_reply_runner_;
Expand Down
Loading