Skip to content

Commit f2f67a5

Browse files
authored
Add Android record keycode mapping, and send the key event to Kabuki (#491)
Co-authored-by: Colin Liang <[email protected]>
1 parent 070d06d commit f2f67a5

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎cobalt/dom/keyboard_event.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ std::string KeyboardEvent::NonPrintableKey(int32_t key_code) const {
337337
return "MediaStop";
338338
case keycode::kMediaPlayPause:
339339
return "MediaPlayPause";
340+
#if SB_API_VERSION >= 15
341+
case keycode::kMediaRecord:
342+
return "MediaRecord";
343+
#endif
340344
case keycode::kMediaLaunchMail:
341345
return "LaunchMail";
342346
case keycode::kMediaLaunchMediaSelect:

‎cobalt/dom/keyboard_event_test.cc‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include "cobalt/dom/keyboard_event.h"
1616

1717
#include "cobalt/base/tokens.h"
18+
#include "cobalt/dom/global_stats.h"
1819
#include "cobalt/dom/keyboard_event_init.h"
1920
#include "cobalt/dom/keycode.h"
20-
#include "cobalt/dom/global_stats.h"
2121
#include "testing/gtest/include/gtest/gtest.h"
2222

2323
namespace cobalt {
@@ -134,6 +134,15 @@ TEST_F(KeyboardEventTest, CanGetKeyIdentifierAndKeyAndCode) {
134134
EXPECT_EQ(keyboard_event_space->key_identifier(), " ");
135135
EXPECT_EQ(keyboard_event_space->key(), " ");
136136
EXPECT_EQ(keyboard_event_space->code(), "Space");
137+
138+
#if SB_API_VERSION >= 15
139+
init.set_key_code(keycode::kMediaRecord);
140+
scoped_refptr<KeyboardEvent> keyboard_event_record =
141+
new KeyboardEvent("keydown", init);
142+
EXPECT_EQ(keyboard_event_record->key_identifier(), "MediaRecord");
143+
EXPECT_EQ(keyboard_event_record->key(), "MediaRecord");
144+
EXPECT_EQ(keyboard_event_record->code(), "MediaRecord");
145+
#endif
137146
}
138147

139148
TEST_F(KeyboardEventTest, CanGetAltKey) {

‎cobalt/dom/keycode.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ enum {
200200
// Not present in Windows virtual key codes, but would be used by the client.
201201
kMediaRewind = 0xE3,
202202
kMediaFastForward = 0xE4,
203+
#if SB_API_VERSION >= 15
204+
kMediaRecord = 0x1A0,
205+
#endif
203206
};
204207

205208
} // namespace keycode

‎starboard/android/shared/input_events_generator.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ SbKey AInputEventToSbKey(GameActivityKeyEvent* event) {
232232
return kSbKeyMediaRewind;
233233
case AKEYCODE_MEDIA_FAST_FORWARD:
234234
return kSbKeyMediaFastForward;
235+
#if SB_API_VERSION >= 15
236+
case AKEYCODE_MEDIA_RECORD:
237+
return kSbKeyRecord;
238+
#endif
235239

236240
// TV Remote specific
237241
case AKEYCODE_CHANNEL_UP:

0 commit comments

Comments
 (0)