Testing
This commit is contained in:
parent
ef8b3e8fa5
commit
aeda01b524
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
#include <grrlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "pads.h"
|
||||
|
||||
typedef struct {
|
||||
GRRLIB_ttfFont *myFont;
|
||||
} app_global_data_t;
|
||||
|
||||
extern app_global_data_t* global_data;
|
25
src/main.cpp
25
src/main.cpp
|
@ -4,25 +4,32 @@
|
|||
|
||||
Minimum Code To Use GRRLIB
|
||||
============================================*/
|
||||
#include <grrlib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "FreeMonoBold_ttf.h"
|
||||
|
||||
app_global_data_t* global_data;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
global_data=(app_global_data_t*)calloc(1,sizeof(app_global_data_t));
|
||||
// Initialise the Graphics & Video subsystem
|
||||
GRRLIB_Init();
|
||||
|
||||
// Initialise the Wiimotes
|
||||
WPAD_Init();
|
||||
global_data->myFont =GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size);
|
||||
|
||||
// Initialise the Controllers
|
||||
Ctrl_Init();
|
||||
|
||||
|
||||
// Loop forever
|
||||
while(1) {
|
||||
GRRLIB_SetBackgroundColour(0xff, 0x00, 0x00, 0xFF);
|
||||
Ctrl_ScanPads(); // Scan the Controllers
|
||||
|
||||
WPAD_ScanPads(); // Scan the Wiimotes
|
||||
// If [HOME] was pressed on the first Controller, break out of the loop
|
||||
if (Ctrl_ButtonsDown(0) & PAD_BUTTON_START) break;
|
||||
|
||||
// If [HOME] was pressed on the first Wiimote, break out of the loop
|
||||
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
|
||||
if(Ctrl_ButtonsDown(0) & PAD_BUTTON_A) GRRLIB_PrintfTTF(200,200,global_data->myFont,"A Pressed",12,0xFFFFFFFF);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Place your drawing code here
|
||||
|
@ -32,6 +39,8 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
|
||||
GRRLIB_FreeTTF(global_data->myFont);
|
||||
free(global_data);
|
||||
|
||||
exit(0); // Use exit() to exit a program, do not use 'return' from main()
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#include "controller.h"
|
||||
|
||||
void Ctrl_Init()
|
||||
{
|
||||
PAD_Init();
|
||||
#if defined(HW_RVL)
|
||||
WPAD_Init();
|
||||
#endif
|
||||
}
|
||||
void Ctrl_ScanPads()
|
||||
{
|
||||
PAD_ScanPads();
|
||||
#if defined(HW_RVL)
|
||||
WPAD_ScanPads();
|
||||
#endif
|
||||
}
|
||||
|
||||
u32 Ctrl_ButtonsDown(int pad)
|
||||
{
|
||||
u32 buttons=PAD_ButtonsDown(pad);
|
||||
#if defined(HW_RVL)
|
||||
u32 wbuttons = WPAD_ButtonsDown(pad);
|
||||
if(wbuttons & WPAD_BUTTON_A) buttons |= PAD_BUTTON_A;
|
||||
if(wbuttons & WPAD_BUTTON_B) buttons |= PAD_BUTTON_B;
|
||||
if(wbuttons & WPAD_BUTTON_1) buttons |= PAD_BUTTON_X;
|
||||
if(wbuttons & WPAD_BUTTON_2) buttons |= PAD_BUTTON_Y;
|
||||
if(wbuttons & WPAD_BUTTON_HOME) buttons |= PAD_BUTTON_START;
|
||||
if(wbuttons & WPAD_BUTTON_DOWN) buttons |= PAD_BUTTON_DOWN;
|
||||
if(wbuttons & WPAD_BUTTON_UP) buttons |= PAD_BUTTON_UP;
|
||||
if(wbuttons & WPAD_BUTTON_LEFT) buttons |= PAD_BUTTON_LEFT;
|
||||
if(wbuttons & WPAD_BUTTON_RIGHT) buttons |= PAD_BUTTON_RIGHT;
|
||||
|
||||
#endif
|
||||
return buttons;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gccore.h>
|
||||
#include <ogc/pad.h>
|
||||
#if defined(HW_RVL)
|
||||
#include <wiiuse/wpad.h>
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void Ctrl_Init();
|
||||
void Ctrl_ScanPads();
|
||||
u32 Ctrl_ButtonsDown(int pad);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue