Skip to content

Samsung DeX / physical keyboards: only one language, because Dictate declares a single system subtype and maps no hardware keys #312

Description

@DevEmperor

Split out of discussion #309:

Will you add support for two languages in Samsung DeX mode? Currently, only one language is available, and I cannot use hotkeys as I can with the default keyboard.

What the code does today

FlorisImeService.onKeyDown hands the event to KeyboardManager.onHardwareKeyDown, and that handles three keys: space, enter, shift. Everything else is passed straight through to the app, which turns the key code into a character using the system's keyboard layout for that input device. Dictate maps no hardware key itself, so its own layouts (ЙЦУКЕН, ЯШЕРТЫ, QWERTZ …) have no effect on what a physical keyboard writes.

Why only one language shows up — the likely mechanism

app/src/main/res/xml/method.xml declares one subtype, with no language on it:

<subtype android:label="@string/floris_app_name" android:imeSubtypeMode="keyboard"
         android:imeSubtypeExtraValue="AsciiCapable" android:isAsciiCapable="true"
         android:overridesImplicitlyEnabledSubtype="true"/>

Dictate manages its languages internally, in SubtypeManager, deliberately bypassing Android's subtype mechanism. Since Android 14 the physical-keyboard layout is chosen per IME subtype — so with one subtype there is one layout, and the system shortcut for cycling layouts has nothing to cycle. Samsung's own keyboard registers a subtype per enabled language, which is why it can switch.

This is the plausible explanation, not a verified one — it cannot be confirmed without a DeX device. Hence the questions below.

Two possible routes

  1. Register real subtypes with the systemInputMethodManager.setAdditionalInputMethodSubtypes() at runtime, one per configured Dictate language, and follow onCurrentInputMethodSubtypeChanged back into SubtypeManager. The system then offers a physical layout per language and its own switch shortcut works. Invasive: it puts a second source of truth next to SubtypeManager.
  2. Map the physical keys ourselves — read the key codes in onHardwareKeyDown and resolve them through the active subtype's layout instead of the system keymap (KEYCODE_Qй). This makes Dictate's own language switching meaningful on a hardware keyboard, and it would have to be opt-in: silently taking over every character key would break anyone whose Bluetooth keyboard is already correctly mapped by the system.

A language-switch hotkey on its own (Ctrl+Space or Shift+Space → subtypeManager.switchToNextSubtype()) is half an hour of work, but it is honest to say what it would and would not do: it changes the autocorrect, suggestion and dictation language, and the on-screen keyboard if one is shown. It does not change what the physical keys write. On its own it would not answer this request.

What is needed before any of this is decided

  • The Android version of the DeX device — 14 is the threshold at which layouts became subtype-bound.
  • What "hotkeys" means here: only switching language, or also Ctrl+A/C/V/X/Z and the cursor shortcuts (those go to the app untouched today and should already work — worth knowing if they don't).
  • Whether Settings → System → Physical keyboard → offers a Russian layout at all while Dictate is the active keyboard.

In the meantime

Settings → Advanced → Physical keyboard has "Show on-screen keyboard" (PhysicalKeyboardScreen.kt), which keeps the soft keyboard visible while a hardware keyboard is attached. The language can then be switched with the globe key as usual — the soft keyboard writes in the selected language even when the hardware keys do not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions