forked from libsdl-org/SDL
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Wii U: Add support for swkbd. #100
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
Open
dkosmari
wants to merge
11
commits into
devkitPro:wiiu-sdl2-2.28
Choose a base branch
from
dkosmari:wiiu-swkb
base: wiiu-sdl2-2.28
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- No more replacement of global new/delete operators; use strings with custom allocators instead. - Don't rely on C locale API, let the user control the locale explicitly. - A few more customization functions. - Properly documented all functions. - Added enums. - Input feeding from VPAD and KPAD is now public.
- Added function to manually disable the swkbd.
- Added missing include `<new>`. - Don't copy the user-supplied `nn::swkbd::AppearArg`.
Here's a sample program using this PR: https://github.com/dkosmari/devkitpro-autoconf/tree/main/examples/wiiu/sdl2-swkbd Here's an imgui fork using this PR: https://github.com/dkosmari/imgui
|
Now it no longer depends on libstdc++. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This adds support for the built-in software keyboard API.
By default, the application will get a working swkbd when calling
SDL_StartTextInput()
, with reasonable defaults.Platform-specific functions were added to
SDL_system.h
:SDL_WiiUSetSWKBDEnabled()
: allow the application to disable the swkbd. This can be called before initializing the video driver, which changes SDL's behavior (it will callSDL_StartTextInput()
during driver initialization, so the application ALWAYS receives text input events from the USB keyboard.) It can be called at any point later too, to disable or re-enable the swkbd. Disabling it will free up all memory allocated by the swkbd backend.SDL_WiiUSetSWKBDCreateArg()
andSDL_WiiUSetSWKBDAppearArg()
allow the application to directly control theCreateArg
andAppearArg
arguments to customize the swkbd. When either is set toNULL
, SDL will use its own internalCreateArg
andAppearArg
objects, providing the customization functions below.SDL_WiiUSetSWKBDLocale()
: allows the application to override the swkbd region/language. By default, the system region/language (from the system settings) will be used. The argument is a unix-style locale string ("en"
,"en_US"
,"ja"
,"en_GB"
,"ja_JP"
etc).Customization functions:
SDL_WiiUSetSWKBDHighlightInitialText()
SDL_WiiUSetSWKBDHintText()
SDL_WiiUSetSWKBDInitialText()
SDL_WiiUSetSWKBDKeyboardMode()
SDL_WiiUSetSWKBDOKLabel()
SDL_WiiUSetSWKBDPasswordMode()
SDL_WiiUSetSWKBDShowCopyPasteButtons()
SDL_WiiUSetSWKBDShowWordSuggestions()
These set the various fields of the internal
AppearArg
object. They're reset to their default values (documented inSDL_system.h
) after the swkbd is shown.Manual input:
SDL_WiiUSetSWKBDVPAD()
SDL_WiiUSetSWKBDKPAD()
This is necessary when the application is not using the SDL joystick/gamecontroller subsystem, and calling
VPADRead()
orKPADRead()
directly.New events
There are optional
SDL_SYSWMEVENT
messages generated by the swkbd when it closes. Theevent.syswm.msg->wiiu.event
field will be one of:SDL_WIIU_SYSWM_SWKBD_OK_START_EVENT
: sent when the "OK" button is pressed, before any text input event.SDL_WIIU_SYSWM_SWKBD_OK_FINISH_EVENT
: sent after all text input events (corresponding to the swkbd's text) are sent.SDL_WIIU_SYSWM_SWKBD_CANCEL_EVENT
: sent when the "Cancel" button is pressed.To receive any
SDL_SYSWMEVENT
the application needs to call:Justification: we cannot distinguish whether the text input event is coming from a hardware keyboard or the software keyboard. In a typical UI, hwkbd input will be inserted/deleted/replaced using a "current cursor position." But the swkbd has its own input form, with its own cursor and text selection handling; it produces the final string the UI text input widget should contain.
That means a text input event should either:
I do not know how to distinguish between both cases, on the application/UI code, other than making wild assumptions about the timing of the events. This more of a SDL design limitation, because the drag/drop events do have a begin/complete delimiters, to help combining multiple related events.
Limitations
This makes SDL depend onlibstdc++
, since thenn::swkbd
is a C++-only API. This dependency can be dropped when WUT gets a C API fornn::swkbd
.It no longer depends on
libstdc++
, as of 64ad1d7.