Hacking Gamepad drawString problems

D

Deleted User

Guest
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();
}
 
D

Deleted User

Guest
Oh freak. Thanks.
1. What does flipBuffers do?
2. What if I want it to be on the gamepad?
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.
 

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
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.
What if I want it to be on the gamepad?
Just change drawStringTV and fillScreenTV to drawString and fillScreen?
 
D

Deleted User

Guest
What if I want it to be on the gamepad?
Just change drawStringTV and fillScreenTV to drawString and fillScreen?
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);
}
 

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
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);
}
And for the TV? :3
 

eliboa

Well-Known Member
Member
Joined
Jan 13, 2016
Messages
157
Trophies
0
XP
1,257
Country
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.
 
D

Deleted User

Guest
And for the TV? :3
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?
 

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
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?
Yes, for TV it's:
Code:
OSScreenPutFontEx(0, x, line, string);
And for gamepad it's:
Code:
OSScreenPutFontEx(1, x, line, string);
:)
 
  • Like
Reactions: Deleted User

NWPlayer123

Well-Known Member
Member
Joined
Feb 17, 2012
Messages
2,642
Trophies
0
Location
The Everfree Forest
XP
6,693
Country
United States
But why it's called bufferNum, if it's changing the display? :gun::yayu:

--------------------- MERGED ---------------------------

Can somebody tell it?
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.
 

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
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);
}
And for fillScreenTV and fillScreenGamePad?

--------------------- MERGED ---------------------------

And for fillScreenTV and fillScreenGamePad?
Oh! I figured it out! I just need to call OSClearBufferEx with 0 or 1 bufferNum!
 
Last edited by hugofestA,

hugofestA

Well-Known Member
OP
Newcomer
Joined
Feb 10, 2016
Messages
52
Trophies
0
Age
32
Location
mast:3rw0rld
Website
oddity.comxa.com
XP
101
Country
Hungary
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();
}
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();
    }
}

--------------------- MERGED ---------------------------

: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,

NWPlayer123

Well-Known Member
Member
Joined
Feb 17, 2012
Messages
2,642
Trophies
0
Location
The Everfree Forest
XP
6,693
Country
United States
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();
    }
}

--------------------- MERGED ---------------------------

: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...
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
 
  • Like
Reactions: hugofestA

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Veho @ Veho: The cybertruck is a death trap.