libnx is now capable of calling up system applets, including the virtual keyboard and captive portal browser. With these two components, it should be straightforward to implement a makeshift web browser. Here's how you use the keyboard:
#include <stdio.h>
#include <switch.h>
int main(int argc, char* argv[]) {
SwkbdConfig kbd;
Result rc;
consoleInit(NULL);
rc = swkbdCreate(&kbd, 0);
if (R_SUCCEEDED(rc)) {
swkbdConfigMakePresetDefault(&kbd);
char input[16] = {0};
rc = swkbdShow(&kbd, input, sizeof(input));
if (R_SUCCEEDED(rc)) {
printf("Got input: %s\n", input);
} else {
fprintf(stderr, "swkbdShow() error: %u\n", rc);
}
swkbdClose(&kbd);
} else {
fprintf(stderr, "swkbdCreate() error: %u\n", rc);
}
printf("Press + to exit.\n");
while (appletMainLoop()) {
hidScanInput();
u64 keyDown = hidKeysDown(CONTROLLER_P1_AUTO);
if (keyDown & KEY_PLUS) {
break;
}
consoleUpdate(NULL);
}
consoleExit(NULL);
}
Enjoyed this post? Got feedback? Consider following @Flygsand for the latest updates.
This post, excluding sample code, is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. See the example directory for code licensing.
© Martin Häger, 2018 - 2023.
v1.5.17 (changelog). Built with GraphQL, React and Semantic UI.