Skip to content

Commit e180eef

Browse files
committed
Support device type for KeyEvent
1 parent 029cfdd commit e180eef

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

flutter/shell/platform/tizen/channels/input_device_channel.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class InputDeviceChannel {
2323
last_keyboard_name_ = name;
2424
}
2525

26+
std::string last_keyboard_name() { return last_keyboard_name_; }
27+
2628
private:
2729
void HandleMethodCall(const MethodCall<EncodableValue>& method_call,
2830
std::unique_ptr<MethodResult<EncodableValue>> result);

flutter/shell/platform/tizen/channels/keyboard_channel.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void KeyboardChannel::SendKey(const char* key,
118118
uint32_t modifiers,
119119
uint32_t scan_code,
120120
bool is_down,
121+
FlutterKeyEventDeviceType device_type,
121122
std::function<void(bool)> callback) {
122123
uint64_t sequence_id = last_sequence_id_++;
123124

@@ -142,7 +143,7 @@ void KeyboardChannel::SendKey(const char* key,
142143
}
143144

144145
SendEmbedderEvent(key, string, compose, modifiers, scan_code, is_down,
145-
sequence_id);
146+
sequence_id, device_type);
146147
// The channel-based API (RawKeyEvent) is deprecated and |SendChannelEvent|
147148
// will be removed in the future. This class (KeyboardChannel) itself will
148149
// also be renamed and refactored then.
@@ -205,7 +206,8 @@ void KeyboardChannel::SendEmbedderEvent(const char* key,
205206
uint32_t modifiers,
206207
uint32_t scan_code,
207208
bool is_down,
208-
uint64_t sequence_id) {
209+
uint64_t sequence_id,
210+
FlutterKeyEventDeviceType device_type) {
209211
uint64_t physical_key = GetPhysicalKey(scan_code);
210212
uint64_t logical_key = GetLogicalKey(key);
211213
const char* character = is_down ? string : nullptr;
@@ -242,6 +244,7 @@ void KeyboardChannel::SendEmbedderEvent(const char* key,
242244
.logical = 0,
243245
.character = "",
244246
.synthesized = false,
247+
.device_type = device_type,
245248
};
246249
send_event_(empty_event, nullptr, nullptr);
247250
ResolvePendingEvent(sequence_id, true);
@@ -263,6 +266,7 @@ void KeyboardChannel::SendEmbedderEvent(const char* key,
263266
event.logical = last_logical_record != 0 ? last_logical_record : logical_key;
264267
event.character = character;
265268
event.synthesized = false;
269+
event.device_type = device_type;
266270

267271
send_event_(
268272
event,

flutter/shell/platform/tizen/channels/keyboard_channel.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class KeyboardChannel {
3535
uint32_t modifiers,
3636
uint32_t scan_code,
3737
bool is_down,
38+
FlutterKeyEventDeviceType device_type,
3839
std::function<void(bool)> callback);
3940

4041
private:
@@ -69,7 +70,8 @@ class KeyboardChannel {
6970
uint32_t modifiers,
7071
uint32_t scan_code,
7172
bool is_down,
72-
uint64_t sequence_id);
73+
uint64_t sequence_id,
74+
FlutterKeyEventDeviceType device_type);
7375

7476
void SendChannelEvent(const char* key,
7577
const char* string,

flutter/shell/platform/tizen/flutter_tizen_view.cc

+17-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ const std::vector<std::string> kBindableSystemKeys = {
4545
"XF86Exit",
4646
};
4747

48+
const std::vector<std::string> kRemoteControlDeviceTypeNameKeywords = {
49+
"rc device", // wt61p807 rc device
50+
"Smart Control", // Smart Control 2016
51+
};
52+
4853
// The multiplier is taken from the Chromium source
4954
// (ui/events/x/events_x_utils.cc).
5055
constexpr int32_t kScrollOffsetMultiplier = 53;
@@ -351,9 +356,20 @@ void FlutterTizenView::OnKey(const char* key,
351356
}
352357
}
353358

359+
FlutterKeyEventDeviceType device_type =
360+
FlutterKeyEventDeviceType::kFlutterKeyEventDeviceTypeKeyboard;
361+
for (const std::string& key : kRemoteControlDeviceTypeNameKeywords) {
362+
if (input_device_channel_->last_keyboard_name().find(key) !=
363+
std::string::npos) {
364+
device_type =
365+
FlutterKeyEventDeviceType::kFlutterKeyEventDeviceTypeDirectionalPad;
366+
break;
367+
}
368+
}
369+
354370
if (engine_->keyboard_channel()) {
355371
engine_->keyboard_channel()->SendKey(
356-
key, string, compose, modifiers, scan_code, is_down,
372+
key, string, compose, modifiers, scan_code, is_down, device_type,
357373
[engine = engine_.get(), symbol = std::string(key),
358374
is_down](bool handled) {
359375
if (handled) {

0 commit comments

Comments
 (0)