Skip to content

Commit

Permalink
add callback launching support for switch/wiiu
Browse files Browse the repository at this point in the history
  • Loading branch information
vgmoose committed Aug 21, 2023
1 parent a439292 commit 2c55c0e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- platform: switch
ext: nro
container:
image: ghcr.io/fortheusers/sealeo:latest
image: ghcr.io/fortheusers/sealeo:sha-1474053
steps:
- uses: actions/checkout@main
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "libs/json"]
path = libs/json
url = https://github.com/nlohmann/json.git
[submodule "libs/librpxloader"]
path = libs/librpxloader
url = https://github.com/wiiu-env/librpxloader.git
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ APP_VERSION := 2.1
SOURCES += . gui edit
CFLAGS += -DUSE_KEYBOARD

SOURCES += $(CHESTO_DIR)/libs/SDL_FontCache
VPATH += $(CHESTO_DIR)/libs/SDL_FontCache
SOURCES += $(CHESTO_DIR)/libs/SDL_FontCache
VPATH += $(CHESTO_DIR)/libs/SDL_FontCache

ifeq (wiiu,$(MAKECMDGOALS))
SOURCES += $(CHESTO_DIR)/libs/wiiu_kbd
VPATH += $(CHESTO_DIR)/libs/wiiu_kbd
SOURCES += $(CHESTO_DIR)/libs/wiiu_kbd libs/librpxloader/source
VPATH += $(CHESTO_DIR)/libs/wiiu_kbd
INCLUDES += ../libs/librpxloader/include
endif

include libs/chesto/Makefile
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

A basic SDL2 text editor designed for easy use on a video game console using a controller or touch screen. The primary goal of this project is to allow you to not have to turn to another device to edit text files.

## Passing files to vgedit
<img src="https://user-images.githubusercontent.com/2467473/83720891-fb573600-a607-11ea-9c18-42e5e75994fe.png" width="400" alt="File browser" /> <img src="https://user-images.githubusercontent.com/2467473/83720896-fdb99000-a607-11ea-9f8c-439da907aa76.png" width="400" alt="Editor View" />

### Passing files to vgedit
vgedit can be passed a file name to open by specifying it as the first argument on the command line. On PC this looks like `vgedit.exe test.txt`, and on Switch/Wii U, if supported, the calling homebrew can pass the argument before launching vgedit.

Another way to pass a target file is to write an `args.json` file in the same directory as vgedit. For example, to open `test.txt`:
Expand Down
6 changes: 6 additions & 0 deletions edit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ int main(int argc, char* argv[])

std::string startPath = START_PATH;

// USAGE: vgedit [file to edit path] [callback path]
if (argc > 1) {
// get the file path from the command line
startPath = argv[1];

// if there's a callback path, store it for later
if (argc > 2) {
display->callbackPath = argv[2];
}
}

// check if the args.json file exists
Expand Down
31 changes: 30 additions & 1 deletion gui/MainDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
#include "EditorView.hpp"
#include "FileBrowser.hpp"

#if defined(__WIIU__)
#include "../libs/librpxloader/include/rpxloader/rpxloader.h"
#endif

#if defined(SWITCH)
#include <switch.h>
#endif

MainDisplay::MainDisplay()
{
RootDisplay::super();
Expand Down Expand Up @@ -43,8 +51,29 @@ void MainDisplay::closeEditor()
// (single file mode)

if (callbackPath != "") {
// TODO: on switch/wiiu set the next nro/wuhb to launch
std::cout << "Launching " << callbackPath << std::endl;
bool success = false;

#ifdef __WIIU__
RPXLoaderStatus ret = RPXLoader_InitLibrary();
if (ret == RPX_LOADER_RESULT_SUCCESS) {
auto res = RPXLoader_LaunchHomebrew(callbackPath.c_str());
success = res == RPX_LOADER_RESULT_SUCCESS;
}
#endif

#ifdef SWITCH
// use envSetNextLoad to set the path to the app to launch
if (envHasNextLoad()) {
auto res = envSetNextLoad(callbackPath.c_str(), editorView->editor->filename); // give it the filename of the file we edited
success = R_SUCCEEDED(res);
}
#endif

if (!success) {
std::cout << "Failed to launch " << callbackPath << std::endl;
exit(1);
}
}

exit(0);
Expand Down
1 change: 1 addition & 0 deletions libs/librpxloader
Submodule librpxloader added at cad78b

0 comments on commit 2c55c0e

Please sign in to comment.