OLD | NEW |
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 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.os.Bundle; | 10 import android.os.Bundle; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 JniInterface.sendTextEvent(event.getCharacters()); | 239 JniInterface.sendTextEvent(event.getCharacters()); |
240 return true; | 240 return true; |
241 } | 241 } |
242 | 242 |
243 boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN; | 243 boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN; |
244 | 244 |
245 // For Enter getUnicodeChar() returns 10 (line feed), but we still | 245 // For Enter getUnicodeChar() returns 10 (line feed), but we still |
246 // want to send it as KeyEvent. | 246 // want to send it as KeyEvent. |
247 int unicode = keyCode != KeyEvent.KEYCODE_ENTER ? event.getUnicodeChar()
: 0; | 247 int unicode = keyCode != KeyEvent.KEYCODE_ENTER ? event.getUnicodeChar()
: 0; |
248 | 248 |
249 boolean no_modifiers = !event.isAltPressed() && | 249 boolean no_modifiers = !event.isAltPressed() |
250 !event.isCtrlPressed() && !event.isMetaPressed(); | 250 && !event.isCtrlPressed() && !event.isMetaPressed(); |
251 | 251 |
252 if (event.getDeviceId() == KeyCharacterMap.VIRTUAL_KEYBOARD && | 252 if (event.getDeviceId() == KeyCharacterMap.VIRTUAL_KEYBOARD |
253 pressed && unicode != 0 && no_modifiers) { | 253 && pressed && unicode != 0 && no_modifiers) { |
254 mPressedTextKeys.add(keyCode); | 254 mPressedTextKeys.add(keyCode); |
255 int[] codePoints = { unicode }; | 255 int[] codePoints = { unicode }; |
256 JniInterface.sendTextEvent(new String(codePoints, 0, 1)); | 256 JniInterface.sendTextEvent(new String(codePoints, 0, 1)); |
257 return true; | 257 return true; |
258 } | 258 } |
259 | 259 |
260 if (!pressed && mPressedTextKeys.contains(keyCode)) { | 260 if (!pressed && mPressedTextKeys.contains(keyCode)) { |
261 mPressedTextKeys.remove(keyCode); | 261 mPressedTextKeys.remove(keyCode); |
262 return true; | 262 return true; |
263 } | 263 } |
(...skipping 18 matching lines...) Expand all Loading... |
282 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed); | 282 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT, pressed); |
283 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed); | 283 JniInterface.sendKeyEvent(KeyEvent.KEYCODE_EQUALS, pressed); |
284 return true; | 284 return true; |
285 | 285 |
286 default: | 286 default: |
287 // We try to send all other key codes to the host directly. | 287 // We try to send all other key codes to the host directly. |
288 return JniInterface.sendKeyEvent(keyCode, pressed); | 288 return JniInterface.sendKeyEvent(keyCode, pressed); |
289 } | 289 } |
290 } | 290 } |
291 } | 291 } |
OLD | NEW |