Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Opening the on-screen keyboard with standard APIs #668

Closed
flibitijibibo opened this issue Nov 12, 2022 · 10 comments · Fixed by libsdl-org/SDL#6515
Closed

[Question] Opening the on-screen keyboard with standard APIs #668

flibitijibibo opened this issue Nov 12, 2022 · 10 comments · Fixed by libsdl-org/SDL#6515

Comments

@flibitijibibo
Copy link

Currently Valve asks applications to interact with the on-screen keyboard via proprietary APIs, such as ShowGamepadTextInput - this is okay for new games, but for older games there is already prior art for interacting with the on-screen keyboard, namely SDL's text input API. On Wayland we actually have really good on-screen keyboard support thanks to the text-input-v3 protocol, which does a great job of not only showing the keyboard but only doing so when a physical keyboard isn't present - once gamescope supports native Wayland clients (#543) this will all hopefully Just Work for many existing native SDL titles!

For now though, we're of course using Xwayland, and SDL's X11 driver does have support for ibus/fcitx, but I'm not aware of any standard way to interact with the on-screen keyboard - does gamescope/wlroots expose this to X applications in some way? If we can add this to SDL, it would be a huge help for existing games; I've lost count of how many games I've had completely fail Deck cert because SDL_StartTextInput doesn't work on Steam Deck, even though it works great on normal Linux systems, and unfortunately updating Steamworks is not as trivial as updating SDL.

For reference, here's SDL's...

@misyltoad
Copy link
Collaborator

misyltoad commented Nov 13, 2022

Hi!

Gamescope has nothing to do with the Steam keyboard -- that's provided entirely by Steam.

There are two possible options we could do to make this work:

Option 1

SDL gets the GAMESCOPE_WAYLAND_DISPLAY, and uses its existing text_input_v3 interface to talk to Gamescope, which talks to Steam to open the keyboard.

We do technically support Wayland clients -- just not xdg-shell after all.

Option 2

SDL detects its running on Gamescope by checking the root window of the DISPLAY.

SDL uses xdg-open or whatever and just calls steam://open/keyboard?XPosition=%d&YPosition=%d&Width=%d&Height=%d&Mode=0 to open the keyboard

Some games on Steam that are bound by older Steam APIs as they use crappy middleware, etc end up doing this.


Maybe @slouken has an opinion on what method they would like in SDL?

@flibitijibibo
Copy link
Author

Option 2 would probably be the best route for the x11 driver - we could implement HasScreenKeyboard to check for gamescope, then StartTextInput could call the deeplink. We would probably just use whatever values make the equivalent of pressing Steam+X, if possible.

@misyltoad
Copy link
Collaborator

Option 2 needs nothing from our side so feel free to give it a shot if you think thats the best.

@flibitijibibo
Copy link
Author

I'll throw together a draft today - for Wayland clients we should definitely use the official protocol, but that can come from gamescope later IMO (SDL3?).

@slouken
Copy link
Collaborator

slouken commented Nov 13, 2022

Option 2 is also extendable to other environments, so I would vote for that as well.

@slouken
Copy link
Collaborator

slouken commented Nov 13, 2022

I would implement it via the ScreenKeyboard internal API, and call SDL_OpenURL() to open the on-screen keyboard. Maybe this is appropriate for src/core/steam/SDL_steam.c?

@slouken
Copy link
Collaborator

slouken commented Nov 13, 2022

We probably want to account for the case where there's a hardware keyboard attached?

@misyltoad
Copy link
Collaborator

We probably want to account for the case where there's a hardware keyboard attached?

Steam should handle that in the open/keyboard call.

@flibitijibibo
Copy link
Author

libsdl-org/SDL#6515

@flibitijibibo
Copy link
Author

This can now be seen in action with Salt & Sanctuary's native Linux version (which is currently being overridden by force, grumble):

https://steamcommunity.com/games/SaltandSanctuary/announcements/detail/5023230335822734611

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 a pull request may close this issue.

3 participants