mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 05:24:19 +01:00
Add shortcut to open keyboard settings
The keyboard settings can be opened by:
adb shell am start -a android.settings.HARD_KEYBOARD_SETTINGS
Add a shortcut (MOD+k) for convenience if the current keyboard is HID.
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
This commit is contained in:
@@ -19,6 +19,7 @@ public final class ControlMessage {
|
||||
public static final int TYPE_ROTATE_DEVICE = 11;
|
||||
public static final int TYPE_UHID_CREATE = 12;
|
||||
public static final int TYPE_UHID_INPUT = 13;
|
||||
public static final int TYPE_OPEN_HARD_KEYBOARD_SETTINGS = 14;
|
||||
|
||||
public static final long SEQUENCE_INVALID = 0;
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ public class ControlMessageReader {
|
||||
case ControlMessage.TYPE_EXPAND_SETTINGS_PANEL:
|
||||
case ControlMessage.TYPE_COLLAPSE_PANELS:
|
||||
case ControlMessage.TYPE_ROTATE_DEVICE:
|
||||
case ControlMessage.TYPE_OPEN_HARD_KEYBOARD_SETTINGS:
|
||||
msg = ControlMessage.createEmpty(type);
|
||||
break;
|
||||
case ControlMessage.TYPE_UHID_CREATE:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
import com.genymobile.scrcpy.wrappers.InputManager;
|
||||
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.view.InputDevice;
|
||||
@@ -208,6 +210,9 @@ public class Controller implements AsyncProcessor {
|
||||
case ControlMessage.TYPE_UHID_INPUT:
|
||||
getUhidManager().writeInput(msg.getId(), msg.getData());
|
||||
break;
|
||||
case ControlMessage.TYPE_OPEN_HARD_KEYBOARD_SETTINGS:
|
||||
openHardKeyboardSettings();
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
@@ -446,4 +451,9 @@ public class Controller implements AsyncProcessor {
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
private void openHardKeyboardSettings() {
|
||||
Intent intent = new Intent("android.settings.HARD_KEYBOARD_SETTINGS");
|
||||
ServiceManager.getActivityManager().startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +366,22 @@ public class ControlMessageReaderTest {
|
||||
Assert.assertArrayEquals(data, event.getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseOpenHardKeyboardSettings() throws IOException {
|
||||
ControlMessageReader reader = new ControlMessageReader();
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
dos.writeByte(ControlMessage.TYPE_OPEN_HARD_KEYBOARD_SETTINGS);
|
||||
|
||||
byte[] packet = bos.toByteArray();
|
||||
|
||||
reader.readFrom(new ByteArrayInputStream(packet));
|
||||
ControlMessage event = reader.next();
|
||||
|
||||
Assert.assertEquals(ControlMessage.TYPE_OPEN_HARD_KEYBOARD_SETTINGS, event.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiEvents() throws IOException {
|
||||
ControlMessageReader reader = new ControlMessageReader();
|
||||
|
||||
Reference in New Issue
Block a user