Homebrew Discussion Does anyone have a working method of text input?

jfmherokiller

Well-Known Member
OP
Newcomer
Joined
Jan 6, 2017
Messages
51
Trophies
0
Age
27
XP
226
Country
United States
I would like to attempt to port something like Zork to the switch but I'm unable to devise my own method of allowing the player to input text.

Something like the input method used in godmode9 as linked below would work just fine.
https://github.com/d0k3/GodMode9/blob/master/arm9/source/common/ui.c#L636

I also found this
https://github.com/zrafa/onscreenkeyboard

I'm asking if this exists because as far as my reading of the libnx source code allowed me to observe. It does not have the ability to launch library applets yet.
So what I would like to know is if someone has already created a good method.

I attempted to copy the behavior of godmode9 myself and my attempt which is still in the early stages can be seen in the gist below.
https://gist.github.com/jfmherokiller/288b95479593ea0e25f3c866b537d718
https://gist.github.com/jfmherokiller/288b95479593ea0e25f3c866b537d718
 

jfmherokiller

Well-Known Member
OP
Newcomer
Joined
Jan 6, 2017
Messages
51
Trophies
0
Age
27
XP
226
Country
United States
You could check this out: https://github.com/misson20000/swkbd-demo

Switchbrew also has information on it: http://switchbrew.org/index.php?title=Software_Keyboard

You might/will need to adjust the homebrew loader's (https://github.com/switchbrew/nx-hbloader) wonky memory stuff, though.
Thank you for that I was attempting to launch it via code copied from the file https://github.com/switchbrew/libnx/blob/master/nx/source/services/applet.c

Which wasnt exactly working, only issue with what you linked is its using the libtransistor library while I primarily use libnx. But ill see if i can convert it.
 
Last edited by jfmherokiller,

jfmherokiller

Well-Known Member
OP
Newcomer
Joined
Jan 6, 2017
Messages
51
Trophies
0
Age
27
XP
226
Country
United States
In terms of converting thier code into something i can use I seem to have hit a snag. I seem to be unable to replicate thier IStorageAccessor Write function using libnx.
Their implementation correctly calls the function in yuzu. While, my implementation seems to just crash yuzu with no output on why it crashed (In the log It does not even show the api being called).
I know its something with my implementation because my GetSize implementation works correctly and shows up in the yuzu log.
If I had to guess I'd say something is going on with the buffer it needs.

heres how its being called in context
Code:
u32 common_args_header[] = {0x1, 0x20}; // {version?, size?}
rc = StorageWrite(StorageAccessHandle, 0, (uint8_t *) common_args_header, sizeof(common_args_header));

My Implementation
Code:
Result StorageWrite(Handle srv, u64 offset, const uint8_t *data, size_t size) {
    IpcCommand c;
    ipcInitialize(&c);

    struct {
        u64 magic;
        u64 cmd_id;
        u64 offset;
    } *raw;

    raw = ipcPrepareHeader(&c, sizeof(*raw));

    raw->magic = SFCI_MAGIC;
    raw->cmd_id = 10;
    raw->offset = offset;
    ipcAddSendBuffer(&c, (void *) data, size, 0x21);

    Result rc = ipcDispatch(srv);

    if (R_SUCCEEDED(rc)) {
        IpcParsedCommand r;
        ipcParse(&r);

        struct {
            u64 magic;
            u64 result;
        } *resp = r.Raw;

        rc = resp->result;
    }

    return rc;
}
their implementation
Code:
void IStorageAccessor::Write(size_t offset, const uint8_t *data, size_t size) {
   ResultCode::AssertOk(
      object.SendSyncRequest<10>(
         ipc::InRaw<uint64_t>(offset),
         ipc::Buffer<uint8_t, 0x21>((uint8_t*) data, size)));
}
Below is how the buffer is implemented in libnx and libtransistor
Code:
~~~~~~LIBNX~~~~~~
* @brief Adds a buffer to an IPC command structure.
* @param cmd IPC command structure.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param type Buffer type.
*/
static inline void ipcAddSendBuffer(IpcCommand* cmd, const void* buffer, size_t size, BufferType type) {
   size_t off = cmd->NumSend;
   cmd->Buffers[off] = buffer;
   cmd->BufferSizes[off] = size;
   cmd->BufferTypes[off] = type;
   cmd->NumSend++;
}
~~~~~~LIBTRANSISTOR~~~~~
template<typename T, uint32_t type, size_t expected_size> 
struct FormatMutator<ipc::Buffer<T, type, expected_size>> {
   static AccessorHelper<ipc::Buffer<T, type, expected_size>> MutateFormat(TransactionFormat &fmt) {
     ipc_buffer_t *buffer = new ipc_buffer_t();
     buffer->type = type;
     buffer->size = expected_size;
    fmt.buffers.push_back(buffer);
    return AccessorHelper<ipc::Buffer<T, type, expected_size>>(buffer);
   }
};
 
Last edited by jfmherokiller,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • S @ salazarcosplay:
    and good morning everyone
    +1
  • K3Nv2 @ K3Nv2:
    @BakerMan, his partner is Luke
    +1
  • Sicklyboy @ Sicklyboy:
    Sup nerds
    +1
  • Flame @ Flame:
    oh hi, Sickly
  • K3Nv2 @ K3Nv2:
    Oh hi flame
  • S @ salazarcosplay:
    @K3Nv2 what was your ps4 situation
  • S @ salazarcosplay:
    did you always have a ps4 you never updated
  • S @ salazarcosplay:
    or were you able to get new ps4 tracking it \
    as soon as the hack was announced
  • S @ salazarcosplay:
    or did you have to find a used one with the lower firm ware that was not updated
  • K3Nv2 @ K3Nv2:
    I got this ps4 at launch and never updated since 9.0
  • K3Nv2 @ K3Nv2:
    You got a good chance of buying a used one and asking the seller how often they used or even ask for a Pic of fw and telling them not to update
  • RedColoredStars @ RedColoredStars:
    Speaking of PLaystation. I see Evilnat put out a beta for PS3 CFW 4.91.2 on the 22nd.
  • K3Nv2 @ K3Nv2:
    Don't really see the point in updating it tbh
  • BigOnYa @ BigOnYa:
    Yea you right, I thought about updating my PS3 CFW to 4.91, but why really, everything plays fine now. I guess for people that have already updated past 4.9 it would be helpful.
  • K3Nv2 @ K3Nv2:
    Idk if online servers are still active that would be my only thought
    +1
  • BigOnYa @ BigOnYa:
    Thats true, personally I don't play it online at all, in fact, I deleted all wifi details on it once I installed CFW, so it won't connect and auto-update itself
  • BigOnYa @ BigOnYa:
    I play most games that are on both PS3/360 strickly on the 360, but PS3 exclusives are really only games I play on the PS3 (You know me, I'm more of a Xbox junkie)
  • K3Nv2 @ K3Nv2:
    Ps3 really has no titles worth going online over nps is the only reason you'd want wifi
  • BigOnYa @ BigOnYa:
    what is nps?
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, what about GTA v onl... O Yea the PS3 versión got discontinued
  • K3Nv2 @ K3Nv2:
    I feel like the world's cheapest pc build can play gtaV
  • K3Nv2 @ K3Nv2:
    In modern standards
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, then why mine can't?
  • BigOnYa @ BigOnYa:
    @K3Nv2 What is nps you mentioned?
  • K3Nv2 @ K3Nv2:
    Because your pc has a hamster innit
    +2
    K3Nv2 @ K3Nv2: Because your pc has a hamster innit +2