Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,390
  • Replies Replies 6,048
  • Likes Likes 54
Any ideas about how to use ACU_GetWifiStatus properly?
Code:
    u32 enabled = 0;
    ACU_GetWifiStatus(&enabled);

    if (enabled == 0)
    {
        drawErr_btm("WiFi is disabled. \nPlease enable it by pulling the wifi switch.\n\nPress A button when done.");
        while (aptMainLoop())
        {
            hidScanInput();
            if (hidKeysUp() & KEY_A)
            {
                    checkWifi();
            }          
        }
    }
This is the code of the function on my homebrew that uses ACU_GetWifiStatus. According to ctrulib doxygen, ACU_GetWifiStatus feeds the pointed u32 with 0 if wifi is disabled. But when I run it, the code on if block is executed even if Wifi is enabled. I tested on both Citra and on real hardware. Any ideas?

Did you initialize the AC service by calling acInit()?
 
Hey guys, I need some help.
I've been recently developing a romFS file explorer, so far it works and can mount romfs files from SD card or from a selected title (HBL only).
One of the planned features is file extracting from romFS to SD card, however I've been unable to get this working as fread seems to always return 0 no matter what I do and how I do. Here is my code:
Code:
FILE *src = fopen((*source)[i].path.c_str(), "rb");
u64 fsize = (*source)[i].size;
char *buffer = (char*)malloc(fsize);
u64 size = fread(buffer, 1, fsize, src);
FILE *dst = fopen((dest + (*source)[i].name).c_str(), "wb");
fwrite(buffer, 1, size, dst);
free(buffer);
fclose(src);
fclose(dst);
fsize is correct (tested by printing its value on screen).
fwrite is working, but the output is either an empty file or random garbage data.
The source file is indeed open, as I was able to get the filesize (on another test), and it is at position 0 (tried rewind too, with no changes).
Also tried fstream, with same results.
 
I can't see why this doesnt compile (gives undefined errors on my std:: line,look at pic)
From what ive found on google some people have this problem when using a 'C' compiler rather than a C++ one?
5069bec5a2.png

Code:
#include <3ds.h>
#include <fstream>
#include <stdio.h>
#include <fstream>
#include <ctime>
#include <string>

int main(int argc, char **argv) {
    gfxInitDefault();
    consoleInit(GFX_TOP, NULL);
  
    std::ofstream ofs ("/text.txt", std::ofstream::out);

    ofs << "lorem ipsum";
    ofs.close();
  
    printf("Fire Emblem: Fates - Difficulty Modifier \nAttemping to load text file: text.txt");  
    printf("\x1b[20;15HPress Start to exit.");
  
  
  

    while(aptMainLoop()) {
        gspWaitForVBlank();
        hidScanInput();

        if(hidKeysDown() & KEY_START)
            break;

        gfxFlushBuffers();
        gfxSwapBuffers();
    }

    gfxExit();
    return 0;
}
 
Any ideas about how to use ACU_GetWifiStatus properly?
Code:
    u32 enabled = 0;
    ACU_GetWifiStatus(&enabled);

    if (enabled == 0)
    {
        drawErr_btm("WiFi is disabled. \nPlease enable it by pulling the wifi switch.\n\nPress A button when done.");
        while (aptMainLoop())
        {
            hidScanInput();
            if (hidKeysUp() & KEY_A)
            {
                    checkWifi();
            }          
        }
    }
This is the code of the function on my homebrew that uses ACU_GetWifiStatus. According to ctrulib doxygen, ACU_GetWifiStatus feeds the pointed u32 with 0 if wifi is disabled. But when I run it, the code on if block is executed even if Wifi is enabled. I tested on both Citra and on real hardware. Any ideas?
I take it ACU_GetWifiStatus(&enabled); is setting the enabled?
 
I can't see why this doesnt compile (gives undefined errors on my std:: line,look at pic)
From what ive found on google some people have this problem when using a 'C' compiler rather than a C++ one?

That's because the std namespace, fstream, stdio and string are all part of the C++ standard library, thus requiring a C++ compiler.
 
Hey guys, I need some help.
I've been recently developing a romFS file explorer, so far it works and can mount romfs files from SD card or from a selected title (HBL only).
One of the planned features is file extracting from romFS to SD card, however I've been unable to get this working as fread seems to always return 0 no matter what I do and how I do. Here is my code:
Code:
FILE *src = fopen((*source)[i].path.c_str(), "rb");
u64 fsize = (*source)[i].size;
char *buffer = (char*)malloc(fsize);
u64 size = fread(buffer, 1, fsize, src);
FILE *dst = fopen((dest + (*source)[i].name).c_str(), "wb");
fwrite(buffer, 1, size, dst);
free(buffer);
fclose(src);
fclose(dst);
fsize is correct (tested by printing its value on screen).
fwrite is working, but the output is either an empty file or random garbage data.
The source file is indeed open, as I was able to get the filesize (on another test), and it is at position 0 (tried rewind too, with no changes).
Also tried fstream, with same results.

I'm on mobile and reading source code from here is a pain but from a quick glance this snippet looks correct, so the problem should reside somewhere else. Are you calling romfsInit() before trying to access the files on the romfs? First thing that comes to mind.
 
I'm on mobile and reading source code from here is a pain but from a quick glance this snippet looks correct, so the problem should reside somewhere else. Are you calling romfsInit() before trying to access the files on the romfs? First thing that comes to mind.

I'm using romfsInitFromFile. The romFS is then mounted, I can explore the files, add to clipboard, get filesize and attributes, etc.
The only thing that's not working is file extraction.
I'll try using ctrulib's fs functions instead of standard C/C++ functions and see if it works.
 
Having problems with fopen().
Code:
    drawWrn_btm("Openning...");
    FILE *cfg = fopen("sdmc:/server.json", "rb");
    if (cfg == NULL)
    {
        drawErr_btm("server.json doesn't exists.\nOr maybe a read error occured.\n\nPress A to back to HBL");
        while (aptMainLoop())
        {
            hidScanInput();
            if (hidKeysUp() & KEY_A)
            {
                break;
            }
        }           
    }
Okay, here's the issue. I call fopen to open the json file for further parsing, but the application freeze.
So, I implemented this if block, to check if the handle is null. Even with this the freeze happens. The error message isn't even displayed at all, it freezes at "Openning."
Any ideas?
 
Having problems with fopen().
Okay, here's the issue. I call fopen to open the json file for further parsing, but the application freeze.
So, I implemented this if block, to check if the handle is null. Even with this the freeze happens. The error message isn't even displayed at all, it freezes at "Openning."
Any ideas?

Try this and see if it works:
Code:
    drawWrn_btm("Openning...");
    char fname[] = "/server.json";
    FILE *cfg = fopen(fname, "rb");
    if (cfg == NULL)
    {
        drawErr_btm("server.json doesn't exists.\nOr maybe a read error occured.\n\nPress A to back to HBL");
        while (aptMainLoop())
        {
            hidScanInput();
            if (hidKeysUp() & KEY_A)
            {
                break;
            }
        }         
    }
 
Also managed to fix my issue, make file indeed was only trying to compile C not C++ as I suspected, modified makefile replacement and now it all compiles perfectly
 
>Was able to fix another user's issue
>Still can't solve my own

To be honest it's the first time that I mess with homebrew development, so I don't have a clue about how to help you.

Anyways your fopen() workaround worked, but after implementing more things (without touching the fopen() call!) it started freezing again.
L+R+Down+B in this case doesn't even work, forcing me to reboot the console. But after a hour trying to discover what I did wrong, the function was too big (I think that this caused it)
Then I chopped it into 3 parts (read file, put into ram and parse) and set the first one to chaincall until end. This fixed my issue.
 
How do I print an item once in the main loop?
It keeps repeating so I cant build a menu properly

Are you using printf to set the cursor to a fixed position? Like this:
Code:
printf("\x1b[0;0HHello World!");

Here is an example that should work during a loop:
Code:
printf("\x1b[0;0HI'm on line 1.");
printf("\x1b[1;0HI'm on line 2.\x1b[2;0HI'm on line 3.");
int line = 10;
printf("\x1b[%i;0HI'm on line 10.", line);
int position = 7;
printf("\x1b[1;%iHI'm on line 2, position 7.", position);
 
Are you using printf to set the cursor to a fixed position? Like this:
Code:
printf("\x1b[0;0HHello World!");

Here is an example that should work during a loop:
Code:
printf("\x1b[0;0HI'm on line 1.");
printf("\x1b[1;0HI'm on line 2.\x1b[2;0HI'm on line 3.");
int line = 10;
printf("\x1b[%i;0HI'm on line 10.", line);
int position = 7;
printf("\x1b[1;%iHI'm on line 2, position 7.", position);
Even when I do that it seemed to freak out from what I recall, ill try that again
(I knew you could print in a certain area with that snippet at the front of a string but it didnt seem to work o.0)
 
Have a separate function that draws your menu, add a call to printf with "\x1b[2J" at the beginning to clear the screen.
Also, instead of drawing the menu every frame, just draw it when something has changed and it won't be all flickery.
 

Site & Scene News

Popular threads in this forum