Skip to content

Commit 805b961

Browse files
Android: final refinements per maintainer feedback
- Change database migration to use BOOLEAN instead of INTEGER for sendRawKeys - Remove useExtended field, use only OptionalInt.isPresent() for cleaner design - Add authoritative specification links: RFC 6143 for RFB protocol and vncdotool for QEMU Extended Key Event protocol - Simplify OutputEvent constructor by removing useExtended parameter All changes compile successfully. Addresses final review comments from PR bk138#272.
1 parent 6445e5e commit 805b961

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

android/app/src/main/java/com/coboltforge/dontmind/multivnc/AndroidKeyToXt.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import android.view.KeyEvent
1111
* For 2-byte XT codes (like arrow keys), we encode them as single integers
1212
* where the high byte represents the 0xe0 prefix.
1313
*
14+
* RFB Protocol (RFC 6143): https://www.rfc-editor.org/rfc/rfc6143.html
15+
* QEMU Extended Key Event protocol: https://vncdotool.readthedocs.io/en/78/rfbproto.html
1416
* XT scan code specification: https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
1517
*/
1618
object AndroidKeyToXt {

android/app/src/main/java/com/coboltforge/dontmind/multivnc/VNCConn.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,16 @@ public OutputEvent(int x, int y, int modifiers, int pointerMask) {
111111
pointer.mask = pointerMask;
112112
}
113113

114-
public OutputEvent(int keyCode, int metaState, boolean down, OptionalInt xtKeycode, boolean useExtended) {
114+
public OutputEvent(int keyCode, int metaState, boolean down, OptionalInt xtKeycode) {
115115
key = new KeyboardEvent();
116116
key.keyCode = keyCode;
117117
key.metaState = metaState;
118118
key.down = down;
119119
key.xtKeycode = xtKeycode;
120-
key.useExtended = useExtended;
121120
}
122121

123122
public OutputEvent(int keyCode, int metaState, boolean down) {
124-
this(keyCode, metaState, down, OptionalInt.empty(), false);
123+
this(keyCode, metaState, down, OptionalInt.empty());
125124
}
126125

127126
public OutputEvent(boolean incremental) {
@@ -155,7 +154,6 @@ private class KeyboardEvent {
155154
int metaState;
156155
boolean down;
157156
OptionalInt xtKeycode; // XT scancode for extended key events
158-
boolean useExtended; // whether to use extended key events
159157
}
160158

161159
private class FullFramebufferUpdateRequest {
@@ -377,7 +375,7 @@ private boolean sendKeyEvent(OutputEvent.KeyboardEvent evt) {
377375
if(Utils.DEBUG()) Log.d(TAG, "sending key " + evt.keyCode + (evt.down?" down":" up"));
378376

379377
// Use extended key event if available and enabled
380-
if (evt.useExtended && evt.xtKeycode.isPresent() && rfbSupportsExtendedKeys()) {
378+
if (evt.xtKeycode.isPresent() && rfbSupportsExtendedKeys()) {
381379
if(Utils.DEBUG()) Log.d(TAG, "sending extended key: keysym=0x" + Integer.toHexString(evt.keyCode) +
382380
", xtCode=0x" + Integer.toHexString(evt.xtKeycode.getAsInt()) + (evt.down?" down":" up"));
383381
rfbSendExtendedKeyEvent(evt.keyCode, evt.xtKeycode.getAsInt(), evt.down);
@@ -629,15 +627,13 @@ public boolean sendKeyEvent(int keyCode, KeyEvent evt, boolean sendDirectly) {
629627
}
630628

631629
// Check if we should use extended key events
632-
boolean useExtended = false;
633630
OptionalInt xtKeycode = OptionalInt.empty();
634631

635632
if (connSettings != null && connSettings.sendRawKeys && !sendDirectly) {
636633
int xtCode = AndroidKeyToXt.INSTANCE.getXtKeycode(evt.getKeyCode());
637634
// Only use extended keys if we have a valid XT mapping
638635
if (xtCode != 0) {
639636
xtKeycode = OptionalInt.of(xtCode);
640-
useExtended = true;
641637
if(Utils.DEBUG()) {
642638
Log.d(TAG, "Using extended key event: keyCode=" + evt.getKeyCode() +
643639
" -> keysym=0x" + Integer.toHexString(keyCode) +
@@ -650,8 +646,7 @@ public boolean sendKeyEvent(int keyCode, KeyEvent evt, boolean sendDirectly) {
650646
keyCode,
651647
metaState,
652648
evt.getAction() == KeyEvent.ACTION_DOWN,
653-
xtKeycode,
654-
useExtended);
649+
xtKeycode);
655650
outputEventQueue.add(e);
656651
synchronized (outputEventQueue) {
657652
outputEventQueue.notify();

android/app/src/main/java/com/coboltforge/dontmind/multivnc/db/VncDatabase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ public void migrate(@NonNull SupportSQLiteDatabase database) {
174174
public void migrate(@NonNull SupportSQLiteDatabase database) {
175175
Log.i("VncDatabase", "Migrating to Room [15 -> 16]");
176176

177-
// add new SENDRAWKEYS column to CONNECTION_BEAN with default value false (0)
178-
database.execSQL("ALTER TABLE CONNECTION_BEAN ADD SENDRAWKEYS INTEGER NOT NULL DEFAULT 0");
177+
// add new SENDRAWKEYS column to CONNECTION_BEAN with default value false
178+
database.execSQL("ALTER TABLE CONNECTION_BEAN ADD SENDRAWKEYS BOOLEAN NOT NULL DEFAULT FALSE");
179179
}
180180
};
181181
}

0 commit comments

Comments
 (0)