HomeMenu/Installation and usage
Installation and usage
Installation
- Copy all the .c and .h files into your project (make sure the .c are accessible as sources and .h accessible as includes).
- Add
#include "HomeMenu.h"
where appropriate. - Add
-lasnd -lwiiuse
to your MakeFile'sLIBS :=
line.
Usage
- Call
HomeMenu_Init()
to set things up. Its parameters are:int screenWidth
-- horizontal resolution of screen.int screenHeight
-- vertical resolution of screen.void* framebuffer0
-- pointer to the first framebuffer.void* framebuffer1
-- pointer to the second framebuffer (Currently assumes double-buffering).u8 framebufferIndex
-- index to last buffer drawn to [0, 1].
- Specify graphics library with
HomeMenu_SetGFX()
. Accepted values are:HM_GFX_GRRLIB
HM_GFX_LIBWIISPRITE
HM_GFX_FAILSAFE
(which currently draws nothing).
- Specify sound library with
HomeMenu_SetSND()
. Accepted values are:HM_SND_ASND
HM_SND_SDL
(not yet implemented)HM_SND_NOSOUND
.
- When you want to display the menu (when the user presses HOME), simply call
HomeMenu_Show()
. In order for HomeMenu to be able to take a screenshot (used as the menu background)HomeMenu_Show()
must be called before flushing the framebuffer.
Tip: If you have a callback set up for when the user holds down on the wiimote's powerbutton, add HomeMenu_Hide()
to this callback to tell HomeMenu to relinquish its control of the main thread.
Tip: If your application relies on a timer, consider using the HomeMenu_SetAfterHideMenu(yourCallback)
callback setter. This will allow you to update your timer (if necessary) before resuming your application.
Libwiisprite users
Currently, the pointers to the framebuffers and the framebuffer index are stored in the GameWindow
object as private
members. Shiny Red Tank got around this problem by adding accessors to the GameWindow
class. Hopefully, if there is enough demand, the accessors will be included in the next version of LWS (go ask!). Here are my modifications:
Changes to GameWindow.h |
---|
/*** Add the following lines in the public section ***/
//!Get a pointer to one of the framebuffers
//!\return a pointer to desired framebuffer, or NULL if index is out of bounds.
void* GetFrameBuffer(u32 index);
//!Gets the index of the current framebuffer.
//!\return value of index of current framebuffer.
u32 GetFrameBufferIndex(); |
Changes to GameWindow.cpp |
---|
/*** Add the following lines within the namespace wsp block ***/
void* GameWindow::GetFrameBuffer(u32 index) {
if (index > 1 || index < 0)
return NULL;
else
return _frameBuffer[index];
}
u32 GameWindow::GetFrameBufferIndex() {
return _fb;
} |
GRRLIB 4.0.0 users
I think the same problem (as mentioned above) applies to you guys. Here are the accessors I used during my testing.
Changes to GRRLIB.h |
---|
void* GetFrameBuffer(u32 index);
int GetFrameBufferIndex(); |
Changes to GRRLIB.c |
---|
/**
* Get a pointer to one of the framebuffers.
* @param index specifies which framebuffer to retrieve.
*/
void* GetFrameBuffer(u32 index) {
return xfb[index];
}
/**
* Get the index of the current framebuffer.
*/
int GetFrameBufferIndex() {
return fb;
} |