Skip to content

Commit

Permalink
Add Android record keycode mapping, and send the key event to Kabuki (y…
Browse files Browse the repository at this point in the history
…outube#491)

Co-authored-by: Colin Liang <[email protected]>
  • Loading branch information
zhongqiliang and Colin Liang committed May 30, 2023
1 parent 070d06d commit f2f67a5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cobalt/dom/keyboard_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ std::string KeyboardEvent::NonPrintableKey(int32_t key_code) const {
return "MediaStop";
case keycode::kMediaPlayPause:
return "MediaPlayPause";
#if SB_API_VERSION >= 15
case keycode::kMediaRecord:
return "MediaRecord";
#endif
case keycode::kMediaLaunchMail:
return "LaunchMail";
case keycode::kMediaLaunchMediaSelect:
Expand Down
11 changes: 10 additions & 1 deletion cobalt/dom/keyboard_event_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "cobalt/dom/keyboard_event.h"

#include "cobalt/base/tokens.h"
#include "cobalt/dom/global_stats.h"
#include "cobalt/dom/keyboard_event_init.h"
#include "cobalt/dom/keycode.h"
#include "cobalt/dom/global_stats.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cobalt {
Expand Down Expand Up @@ -134,6 +134,15 @@ TEST_F(KeyboardEventTest, CanGetKeyIdentifierAndKeyAndCode) {
EXPECT_EQ(keyboard_event_space->key_identifier(), " ");
EXPECT_EQ(keyboard_event_space->key(), " ");
EXPECT_EQ(keyboard_event_space->code(), "Space");

#if SB_API_VERSION >= 15
init.set_key_code(keycode::kMediaRecord);
scoped_refptr<KeyboardEvent> keyboard_event_record =
new KeyboardEvent("keydown", init);
EXPECT_EQ(keyboard_event_record->key_identifier(), "MediaRecord");
EXPECT_EQ(keyboard_event_record->key(), "MediaRecord");
EXPECT_EQ(keyboard_event_record->code(), "MediaRecord");
#endif
}

TEST_F(KeyboardEventTest, CanGetAltKey) {
Expand Down
3 changes: 3 additions & 0 deletions cobalt/dom/keycode.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ enum {
// Not present in Windows virtual key codes, but would be used by the client.
kMediaRewind = 0xE3,
kMediaFastForward = 0xE4,
#if SB_API_VERSION >= 15
kMediaRecord = 0x1A0,
#endif
};

} // namespace keycode
Expand Down
4 changes: 4 additions & 0 deletions starboard/android/shared/input_events_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ SbKey AInputEventToSbKey(GameActivityKeyEvent* event) {
return kSbKeyMediaRewind;
case AKEYCODE_MEDIA_FAST_FORWARD:
return kSbKeyMediaFastForward;
#if SB_API_VERSION >= 15
case AKEYCODE_MEDIA_RECORD:
return kSbKeyRecord;
#endif

// TV Remote specific
case AKEYCODE_CHANNEL_UP:
Expand Down

0 comments on commit f2f67a5

Please sign in to comment.