1 /* Library header file */
2 #ifndef HBM_BASE_H_
3 #define HBM_BASE_H_
4 
5 #ifdef __cplusplus
6 extern "C"
7 {
8 #endif /*__cplusplus */
9 
10 #ifndef HBM_SND_THREAD_STACK_SIZE
11 #define HBM_SND_THREAD_STACK_SIZE           1024*16
12 #endif
13 #define HBM_MEM_SIZE (1024 * 512)
14 #define HBM_SND_GROUP_HOMEBUTTON 0
15 
16 //#define USE_FOR_MANUAL
17 
18 typedef enum
19 {
20     HBM_SELECT_NULL = -1,
21     HBM_SELECT_HOMEBTN = 0,
22     HBM_SELECT_BTN1,
23     HBM_SELECT_BTN2,
24     HBM_SELECT_BTN3,
25     HBM_SELECT_BTN4,
26     HBM_SELECT_MAX
27 }HBMSelectBtnNum;
28 
29 enum
30 {
31     HBMSE_HOME_BUTTON = 0,
32     HBMSE_RETURN_APP,
33     HBMSE_GOTO_MENU,
34     HBMSE_RESET_APP,
35     HBMSE_FOCUS,
36     HBMSE_SELECT,
37     HBMSE_CANCEL,
38     HBMSE_OPEN_CONTROLLER,
39     HBMSE_CLOSE_CONTROLLER,
40     HBMSE_VOLUME_PLUS,
41     HBMSE_VOLUME_MINUS,//10
42     HBMSE_VOLUME_PLUS_LIMIT,
43     HBMSE_VOLUME_MINUS_LIMIT,
44     HBMSE_NOTHING_DONE,
45     HBMSE_VIBE_ON,
46     HBMSE_VIBE_OFF,
47     HBMSE_START_CONNECT_WINDOW,
48     HBMSE_CONNECTED,
49     HBMSE_CONNECTED2,
50     HBMSE_CONNECTED3,//20
51     HBMSE_CONNECTED4,
52     HBMSE_END_CONNECT_WINDOW
53 #ifdef USE_FOR_MANUAL
54    ,
55     HBMSE_MANUAL_OPEN,  // for manual
56     HBMSE_MANUAL_FOCUS,
57     HBMSE_MANUAL_SELECT,
58     HBMSE_MANUAL_SCROLL,
59     HBMSE_MANUAL_CANCEL,
60     HBMSE_MANUAL_RETURN
61 #endif
62 };
63 
64 // Value of the evt argument of HBMSoundCallback
65 enum
66 {
67     HBMSEV_BEFORE_INIT_SOUND,   /* Enter menu and just before initializing sound */
68     HBMSEV_INIT_SOUND,          /* Enter menu and just before playing sound effect */
69     HBMSEV_BEGIN_EXIT_ANIM,     /* Start animation when exiting from menu */
70     HBMSEV_BEGIN_BLACKOUT,      /* Start menu blackout */
71     HBMSEV_END_MENU,            /* Menu close */
72     HBMSEV_PLAY_SOUND           /* Play sound effect */
73 #ifdef USE_FOR_MANUAL
74     ,HBMSEV_BEGIN_BLACKOUT_TO_MANUAL    /* Start menu blackout (when at manual) */
75 #endif
76 };
77 
78 // Return value of HBMSoundCallback
79 enum
80 {
81     HBMSEV_RET_NONE = 0,        /* No sound is played back from the application either outside of HBMSEV_PLAY_SOUND or during HBMSEV_PLAY_SOUND. */
82     HBMSEV_RET_PLAY_SOUND       /* Sound was played back from the application during HBMSEV_PLAY_SOUND. */
83 };
84 
85 // messageFlag flag
86 enum
87 {
88     HBMMSG_NOSAVE_DEFAULT   = 0,
89     HBMMSG_NOSAVE_WIIMENU   = 1,
90     HBMMSG_NOSAVE_RESET = 2,
91     HBMMSG_NOSAVE_ALL = -1
92 };
93 
94 /* Wii Controller information */
95 typedef struct
96 {
97     KPADStatus* kpad;
98     Vec2        pos;
99     u32         use_devtype;
100 }HBMKPadData;
101 
102 /* Controller data structure passed to Home Button object */
103 typedef struct
104 {
105     HBMKPadData wiiCon[WPAD_MAX_CONTROLLERS];
106 }HBMControllerData;
107 
108 /* Sound callback function type declaration */
109 typedef int (*HBMSoundCallback)(int evt, int num);
110 
111 typedef struct
112 {
113     void* layoutBuf;
114     void* spkSeBuf;
115     void* msgBuf;
116     void* configBuf;
117     void* mem;
118     HBMSoundCallback sound_callback;
119     int   backFlag;
120     int   region;
121     int   cursor;
122     int   messageFlag;
123     u32   configBufSize;
124     u32   memSize;
125     f32   frameDelta;
126     Vec2  adjust;
127     MEMAllocator*   pAllocator;
128 }HBMDataInfo;
129 
130 void             HBMCreate( const HBMDataInfo* pHBInfo );
131 void             HBMDelete();
132 void             HBMInit( void );
133 HBMSelectBtnNum  HBMCalc( const HBMControllerData* pController );
134 void             HBMDraw( void );
135 HBMSelectBtnNum  HBMGetSelectBtnNum( void );
136 void             HBMSetAdjustFlag( int flag );
137 void             HBMStartBlackOut( void );
138 int              HBMIsReassignedControllers( void );
139 
140 void             HBMSetBlackOutColor( u8 red, u8 green, u8 blue );
141 GXColor          HBMGetBlackOutColor( void );
142 void             HBMSetVIBlack ( int flag );
143 
144 #define HBM_WORK_SIZE_SOUND		0x14700
145 #define HBM_MEM_SIZE_SOUND     (HBM_WORK_SIZE_SOUND + HBM_SND_THREAD_STACK_SIZE)
146 
147 /* Compatibility */
148 #define HBM_MEM_SIZE_DVD       HBM_MEM_SIZE_SOUND
149 #define HBM_MEM_SIZE_MEMORY    HBM_MEM_SIZE_SOUND
150 #define HBM_MEM_SIZE_NAND      HBM_MEM_SIZE_SOUND
151 #define HBM_MEM2_SIZE_DVD      HBM_MEM_SIZE_DVD
152 #define HBM_MEM2_SIZE_MEMORY   HBM_MEM_SIZE_MEMORY
153 #define HBM_MEM2_SIZE_NAND     HBM_MEM_SIZE_NAND
154 
155 void             HBMCreateSound( const void* soundData, void* memBuf, u32 memSize );
156 void             HBMDeleteSound();
157 
158 void             HBMUpdateSound();      /* Call every frame */
159 
160 #ifdef USE_FOR_MANUAL
161 void            HBMPlayManualSound( int id );
162 void            HBMUpdateManualSound( void );
163 void            HBMFadeoutManualSound( f32 gain );
164 void            HBMResetManualSound( void );
165 #endif
166 
167 #ifdef __cplusplus
168 }
169 #endif /*__cplusplus */
170 
171 #endif /* HBM_BASE_H */
172