Gamepad drawString problems

Discussion in 'Wii U - Hacking & Backup Loaders' started by hugofestA, Feb 26, 2016.

  1. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Hi! I have some problems with drawstring();
    Can somebody check it?

    loader.c
    loader.h

    Thanks,
    hugo
    (P.S.: I should learn more about stuff before talking about I will write a kexploit :D)
    (P.P.S.: nvm if you missed that post)
     
  2. Voxel

    Voxel u wot

    Member
    GBAtemp Patron
    Voxel is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,218
    5,965
    Jun 27, 2015
    United Kingdom
    England, UK
    You're missing flipBuffers() that's the problem.
    Code:
    void _start()
    {
       fillScreenTV(0,0,0,0);
       drawStringTV(0, 0, "Restart your Wii U.\n\n\n\n\nSorry.")
       flipBuffers();
    }
    
     
  3. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Oh freak. Thanks.
    1. What does flipBuffers do?
    2. What if I want it to be on the gamepad?
     
  4. Voxel

    Voxel u wot

    Member
    GBAtemp Patron
    Voxel is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,218
    5,965
    Jun 27, 2015
    United Kingdom
    England, UK
    I don't know the technical reason why you need flipBuffers(), but it's always required when drawing stuff. Take a look at some source code of other apps and study how the program actually works. It will give you a good steady boost of knowledge of how to actually code a homebrew app.
     
  5. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    What if I want it to be on the gamepad?
    Just change drawStringTV and fillScreenTV to drawString and fillScreen?
     
  6. Voxel

    Voxel u wot

    Member
    GBAtemp Patron
    Voxel is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,218
    5,965
    Jun 27, 2015
    United Kingdom
    England, UK
    Oh god, I forgot. I'm using my own custom drawing library so it wouldn't be like that. It'd just be drawString in your average libwiiu. :wink:

    for you, I'd add this code into draw.c in libwiiu/src/draw.c if you want to just draw a string to the GamePad:

    Code:
    void drawStringGamePad(int x, int line, char * string)
    {
       unsigned int coreinit_handle;
       OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
       unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
       OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
       OSScreenPutFontEx(1, x, line, string);
    }
    
     
  7. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    And for the TV? :3
     
  8. eliboa

    eliboa Member

    Newcomer
    49
    56
    Jan 13, 2016
    France
    I think you can't to that whith os_screen functions. You have to use GX2 lib if you want to draw something different on tv and gamepad.
     
  9. Voxel

    Voxel u wot

    Member
    GBAtemp Patron
    Voxel is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,218
    5,965
    Jun 27, 2015
    United Kingdom
    England, UK
    Code:
    void drawStringTV(int x, int line, char * string)
    {
       unsigned int coreinit_handle;
       OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
       unsigned int(*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int line, void * buffer);
       OSDynLoad_FindExport(coreinit_handle, 0, "OSScreenPutFontEx", &OSScreenPutFontEx);
       OSScreenPutFontEx(0, x, line, string);
    }
    
    Notice any difference between the two functions?
     
  10. eliboa

    eliboa Member

    Newcomer
    49
    56
    Jan 13, 2016
    France
    Ok, apparently it is possible :D Sorry..
     
    Voxel likes this.
  11. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Yes, for TV it's:
    Code:
    OSScreenPutFontEx(0, x, line, string);
    
    And for gamepad it's:
    Code:
    OSScreenPutFontEx(1, x, line, string);
    
    :)
     
    Voxel likes this.
  12. Voxel

    Voxel u wot

    Member
    GBAtemp Patron
    Voxel is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,218
    5,965
    Jun 27, 2015
    United Kingdom
    England, UK
    We're finally getting somewhere now! ;)
     
  13. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    But why it's called bufferNum, if it's changing the display? :gun::yayu:

    — Posts automatically merged - Please don't double post! —

    Can somebody tell it?
     
  14. NWPlayer123

    NWPlayer123 GBAtemp Addict

    Member
    2,632
    6,233
    Feb 17, 2012
    United States
    The Everfree Forest
    It's "double buffered", 0 is TV and 1 is Gamepad, think of it like a piece of paper, the program writes it on the bottom and you have to flip it over to see it. There's 2 pieces of paper, one for TV and one for Gamepad.
     
  15. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    And for fillScreenTV and fillScreenGamePad?

    — Posts automatically merged - Please don't double post! —

    Oh! I figured it out! I just need to call OSClearBufferEx with 0 or 1 bufferNum!
     
    Last edited by hugofestA, Feb 26, 2016
  16. hugofestA
    OP

    hugofestA Advanced Member

    Newcomer
    52
    7
    Feb 10, 2016
    Hungary
    mast:3rw0rld
    Do I need to run this in a loop, like this?
    Code:
    void _start()
    {
        while(1){
            fillScreenTV(0,0,0,0);
            drawStringTV(0, 0, "Restart your Wii U.\n\n\n\n\nSorry.");
            flipBuffers();
        }
    }
    
    — Posts automatically merged - Please don't double post! —

    :gun::insert emoji of my profile picture here:
    I'm so stupid.
    Can somebody lock/delete these threads?
    P.S.: Nobody said there's an osscreentemplates folder...
     
    Last edited by hugofestA, Feb 27, 2016
  17. NWPlayer123

    NWPlayer123 GBAtemp Addict

    Member
    2,632
    6,233
    Feb 17, 2012
    United States
    The Everfree Forest
    Nah, only need to call it once, the back buffer and front buffer won't change unless you run code to, that's just doing unnecessary work for the same result. and yeah, OSScreenTemplates is also pretty helpful. I should commit my old Mario sprite test there
     
    hugofestA likes this.