Homebrew Infra Red Resource Thread

  • Thread starter Thread starter RedHat
  • Start date Start date
  • Views Views 63,845
  • Replies Replies 226
  • Likes Likes 10

Would you like to see development for IR homebrew (CPP or not) on the 3ds?

  • Yes, and I have the CPP!

    Votes: 41 19.2%
  • Yes, why not!

    Votes: 167 78.4%
  • No.

    Votes: 5 2.3%

  • Total voters
    213
I don't have that game, sorry (It's like a hackers dream, and I don't have it! Gah!)... Someone else should give it a shot!

Edit: The main post should now reflect the current status of the project! I am now off to github, whoo!
You forgot Dead or Alive Dimensions.
 
We'd have to do all of the testing again, but we should try for ir:USER too (I'm modifying the original test now, almost done). Games like Majora's Mask and MH3/MH4 should have access to it, considering they can use the CPP.

Edit: Yeah, had no problems getting Majora's Mask to get a handle to ir:USER. Only problem is, ir:USER is pretty much completely undocumented.
 
Last edited by daxtsu,
  • Like
Reactions: VegaRoXas
We'd have to do all of the testing again, but we should try for ir:USER too (I'm modifying the original test now, almost done). Games like Majora's Mask and MH3/MH4 should have access to it, considering they can use the CPP.
What is weird with both of the MH games is that when you try to launch them, the graphics get all weird (they never even initialize and I am certain that it is not my code)... Nothing is displayed on the bottom screen and the top screen goes nuts. Then, when you quit, homebrew launcher crashes and the 3DS must be powered off. Others might have to try to confirm this, however.

Yes, we should totally try ir:USER.

And, if you get a chance, either post your repository here and/or try and merge it with mine, either works.
 
I was thinking; since OOT and CN were the only things that worked, and those games are both used for exploits, maybe it works for those only because the exploit installed in it gives another homebrew more permissions or something?

This is probably far from right, but hey I could be on to something
 
What is weird with both of the MH games is that when you try to launch them, the graphics get all weird (they never even initialize and I am certain that it is not my code)... Nothing is displayed on the bottom screen and the top screen goes nuts. Then, when you quit, homebrew launcher crashes and the 3DS must be powered off. Others might have to try to confirm this, however.

Yes, we should totally try ir:USER.

And, if you get a chance, either post your repository here and/or try and merge it with mine, either works.
Same happens for example with acnl.
 
I was thinking; since OOT and CN were the only things that worked, and those games are both used for exploits, maybe it works for those only because the exploit installed in it gives another homebrew more permissions or something?

This is probably far from right, but hey I could be on to something
It also works with themehax, so I don't think it's because of that.
 
I don't think it's related if it's happening when the game first starts. Nothing is happening differently until the exploit triggers.
 
  • Like
Reactions: VegaRoXas
And, if you get a chance, either post your repository here and/or try and merge it with mine, either works.

I mostly just commented out the ir:u stuff and slipped in some ir:USER stuff (I had to improvise a little, since ctrulib doesn't have ir:USER code yet). You also forgot a free for the irmemloc block, so I inserted one down at the end, commented out.

Code:
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <setjmp.h>

#include <3ds.h>

#include "drawing.h"

static jmp_buf exitJmp;
// u32 *irmemloc;
// Result Startup;
Result irUSERStartup;
Result SetIR;
int frame = 0; // if the framerate is 60, every time we hit 60, 1 second has passed. 

Handle irUSERHandle = 0;

Result irUserInit()
{
    return srvGetServiceHandle(&irUSERHandle, "ir:USER");
}

void irUserExit()
{
    if (irUSERHandle)svcCloseHandle(irUSERHandle);
}

void hang(char *message) {
    while(aptMainLoop()) {
        hidScanInput();
       
        clearScreen();
        drawString(10, 10, "%s", message);
        drawString(10, 20, "Start and Select to exit");
       
        u32 kHeld = hidKeysHeld();
        if((kHeld & KEY_START) && (kHeld & KEY_SELECT)) longjmp(exitJmp, 1);
       
        gfxFlushBuffers();
        gspWaitForVBlank();
        gfxSwapBuffers();
    }
}

int main(void) {
    //irmemloc = (u32*) malloc(0x1000);
    //Startup = IRU_Initialize(irmemloc, 0x1000);
    irUSERStartup = irUserInit();
    srvInit();        // services
    aptInit();        // applets
    hidInit(NULL);    // input
    gfxInitDefault(); // gfx
   
    gfxSetDoubleBuffering(GFX_TOP, true);
    gfxSetDoubleBuffering(GFX_BOTTOM, true);
   
    if(setjmp(exitJmp)) goto exit;
   
    clearScreen();
    gfxFlushBuffers();
    gfxSwapBuffers();
   
    while(aptMainLoop()) {
        hidScanInput();
        irrstScanInput();
       
        u32 kHeld = hidKeysHeld();
        circlePosition circlePad;
        circlePosition cStick;
        //circlePosition circlePadPro;
        u8 vol8;
        u8* volp = &vol8;
        hidCstickRead(&cStick);
        hidCircleRead(&circlePad);
        HIDUSER_GetSoundVolume(volp);
        touchPosition touch;
        touchRead(&touch);
       
        clearScreen();
       
        char keys[30] = "ABXY URDL SEST LR ZLZR";
       
        if(kHeld & KEY_A) {
            keys[0] = '*';
        }
        if(kHeld & KEY_B) {
            keys[1] = '*';
        }
        if(kHeld & KEY_X) {
            keys[2] = '*';
        }
        if(kHeld & KEY_Y) {
            keys[3] = '*';
        }
        if(kHeld & KEY_DUP) {
            keys[5] = '*';
        }
        if(kHeld & KEY_DRIGHT) {
            keys[6] = '*';
        }
        if(kHeld & KEY_DDOWN) {
            keys[7] = '*';
        }
        if(kHeld & KEY_DLEFT) {
            keys[8] = '*';
        }
        if(kHeld & KEY_SELECT) {
            keys[10] = '*';
            keys[11] = '*';
        }
        if(kHeld & KEY_START) {
            keys[12] = '*';
            keys[13] = '*';
        }
        if(kHeld & KEY_L) {
            keys[15] = '*';
        }
        if(kHeld & KEY_R) {
            keys[16] = '*';
        }
        if(kHeld & KEY_ZL) {
            keys[18] = '*';
            keys[19] = '*';
        }
        if(kHeld & KEY_ZR) {
            keys[20] = '*';
            keys[21] = '*';
        }
        drawString(10, 10, keys);
        drawString(10, 20, "Volume: %d", vol8);
        drawString(10, 30, "Circle Pad   x: %04+d, y: %04+d", circlePad.dx, circlePad.dy);
        drawString(10, 40, "CStick (new) x: %04+d, y: %04+d", cStick.dx, cStick.dy );
        drawString(10, 50, "CPadPr (old) x: NaN , y: NaN", cStick.dx, cStick.dy );
        drawString(10, 60, "Touch        x: %04d, y: %04d", touch.px, touch.py );
        drawString(10, 70, "ir:USER Init  Error: %x", irUSERStartup);
        drawString(10, 80, "IR I/O   Error: %x", SetIR);
        frame++;
        if(frame == 60) {
            frame = 0;
        }
        if(frame == 58 || frame == 59) {
            SetIR = IRU_SetIRLEDState(0x1);
            drawString(10, 90, "IR state:*");
        } else {
            SetIR = IRU_SetIRLEDState(0x0);
            drawString(10, 90, "IR state:");
        }
       
        drawString(10, 220, "Start + Select to exit.");

       
        if((kHeld & KEY_START) && (kHeld & KEY_SELECT)) longjmp(exitJmp, 1);
       
        gfxFlushBuffers();
        gspWaitForVBlank();
        gfxSwapBuffers();
    }
   
    exit:
   
    //IRU_Shutdown();
    //free(irmemloc);
    irUserExit();
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
   
    return 0;
}
 

Attachments

I tried quite a few on Ironhax.
Music app:
Fail
Camera app: Fail
eShop: Fail
AR Games: Fail
Settings: Fail
Pokemon Shuffle: Fail
Pokemon Rumble World: Fail
The Last Ranger: Fail
Flipnote Studio 3D: Fail
Steamworld Dig: Fail
Steel Diver Sub Wars: Fail
Crashmo: Fail
2Fast4Gnomz: Fail

I will try more later.
 
Last edited by teampleb,
You also forgot a free for the irmemloc block
Shoot! I thought it did that on return 0! I am a Java programmer, guess I am used to garbage collectors :/

I tried quite a few on Ironhax.
Music app:
Fail
Camera app: Fail
eShop: Fail
AR Games: Fail
Settings: Fail
Pokemon Shuffle: Fail
Pokemon Rumble World: Fail
The Last Ranger: Fail
Flipnote 3D: Fail
Steamworld Dig: Fail
Steel Diver Sub Wars: Fail
Crashmo: Fail
2Fast4Gnomz: Fail

Thank you so much! I hope we don't end with just 3-4 games at this point...
 
Shoot! I thought it did that on return 0! I am a Java programmer, guess I am used to garbage collectors :/

Depending on the operating system, it *might* free used memory nicely for you at application exit, but in C, you should never assume that memory is auto-freed.
 
Depending on the operating system, it *might* free used memory nicely for you, but in C, you should never assume that memory is auto-freed.
I'll take a note of that. I think for some methods I am about to write it'll allocate some more memory, so I'll make sure to free it.
 
Oh, I'm on n3DS 10.1 with Ironhax BTW. I'm just testing if the IR port turns on. :)
You won't have to test the standard titles (e.g. camera, ar games, music etc). They don't work.
At least on a 2ds they don't. But since we are on the same fw it shouldn't work for you either.
 

Site & Scene News

Popular threads in this forum