Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: remoting/client/jni/chromoting_jni_instance.cc

Issue 1321223003: Use scan codes when sending keyboard events froms physical keyboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/jni/chromoting_jni_instance.h" 5 #include "remoting/client/jni/chromoting_jni_instance.h"
6 6
7 #include <android/log.h> 7 #include <android/log.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "jingle/glue/thread_wrapper.h" 11 #include "jingle/glue/thread_wrapper.h"
12 #include "net/socket/client_socket_factory.h" 12 #include "net/socket/client_socket_factory.h"
13 #include "remoting/base/service_urls.h" 13 #include "remoting/base/service_urls.h"
14 #include "remoting/client/audio_player.h" 14 #include "remoting/client/audio_player.h"
15 #include "remoting/client/client_status_logger.h" 15 #include "remoting/client/client_status_logger.h"
16 #include "remoting/client/jni/android_keymap.h" 16 #include "remoting/client/jni/android_keymap.h"
17 #include "remoting/client/jni/chromoting_jni_runtime.h" 17 #include "remoting/client/jni/chromoting_jni_runtime.h"
18 #include "remoting/client/jni/jni_frame_consumer.h" 18 #include "remoting/client/jni/jni_frame_consumer.h"
19 #include "remoting/client/software_video_renderer.h" 19 #include "remoting/client/software_video_renderer.h"
20 #include "remoting/client/token_fetcher_proxy.h" 20 #include "remoting/client/token_fetcher_proxy.h"
21 #include "remoting/protocol/chromium_port_allocator.h" 21 #include "remoting/protocol/chromium_port_allocator.h"
22 #include "remoting/protocol/chromium_socket_factory.h" 22 #include "remoting/protocol/chromium_socket_factory.h"
23 #include "remoting/protocol/host_stub.h" 23 #include "remoting/protocol/host_stub.h"
24 #include "remoting/protocol/libjingle_transport_factory.h" 24 #include "remoting/protocol/libjingle_transport_factory.h"
25 #include "remoting/protocol/negotiating_client_authenticator.h" 25 #include "remoting/protocol/negotiating_client_authenticator.h"
26 #include "remoting/protocol/network_settings.h" 26 #include "remoting/protocol/network_settings.h"
27 #include "remoting/signaling/server_log_entry.h" 27 #include "remoting/signaling/server_log_entry.h"
28 #include "ui/events/keycodes/dom/keycode_converter.h"
28 29
29 namespace remoting { 30 namespace remoting {
30 31
31 namespace { 32 namespace {
32 33
33 // TODO(solb) Move into location shared with client plugin. 34 // TODO(solb) Move into location shared with client plugin.
34 const char* const kXmppServer = "talk.google.com"; 35 const char* const kXmppServer = "talk.google.com";
35 const int kXmppPort = 5222; 36 const int kXmppPort = 5222;
36 const bool kXmppUseTls = true; 37 const bool kXmppUseTls = true;
37 38
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 delta_x, delta_y)); 223 delta_x, delta_y));
223 return; 224 return;
224 } 225 }
225 226
226 protocol::MouseEvent event; 227 protocol::MouseEvent event;
227 event.set_wheel_delta_x(delta_x); 228 event.set_wheel_delta_x(delta_x);
228 event.set_wheel_delta_y(delta_y); 229 event.set_wheel_delta_y(delta_y);
229 client_->input_stub()->InjectMouseEvent(event); 230 client_->input_stub()->InjectMouseEvent(event);
230 } 231 }
231 232
232 bool ChromotingJniInstance::SendKeyEvent(int key_code, bool key_down) { 233 bool ChromotingJniInstance::SendKeyEvent(int scan_code,
233 uint32 usb_key_code = AndroidKeycodeToUsbKeycode(key_code); 234 int key_code,
235 bool key_down) {
236 // For software keyboards |scan_code| is set to 0, in which case the
Lambros 2015/09/08 23:39:44 in which case the ... what?
Sergey Ulanov 2015/09/09 00:30:06 Done.
237 uint32_t usb_key_code =
238 scan_code ? ui::KeycodeConverter::NativeKeycodeToUsbKeycode(scan_code)
239 : AndroidKeycodeToUsbKeycode(key_code);
234 if (!usb_key_code) { 240 if (!usb_key_code) {
235 LOG(WARNING) << "Ignoring unknown keycode: " << key_code; 241 LOG(WARNING) << "Ignoring unknown key code: " << key_code
242 << " scan code: " << scan_code;
236 return false; 243 return false;
237 } 244 }
238 245
239 SendKeyEventInternal(usb_key_code, key_down); 246 SendKeyEventInternal(usb_key_code, key_down);
240 return true; 247 return true;
241 } 248 }
242 249
243 void ChromotingJniInstance::SendTextEvent(const std::string& text) { 250 void ChromotingJniInstance::SendTextEvent(const std::string& text) {
244 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 251 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
245 jni_runtime_->network_task_runner()->PostTask( 252 jni_runtime_->network_task_runner()->PostTask(
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 stats->round_trip_ms()); 501 stats->round_trip_ms());
495 502
496 client_status_logger_->LogStatistics(stats); 503 client_status_logger_->LogStatistics(stats);
497 504
498 jni_runtime_->network_task_runner()->PostDelayedTask( 505 jni_runtime_->network_task_runner()->PostDelayedTask(
499 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), 506 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this),
500 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 507 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
501 } 508 }
502 509
503 } // namespace remoting 510 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698