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

[3.5 | Switch] Create Switch API for virtual keyboards #10

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

halotroop2288
Copy link
Member

@halotroop2288 halotroop2288 commented Jan 22, 2024

Adds a new NintendoSwitch global singleton for opening different types of virtual keyboard supported by Horizon OS.

This can be expanded to support other Switch-specific features later on.

I also went ahead and fixed a few bugs with the .gitignore.

@halotroop2288 halotroop2288 requested review from a team January 22, 2024 18:43
@halotroop2288 halotroop2288 self-assigned this Jan 22, 2024
@halotroop2288 halotroop2288 added enhancement New feature or request bug Something isn't working labels Jan 22, 2024
@halotroop2288 halotroop2288 force-pushed the pr/joy-motion branch 22 times, most recently from 1729dc9 to 394799c Compare January 23, 2024 17:48
@halotroop2288 halotroop2288 marked this pull request as ready for review January 23, 2024 17:57
@halotroop2288 halotroop2288 force-pushed the pr/joy-motion branch 2 times, most recently from eed976f to f7a5b0b Compare January 23, 2024 23:58
@halotroop2288 halotroop2288 changed the title [Switch] Create Switch API for virtual keyboards [3.5 | Switch] Create Switch API for virtual keyboards Jan 24, 2024
Copy link

@hokaze hokaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out why the keyboard wasn't showing in the test suite.

When the code was moved over from os_switch.cpp to api.cpp, there's some code for initialising the software keyboard that was shifted out of OS_Switch::run and into NintendoSwitch::initialize_software_keyboard():

...however, the initialize_software_keyboard() method isn't actually called anywhere, so the keyboard never gets setup properly.

In my own local changes to test and confirm this theory, I just put
NintendoSwitch::get_singleton()->initialize_software_keyboard();
On line 351 of os_switch.cpp below main_loop->init(), as that's where that code was previous to being moved to that method.


Other Issues I've just spotted:

  • For some reason, the first 2 characters of the TextEdit node can't be deleted, the keyboard acts as if it can't go any further left, either when deleting or when using L/R to move the cursor left/right
  • when focusing on the textedit to open the keyboard, I often get it automatically adding either an extra "g" or whatever the last character that was typed onto the end, sometimes 2 of such characters. They can be deleted as normal, but it only happens when the textedit is focused, not when opening the number pad
  • more a complaint with the libnx docs, but I have no idea what the difference is between the all languages keyboard and the default one opened on focusing the textedit - both have the same sets of characters by default and both have the option in the bottom left to change the keyboard layout
  • switch keyboard layout to other languages has the layout update correctly, but the actual characters entered into the text edit don't match the updated layout - tested this with german and japanese hiragana keysets, a lot of the time they just put Ã, a space, a unicode character like ©, etc instead of the actual character selected - this could be a problem with either the keyboard or with the text encoding on the textedit (although I think Godot uses UTF-8 by default, so should normally be fine)

I didn't notice anything massively amiss with the numpad, at least?

Don't have any lead on the keyboard inserting phantom keypresses or not letting you navigate all the way to the start of the string, as I didn't encounter either of those issues on the initial PR we did together for fixing Switch virtual keyboard

@halotroop2288
Copy link
Member Author

halotroop2288 commented Jan 26, 2024

The string length had to be adjusted for the NUL-terminator (NUL = 3 characters)

This solves the issue of not being able to remove all of the text.

image

@halotroop2288
Copy link
Member Author

The check needed to be for string length greater than zero, not any length other than zero. That's how we were getting erroneous characters when it started.

@halotroop2288
Copy link
Member Author

halotroop2288 commented Jan 26, 2024

OK, I'm going to merge this for now just to get it over with. It works perfectly the way it is, but my next PR will likely move this to its own module. I just want to have it out of the way for now.

This API should be considered UNSTABLE just for now. But I intend to fix it before the next release.

@halotroop2288 halotroop2288 merged commit 6a148bf into Homebrodot:main/3.5 Jan 26, 2024
15 checks passed
@halotroop2288 halotroop2288 deleted the pr/joy-motion branch January 26, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants