Skip to content

Add IME keyboard layout and panel metrics support#3973

Merged
georgemoralis merged 49 commits into
shadps4-emu:mainfrom
w1naenator:ime-fixes-again
May 9, 2026
Merged

Add IME keyboard layout and panel metrics support#3973
georgemoralis merged 49 commits into
shadps4-emu:mainfrom
w1naenator:ime-fixes-again

Conversation

@w1naenator
Copy link
Copy Markdown
Contributor

  • Introduced new header and implementation files for IME keyboard layout handling.
  • Added structures for viewport metrics, keyboard grid layout, and drawing parameters.
  • Implemented functions to compute viewport and panel metrics for the IME dialog.
  • Enhanced the IME dialog UI to utilize the new keyboard layout and metrics.
  • Updated input handling to support new keyboard interactions and layout adjustments.
  • Added caret management and text normalization features in the IME dialog state.
  • Improved window positioning logic to accommodate different screen resolutions.

- Introduced new header and implementation files for IME keyboard layout handling.
- Added structures for viewport metrics, keyboard grid layout, and drawing parameters.
- Implemented functions to compute viewport and panel metrics for the IME dialog.
- Enhanced the IME dialog UI to utilize the new keyboard layout and metrics.
- Updated input handling to support new keyboard interactions and layout adjustments.
- Added caret management and text normalization features in the IME dialog state.
- Improved window positioning logic to accommodate different screen resolutions.
@georgemoralis
Copy link
Copy Markdown
Collaborator

which games uses ime keyboard?

@w1naenator
Copy link
Copy Markdown
Contributor Author

which games uses ime keyboard?

bloodborne, code vein, nier automata, dragon balls xenoverse 1/2 (was softlocked), diablo III, god eater 2

@DanielSvoboda
Copy link
Copy Markdown
Member

In the game Divinity: Original Sin 2 - Definitive Edition this PR causes an error even before the game starts.
In the pre-release, it reaches the menu, but after pressing the X button, the animation loops and the menu doesn't open.

vmovdqa64 is an AVX-512 instruction, and my processor doesn't support AVX-512

image

@StevenMiller123
Copy link
Copy Markdown
Collaborator

StevenMiller123 commented Jan 30, 2026

That sounds like it's executing garbage data, could you compile locally and debug the crash?

@DanielSvoboda
Copy link
Copy Markdown
Member

The local build works normally. I tested it both by debugging in Visual Studio and by running it through the command line.
However, the version downloaded from GitHub shows this error.
Even when testing only the SDL version from GitHub and the local SDL build, the local one works without any issues, while the GitHub version still presents this problem.
Honestly, I couldn’t figure out what is happening....

The game doesn't show any improvement with this PR. So you can disregard my comment.

@georgemoralis
Copy link
Copy Markdown
Collaborator

is this still on work?

@w1naenator
Copy link
Copy Markdown
Contributor Author

This was implemented as a fix for Dragon Ball Xenoverse 1/2, where entering a character name would softlock the game. This issue is now resolved in this PR.

The virtual keyboard now matches the original size, uses the correct positioning, and scales according to the output video resolution.

I am not sure whether a virtual keyboard is needed on your side, so I do not know if it is worth spending additional time on it.

@StevenMiller123
Copy link
Copy Markdown
Collaborator

And yes, I can confirm that this fixes the issue in Dragon Ball Xenoverse titles.
image

@brad0demx
Copy link
Copy Markdown

Rocket League is another title which benefits from this PR
image

@w1naenator
Copy link
Copy Markdown
Contributor Author

@georgemoralis, +1

@georgemoralis
Copy link
Copy Markdown
Collaborator

yah finish it and we gonna merge it :D

@georgemoralis
Copy link
Copy Markdown
Collaborator

ime settings needs to be converted to new settings api

@w1naenator
Copy link
Copy Markdown
Contributor Author

i guess if they UI isn't 100% matched we don't have an issue :d

I made it look similar, but it’s still my own interpretation and code. However, there could still be patented elements, such as hotkeys and key combinations, table-style layouts, function button sequences, and many other features.

@brad0demx
Copy link
Copy Markdown

My bad hadn't been on, I will test it now

@brad0demx
Copy link
Copy Markdown

brad0demx commented Apr 27, 2026

Tested again, and it now scrolls to the end and after a brief pause wraps while the button is being held, with no additional inputs required. There's still the issue with analogue stick navigation and L2 that I mentioned.

IMO I think the only really "glaring" issue is the L2 shift/capslock, because the jumps between shift and caps lock happen quite fast and inconsistently. The analogue stick issue isn't massively inconvenient because it's behaviour is consistent (and I can just use the d pad is also there which works basically perfectly from what I can tell)

@brad0demx
Copy link
Copy Markdown

Also the other issue I had mentioned before like holding triangle to enter multiple spaces. However one I forgot about is holding x on a character to input it multiple times.

w1naenator and others added 2 commits April 27, 2026 18:01
- Introduced a new mechanism for handling virtual button repeat actions, improving responsiveness for gamepad navigation.
- Added support for stick navigation with adjustable repeat rates and initial delays, enhancing user experience during input.
- Removed the ImeSelectorFadeState structure and related logic to streamline the IME keyboard layout drawing process.
- Simplified the activation logic for menus, ensuring that menu activation is more intuitive and responsive to user input.
- Adjusted the navigation threshold for stick inputs to improve sensitivity and control.
- Cleaned up the code by removing unused variables and consolidating repeated logic into reusable functions.
@w1naenator
Copy link
Copy Markdown
Contributor Author

@brad0demx, check now, I think everything fixed!

@brad0demx
Copy link
Copy Markdown

Analogue stick feels a lot better now, I'm able to spin it in a circle and it scrolls 2x2 like on console. I notice when auto scrolling with the stick, it scrolls slower than when using the d-pad, though this a minor nitpick and doesn't really matter.

Holding X and Square to repeatedly enter/delete text works, holding triangle for repeatedly entering spaces works.

L2 seems to be still inconsistent, and I also notice that when holding L2 + triangle to access the punctuation variant of the keyboard, it flashes between both keyboard variants while triangle is being held.

It's kind of like the logic for holding triangle to repeatedly type spaces is also being applied to this button combo shortcut.

@w1naenator
Copy link
Copy Markdown
Contributor Author

Analogue stick feels a lot better now, I'm able to spin it in a circle and it scrolls 2x2 like on console. I notice when auto scrolling with the stick, it scrolls slower than when using the d-pad, though this a minor nitpick and doesn't really matter.

Holding X and Square to repeatedly enter/delete text works, holding triangle for repeatedly entering spaces works.

L2 seems to be still inconsistent, and I also notice that when holding L2 + triangle to access the punctuation variant of the keyboard, it flashes between both keyboard variants while triangle is being held.

It's kind of like the logic for holding triangle to repeatedly type spaces is also being applied to this button combo shortcut.

OK, I have a gamepad modified for shooters. It has no range for L2/R2—just 0 or full. That is why I do not have this problem. Now the issue is clear; I will fix it.

w1naenator and others added 2 commits April 28, 2026 01:49
- Removed unused includes and redundant structures.
- Consolidated virtual pad snapshot handling and input state management.
- Introduced new structures for OSK pad input and navigation handling.
- Updated function signatures for clarity and consistency.
- Enhanced keyboard parameter application for OSK shortcuts.
- Improved overall readability and maintainability of the code.
@w1naenator
Copy link
Copy Markdown
Contributor Author

Huge refactor and optimization made, plus L2 fixes. Something might be broken now.

@w1naenator
Copy link
Copy Markdown
Contributor Author

w1naenator commented Apr 28, 2026

@brad0demx, could you please check again?

@brad0demx
Copy link
Copy Markdown

L2 is now working perfectly, and the issue I mentioned with L2 + triangle is also fixed. Basically everything that I have mentioned previously (Analogue stick, L2, button combos and button hold behaviours) is working now, except one bug in this new version. When pressing triangle to enter space, it doesn't type the space on the first button press and only starts typing it after the button is held briefly.

Also minor nitpick that doesn't really matter, when opening the keyboard it auto hovers over "1" at the top left when on console I believe it hovers over "G"

@w1naenator
Copy link
Copy Markdown
Contributor Author

w1naenator commented Apr 28, 2026

L2 is now working perfectly, and the issue I mentioned with L2 + triangle is also fixed. Basically everything that I have mentioned previously (Analogue stick, L2, button combos and button hold behaviours) is working now, except one bug in this new version. When pressing triangle to enter space, it doesn't type the space on the first button press and only starts typing it after the button is held briefly.

Also minor nitpick that doesn't really matter, when opening the keyboard it auto hovers over "1" at the top left when on console I believe it hovers over "G"

Seams it is result of my optimizations, I'll fix!

@w1naenator
Copy link
Copy Markdown
Contributor Author

@brad0demx Is it working now as expected?

@brad0demx
Copy link
Copy Markdown

Yes it's very close to being perfect, my only issue is currently the initial selection box is based on it's last location rather than starting on "G" when the keyboard is opened. Also when using L2 + triangle combo, it moves the selection box to the selection box of the button combo, whereas on the console the selection box stays in the same position.

Explanation might not have made much sense but I got videos of the behaviour on emu and console to potentially help

imeDialogue.mp4
imeDialoguePS4.mp4

Really appreciate you taking the feedback and working on it so fast, glad I've been able to help 🥕
I'd say (at least for English language) its right there and could probably be merged

- Added new key glyphs for Shift and Caps Lock in ime_kb_layout.h.
- Improved keyboard navigation logic to skip non-action keys.
- Introduced new constants for selector IDs in ime_ui.cpp for better readability.
- Refactored keyboard row and column clamping logic for clarity.
- Enhanced selector drawing logic with fade and pulse effects for better user feedback.
- Implemented functions for cycling keyboard case states and toggling keyboard family modes.
- Added functionality to focus on keyboard action keys based on their actions.
- Improved edit menu handling with new templated functions for better code reuse.
- Updated caret blinking logic to improve text input experience.
- Expanded symbol ranges in font_stack.cpp to include keyboard symbols.
@w1naenator
Copy link
Copy Markdown
Contributor Author

Final fixes.
image

@w1naenator
Copy link
Copy Markdown
Contributor Author

@brad0demx Thank you, your involvement has been very helpful. I really appreciate your time, testing, and feedback - it helped a lot with debugging and improving the OSK.

@w1naenator
Copy link
Copy Markdown
Contributor Author

@georgemoralis @StevenMiller123 @DanielSvoboda please check last update.

@georgemoralis georgemoralis self-requested a review April 30, 2026 15:20
@georgemoralis
Copy link
Copy Markdown
Collaborator

looking good! waiting for others approval

@kalaposfos13
Copy link
Copy Markdown
Member

There are still a couple things missing from the PR, however, they aren't merge blocking features. First, if you use the touchpad, the button selection automatically switches to a cursor that you can then use like a mouse based on-screen keyboard on PC. You can exit that mode by pressing any of the dpad arrows or R3 (see below). The other one is gyro based input, which is entered with R3, or the button that is already present for it but isn't hooked up yet (and exited either by initiating dpad movement or touchpad movement). While in that mode, further R3 presses recenter the cursor, and its movement is most intuitively understood as having a line coming out of the Dualshock's lightbar, and its (rotational 3dof) movement changes where that line intersects the screen, and that intersection is the pointer's location, assuming that at start, this line is pointed at the center of the keyboard.

@georgemoralis georgemoralis merged commit 05df651 into shadps4-emu:main May 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants