avnc icon indicating copy to clipboard operation
avnc copied to clipboard

Feature Requests: zoom on keyboard+mouse, disconnect on keyboard shortcut

Open AtmanActive opened this issue 4 months ago • 17 comments

With the recent addition of "full external mouse control" and "pan zoomed viewport with the mouse pointer" features (still in development), AVNC has de-facto climbed to become the #1 VNC client on the planet.

Congratulations to all the developers for this awesome achievement!

When using AVNC with a keyboard & mouse equiped Android device, there is still an inconvenience of having to use the touchscreen to control the zoom level and to disconnect the VNC session.

It would be awesome if AVNC could zoom-in & zoom-out by, for example, holding CTRL+ALT+SHIFT on the keyboard and turning the mouse wheel up and down. Likewise, it would be awesome if users could disconnect the session from the keyboard shortcut, like, for example, CTRL+ALT+SHIFT+ESC.

To avoid conflict with the VNC session, these could be partially configurable or allowed to be enabled/disabled in the settings. Although, I never encountered these keyboard combinations in use before, so I'm pretty sure they are safe.

By adding these two features, AVNC could become completely independent from having to use touch screen gestures, thus making it also fully usable on Android desktop environments where touch screen is unavailable, like, for example, Android TV, Nvidia Shield, and so on.

Thanks.

AtmanActive avatar Aug 19 '25 11:08 AtmanActive

Zoom in/out with scroll wheel should be doable, though I will have to look more into it.

I am not implementing the shortcut for disconnecting. First, AVNC already disconnects on Back press, so that covers majority of cases. Second, care needs to be taken to properly release the pressed meta keys when disconnecting, so that they are not stuck in pressed state on server.

That said, I am not opposed to the core idea, and if somebody wants to implement it, I would be happy to merge a PR.

gujjwal00 avatar Aug 21 '25 14:08 gujjwal00

About "Zoom in/out with scroll wheel" - thank you.

About "Disconnect using keyboard only": by using a plain BlueTooth keyboard connected to my Android 15 device, I can use CTRL+ALT+Backspace to issue a "back" command everywhere except in the AVNC session. bVNC Pro propagates CTRL+ALT+Backspace to the host. AVNC does nothing. Searching for other options to disconnect the AVNC session without using the touchscreen ...

AtmanActive avatar Aug 21 '25 15:08 AtmanActive

When the BlueTooth keyboard is in Mac mode, then COMMAND+Backspace works as "back" correctly, both in the Android itself and in the AVNC session.

AtmanActive avatar Aug 21 '25 15:08 AtmanActive

  1. Please go to AVNC Settings => Tools => Key test
  2. Check 'Copy automatically on exit'
  3. Press CTRL+ALT+Backspace
  4. Copy (if not exited the test) and paste here.

gujjwal00 avatar Aug 21 '25 16:08 gujjwal00

Here is the debug log of another BlueTooth keyboard, this one has a dedicated back button.

Again, this back button works correctly everywhere in Android except in AVNC session.

Screenshot_20250821_181633.jpg

`

Key test

KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=158, metaState=0, flags=0x8, repeatCount=0, eventTime=476418921586000, downTime=476418921586000, deviceId=20, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=158, metaState=0, flags=0x8, repeatCount=0, eventTime=476419031574000, downTime=476418921586000, deviceId=20, source=0x301, displayId=-1 }


Preview text: 

`

AtmanActive avatar Aug 21 '25 17:08 AtmanActive

Here is CTRL+ALT+Backspace:

Key test

KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_CTRL_LEFT, scanCode=29, metaState=META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=0, eventTime=481977426884000, downTime=481977426884000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_LEFT, scanCode=56, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=0, eventTime=481977593903000, downTime=481977593903000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_LEFT, scanCode=56, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x88, repeatCount=1, eventTime=481977995082857, downTime=481977593903000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_LEFT, scanCode=56, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=2, eventTime=481978045780513, downTime=481977593903000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_LEFT, scanCode=56, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=3, eventTime=481978096554680, downTime=481977593903000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_LEFT, scanCode=56, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=4, eventTime=481978147421242, downTime=481977593903000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DEL, scanCode=14, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=0, eventTime=481978155073000, downTime=481978155073000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=14, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x408, repeatCount=0, eventTime=481978155000000, downTime=481978155000000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_UP, keyCode=KEYCODE_DEL, scanCode=14, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x8, repeatCount=0, eventTime=481978177361000, downTime=481978155073000, deviceId=22, source=0x301, displayId=-1 }
KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=14, metaState=META_ALT_ON|META_ALT_LEFT_ON|META_CTRL_ON|META_CTRL_LEFT_ON, flags=0x408, repeatCount=0, eventTime=481978177000000, downTime=481978155000000, deviceId=22, source=0x301, displayId=-1 }


Preview text: 

AtmanActive avatar Aug 21 '25 19:08 AtmanActive

Here is COMMAND+Backspace:

Key test

KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=482079337000000, downTime=482079337000000, deviceId=-1, source=0x101, displayId=-1 }
KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=482079337000000, downTime=482079337000000, deviceId=-1, source=0x101, displayId=-1 }


Preview text: 

AtmanActive avatar Aug 21 '25 19:08 AtmanActive

Please try changing Settings => Input => Mouse => Back button to 'Default'

gujjwal00 avatar Aug 22 '25 02:08 gujjwal00

Ignore that. I think issue is the improper handling of scan code.

gujjwal00 avatar Aug 22 '25 03:08 gujjwal00

Do you have Settings => Input => Key Mappings => Back to Escape enabled by any chance?

gujjwal00 avatar Aug 22 '25 04:08 gujjwal00

Do you have Settings => Input => Key Mappings => Back to Escape enabled by any chance?

No.

AtmanActive avatar Aug 22 '25 08:08 AtmanActive

Ooops... the dedicated back button does work on the CI version.

So this could easily be a case where we're chasing our own tail, because we have several different versions floating around. Maybe the best would be to release a new official version so we have a common starting point.

AtmanActive avatar Aug 22 '25 10:08 AtmanActive

So, the situation is this:

  • v2.9.1CI: the dedicated back button works correctly; Settings->Input->Mouse->Back Button is set to right-click, Settings->Input->Key Mapping->Back is set to OFF.

  • v2.9.1: the dedicated back button is translated to right-click, but when I go to settings and change it from "right-click" to "default", then it is working correctly. Key Mapping for back is OFF.

AtmanActive avatar Aug 22 '25 11:08 AtmanActive

Thanks for testing different combinations @AtmanActive . But, even after a lot of testing on my end, I can't exactly pinpoint the reason why the CI version would work correctly. Only theory I have is the implementation of Pointer capture which changed the focused View.

So, are you using the CI version with Pointer capture enabled?

  • If yes, can you try with Pointer capture disabled
  • If no, please link the CI APK you are using

gujjwal00 avatar Aug 24 '25 13:08 gujjwal00

You are absolutely right: "Capture Pointer" is what makes all the difference.

When "Capture Pointer" is OFF, then, the hardware back button behavior is absolutely the same as in the v2.9.1 (non-CI) version.

But, when "Capture Pointer" is ON (only in the CI version, of course), then, the hardware back button works correctly, and the setting in Settings->Input->Mouse->Back Button is completely ignored.

AtmanActive avatar Aug 24 '25 15:08 AtmanActive

So here is whats going on: Many android devices intercept and convert mouse right-click to back-press event. To allow correct use of right-click on these device, a workaround was added in AVNC. It tries to detect if back-press was triggered from a mouse. If detected, instead of default back-press handling, AVNC will simulate a mouse right-click (this is controlled by the Back button Input setting).

In your case, the Bluetooth device is triggering this mouse detection, probably because a touchpad is also present on the device. When pointer capture is enabled, the FrameView is focused so the back-press events takes a different code path where the workaround is not applied. That's why it works correctly in CI version.

Please test the following APK: https://github.com/gujjwal00/avnc/actions/runs/17191754762/artifacts/3838425087 I have added an additional check for scancode, so the workaround should not affect any event coming from a real keyboard. With this APK, any method of back-press should work correctly.

gujjwal00 avatar Aug 24 '25 18:08 gujjwal00

Thank you for the quick fix.

Can confirm: now the dedicated "back" keyboard button works correctly in all situations.

AtmanActive avatar Aug 25 '25 09:08 AtmanActive