Some bugfixes for keyboard and some updates from libwiigui repo.

This commit is contained in:
retro100 2021-04-19 18:12:43 +02:00
parent 6d43b892ec
commit 4fc9d4baec
5 changed files with 241 additions and 77 deletions

View File

@ -54,8 +54,22 @@ extern FreeTypeGX *fontSystem[];
#define SCROLL_DELAY_INITIAL 200000
#define SCROLL_DELAY_LOOP 30000
#define SCROLL_DELAY_DECREASE 300
#define FILE_PAGESIZE 8
#define PAGESIZE 8
#define MAX_OPTIONS 150
#define MAX_KEYBOARD_DISPLAY 32
// define this marco to enable/add ESC, ENTER, F1, F2, etc. buttons
#define EXTENDED_KEYBOARD
#ifdef EXTENDED_KEYBOARD
#define KB_ROWS 5
#define KB_COLUMNS 12
#else
#define KB_ROWS 4
#define KB_COLUMNS 11
#endif
typedef void (*UpdateCallback)(void * e);
enum
@ -233,7 +247,7 @@ class GuiElement
//!Constructor
GuiElement();
//!Destructor
~GuiElement();
virtual ~GuiElement();
//!Set the element's parent
//!\param e Pointer to parent element
void SetParent(GuiElement * e);
@ -460,7 +474,7 @@ class GuiWindow : public GuiElement
//!\param h Height of window
GuiWindow(int w, int h);
//!Destructor
~GuiWindow();
virtual ~GuiWindow();
//!Appends a GuiElement to the GuiWindow
//!\param e The GuiElement to append. If it is already in the GuiWindow, it is removed first
void Append(GuiElement* e);
@ -816,7 +830,7 @@ class GuiButton : public GuiElement
};
typedef struct _keytype {
unsigned char ch, chShift;
char ch, chShift;
} Key;
//!On-screen keyboard
@ -833,6 +847,7 @@ class GuiKeyboard : public GuiWindow
int caps;
GuiText * kbText;
GuiImage * keyTextboxImg;
#ifdef EXTENDED_KEYBOARD
GuiText * keyEscText;
GuiImage * keyEscImg;
GuiImage * keyEscOverImg;
@ -841,6 +856,7 @@ class GuiKeyboard : public GuiWindow
GuiImage * keyEnterImg;
GuiImage * keyEnterOverImg;
GuiButton * keyEnter;
#endif
GuiText * keyCapsText;
GuiImage * keyCapsImg;
GuiImage * keyCapsOverImg;
@ -856,10 +872,10 @@ class GuiKeyboard : public GuiWindow
GuiImage * keySpaceImg;
GuiImage * keySpaceOverImg;
GuiButton * keySpace;
GuiButton * keyBtn[5][12];
GuiImage * keyImg[5][12];
GuiImage * keyImgOver[5][12];
GuiText * keyTxt[5][12];
GuiButton * keyBtn[KB_ROWS][KB_COLUMNS];
GuiImage * keyImg[KB_ROWS][KB_COLUMNS];
GuiImage * keyImgOver[KB_ROWS][KB_COLUMNS];
GuiText * keyTxt[KB_ROWS][KB_COLUMNS];
GuiImageData * keyTextbox;
GuiImageData * key;
GuiImageData * keyOver;
@ -870,8 +886,9 @@ class GuiKeyboard : public GuiWindow
GuiSound * keySoundOver;
GuiSound * keySoundClick;
GuiTrigger * trigA;
GuiTrigger * trigB;
Key keys[5][12]; // two chars = less space than one pointer
GuiTrigger * trig2;
Key keys[KB_ROWS][KB_COLUMNS]; // two chars = less space than one pointer
};
#endif

View File

@ -9,20 +9,23 @@
***************************************************************************/
#include "gui.h"
#ifdef EXTENDED_KEYBOARD
#include <string>
#endif
using namespace std;
#define KB_FONTSIZE 22
static char tmptxt[MAX_KEYBOARD_DISPLAY];
static void str_replace(string &str, char *search, const char *replace)
#ifdef EXTENDED_KEYBOARD
static void str_replace(std::string &str, const char *search, const char *replace)
{
int searchLen = strlen(search);
int replaceLen = strlen(replace);
string::size_type pos=0;
std::string::size_type pos=0;
while ((pos=str.find(search, pos)) != string::npos)
while ((pos=str.find(search, pos)) != std::string::npos)
{
str.erase(pos, searchLen);
str.insert(pos, replace);
@ -30,12 +33,12 @@ static void str_replace(string &str, char *search, const char *replace)
}
}
static char * GetDisplayText(char * t, int max)
static const char * GetDisplayText(const char * t)
{
if(!t || t[0] == 0)
return t;
string tempStr(t);
std::string tempStr(t);
char txt[2] = { 0, 0 };
txt[0] = 13; str_replace(tempStr, txt, "<ENTER>");
txt[0] = 27; str_replace(tempStr, txt, "<ESC>");
@ -58,25 +61,44 @@ static char * GetDisplayText(char * t, int max)
return &tmptxt[0];
}
#else
static const char * GetDisplayText(const char * t)
{
if(!t)
return NULL;
snprintf(tmptxt, MAX_KEYBOARD_DISPLAY, "%s", t);
return &tmptxt[0];
}
#endif
/**
* Constructor for the GuiKeyboard class.
*/
GuiKeyboard::GuiKeyboard(char * t, u32 max)
{
#ifdef EXTENDED_KEYBOARD
width = 610;
height = 440;
#else
width = 540;
height = 400;
#endif
shift = 0;
caps = 0;
selectable = true;
focus = 0; // allow focus
alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE;
strncpy(kbtextstr, t, max);
kbtextstr[max] = 0;
snprintf(kbtextstr, 255, "%s", t);
kbtextmaxlen = max;
Key thekeys[5][12] = {
#ifdef EXTENDED_KEYBOARD
Key thekeys[KB_ROWS][KB_COLUMNS] = {
{
{14,0}, // F1
{15,0}, // F2
@ -89,7 +111,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
{22,0}, // F9
{23,0}, // F10
{24,0}, // F11
{25,0}, // F12
{25,0} // F12
},
{
{'`','~'},
@ -149,17 +171,79 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
{'\0','\0'}
}
};
#else
Key thekeys[KB_ROWS][KB_COLUMNS] = {
{
{'1','!'},
{'2','@'},
{'3','#'},
{'4','$'},
{'5','%'},
{'6','^'},
{'7','&'},
{'8','*'},
{'9','('},
{'0',')'},
{'\0','\0'}
},
{
{'q','Q'},
{'w','W'},
{'e','E'},
{'r','R'},
{'t','T'},
{'y','Y'},
{'u','U'},
{'i','I'},
{'o','O'},
{'p','P'},
{'-','_'}
},
{
{'a','A'},
{'s','S'},
{'d','D'},
{'f','F'},
{'g','G'},
{'h','H'},
{'j','J'},
{'k','K'},
{'l','L'},
{';',':'},
{'\'','"'}
},
{
{'z','Z'},
{'x','X'},
{'c','C'},
{'v','V'},
{'b','B'},
{'n','N'},
{'m','M'},
{',','<'},
{'.','>'},
{'/','?'},
{'\0','\0'}
}
};
#endif
memcpy(keys, thekeys, sizeof(thekeys));
#ifdef EXTENDED_KEYBOARD
int yoff_1 = 20;
#else
int yoff_1 = 0;
#endif
keyTextbox = new GuiImageData(keyboard_textbox_png);
keyTextboxImg = new GuiImage(keyTextbox);
keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keyTextboxImg->SetPosition(0, 20);
keyTextboxImg->SetPosition(0, yoff_1);
this->Append(keyTextboxImg);
kbText = new GuiText(GetDisplayText(kbtextstr, max), 22, (GXColor){0, 0, 0, 0xff});
kbText = new GuiText(GetDisplayText(kbtextstr), KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
kbText->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText->SetPosition(0, 33);
kbText->SetPosition(0, yoff_1 + 13);
this->Append(kbText);
key = new GuiImageData(keyboard_key_png);
@ -171,16 +255,18 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger;
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
trig2 = new GuiTrigger;
trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0);
int yoff = 80;
#ifdef EXTENDED_KEYBOARD
keyEscImg = new GuiImage(keyMedium);
keyEscOverImg = new GuiImage(keyMediumOver);
keyEscText = new GuiText("Esc", 22, (GXColor){0, 0, 0, 0xff});
keyEscText = new GuiText("Esc", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
keyEsc = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyEsc->SetImage(keyEscImg);
keyEsc->SetImageOver(keyEscOverImg);
@ -188,13 +274,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyEsc->SetSoundOver(keySoundOver);
keyEsc->SetSoundClick(keySoundClick);
keyEsc->SetTrigger(trigA);
keyEsc->SetTrigger(trig2);
keyEsc->SetPosition(0, yoff);
keyEsc->SetEffectGrow();
this->Append(keyEsc);
keyEnterImg = new GuiImage(keyMedium);
keyEnterOverImg = new GuiImage(keyMediumOver);
keyEnterText = new GuiText("Enter", 22, (GXColor){0, 0, 0, 0xff});
keyEnterText = new GuiText("Enter", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
keyEnter = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyEnter->SetImage(keyEnterImg);
keyEnter->SetImageOver(keyEnterOverImg);
@ -202,13 +289,15 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyEnter->SetSoundOver(keySoundOver);
keyEnter->SetSoundClick(keySoundClick);
keyEnter->SetTrigger(trigA);
keyEnter->SetTrigger(trig2);
keyEnter->SetPosition(12*42+18, 4*42+yoff);
keyEnter->SetEffectGrow();
this->Append(keyEnter);
#endif
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver);
keyBackText = new GuiText("Back", 22, (GXColor){0, 0, 0, 0xff});
keyBackText = new GuiText("Back", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
keyBack = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyBack->SetImage(keyBackImg);
keyBack->SetImageOver(keyBackOverImg);
@ -216,14 +305,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyBack->SetSoundOver(keySoundOver);
keyBack->SetSoundClick(keySoundClick);
keyBack->SetTrigger(trigA);
keyBack->SetTrigger(trigB);
keyBack->SetPosition(11*42+40, 1*42+yoff);
keyBack->SetTrigger(trig2);
keyBack->SetPosition((KB_COLUMNS-1)*42+40, (KB_ROWS-4)*42+yoff);
keyBack->SetEffectGrow();
this->Append(keyBack);
keyCapsImg = new GuiImage(keyMedium);
keyCapsOverImg = new GuiImage(keyMediumOver);
keyCapsText = new GuiText("Caps", 22, (GXColor){0, 0, 0, 0xff});
keyCapsText = new GuiText("Caps", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
keyCaps = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyCaps->SetImage(keyCapsImg);
keyCaps->SetImageOver(keyCapsOverImg);
@ -231,13 +320,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyCaps->SetSoundOver(keySoundOver);
keyCaps->SetSoundClick(keySoundClick);
keyCaps->SetTrigger(trigA);
keyCaps->SetPosition(0, 3*42+yoff);
keyCaps->SetTrigger(trig2);
keyCaps->SetPosition(0, (KB_ROWS-2)*42+yoff);
keyCaps->SetEffectGrow();
this->Append(keyCaps);
keyShiftImg = new GuiImage(keyMedium);
keyShiftOverImg = new GuiImage(keyMediumOver);
keyShiftText = new GuiText("Shift", 22, (GXColor){0, 0, 0, 0xff});
keyShiftText = new GuiText("Shift", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
keyShift = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyShift->SetImage(keyShiftImg);
keyShift->SetImageOver(keyShiftOverImg);
@ -245,7 +335,8 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyShift->SetSoundOver(keySoundOver);
keyShift->SetSoundClick(keySoundClick);
keyShift->SetTrigger(trigA);
keyShift->SetPosition(21, 4*42+yoff);
keyShift->SetTrigger(trig2);
keyShift->SetPosition(21, (KB_ROWS-1)*42+yoff);
keyShift->SetEffectGrow();
this->Append(keyShift);
@ -257,41 +348,46 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keySpace->SetSoundOver(keySoundOver);
keySpace->SetSoundClick(keySoundClick);
keySpace->SetTrigger(trigA);
keySpace->SetPosition(0, 5*42+yoff);
keySpace->SetTrigger(trig2);
keySpace->SetPosition(0, KB_ROWS*42+yoff);
keySpace->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keySpace->SetEffectGrow();
this->Append(keySpace);
char txt[2] = { 0, 0 };
for(int i=0; i<5; i++)
for(int i=0; i<KB_ROWS; i++)
{
for(int j=0; j<12; j++)
for(int j=0; j<KB_COLUMNS; j++)
{
if(keys[i][j].ch != '\0')
{
txt[0] = keys[i][j].ch;
keyImg[i][j] = new GuiImage(key);
keyImgOver[i][j] = new GuiImage(keyOver);
#ifdef EXTENDED_KEYBOARD
switch(keys[i][j].ch)
{
case 14: keyTxt[i][j] = new GuiText("F1", 22, (GXColor){0, 0, 0, 0xff}); break;
case 15: keyTxt[i][j] = new GuiText("F2", 22, (GXColor){0, 0, 0, 0xff}); break;
case 16: keyTxt[i][j] = new GuiText("F3", 22, (GXColor){0, 0, 0, 0xff}); break;
case 17: keyTxt[i][j] = new GuiText("F4", 22, (GXColor){0, 0, 0, 0xff}); break;
case 18: keyTxt[i][j] = new GuiText("F5", 22, (GXColor){0, 0, 0, 0xff}); break;
case 19: keyTxt[i][j] = new GuiText("F6", 22, (GXColor){0, 0, 0, 0xff}); break;
case 20: keyTxt[i][j] = new GuiText("F7", 22, (GXColor){0, 0, 0, 0xff}); break;
case 21: keyTxt[i][j] = new GuiText("F8", 22, (GXColor){0, 0, 0, 0xff}); break;
case 22: keyTxt[i][j] = new GuiText("F9", 22, (GXColor){0, 0, 0, 0xff}); break;
case 23: keyTxt[i][j] = new GuiText("F10", 22, (GXColor){0, 0, 0, 0xff}); break;
case 24: keyTxt[i][j] = new GuiText("F11", 22, (GXColor){0, 0, 0, 0xff}); break;
case 25: keyTxt[i][j] = new GuiText("F12", 22, (GXColor){0, 0, 0, 0xff}); break;
case 14: keyTxt[i][j] = new GuiText("F1", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 15: keyTxt[i][j] = new GuiText("F2", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 16: keyTxt[i][j] = new GuiText("F3", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 17: keyTxt[i][j] = new GuiText("F4", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 18: keyTxt[i][j] = new GuiText("F5", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 19: keyTxt[i][j] = new GuiText("F6", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 20: keyTxt[i][j] = new GuiText("F7", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 21: keyTxt[i][j] = new GuiText("F8", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 22: keyTxt[i][j] = new GuiText("F9", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 23: keyTxt[i][j] = new GuiText("F10", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 24: keyTxt[i][j] = new GuiText("F11", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
case 25: keyTxt[i][j] = new GuiText("F12", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
default:
keyTxt[i][j] = new GuiText(txt, 22, (GXColor){0, 0, 0, 0xff});
keyTxt[i][j] = new GuiText(txt, KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
break;
}
#else
keyTxt[i][j] = new GuiText(txt, KB_FONTSIZE, (GXColor){0, 0, 0, 0xff});
#endif
keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
keyTxt[i][j]->SetPosition(0, -10);
keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
@ -300,8 +396,10 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyBtn[i][j]->SetSoundOver(keySoundOver);
keyBtn[i][j]->SetSoundClick(keySoundClick);
keyBtn[i][j]->SetTrigger(trigA);
keyBtn[i][j]->SetTrigger(trig2);
keyBtn[i][j]->SetLabel(keyTxt[i][j]);
#ifdef EXTENDED_KEYBOARD
int stagger;
switch(i)
{
@ -311,6 +409,9 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
}
keyBtn[i][j]->SetPosition(j*42+stagger+40, i*42+yoff);
#else
keyBtn[i][j]->SetPosition(j*42+21*i+40, i*42+yoff);
#endif
keyBtn[i][j]->SetEffectGrow();
this->Append(keyBtn[i][j]);
}
@ -326,6 +427,7 @@ GuiKeyboard::~GuiKeyboard()
delete kbText;
delete keyTextbox;
delete keyTextboxImg;
#ifdef EXTENDED_KEYBOARD
delete keyEscText;
delete keyEscImg;
delete keyEscOverImg;
@ -334,6 +436,7 @@ GuiKeyboard::~GuiKeyboard()
delete keyEnterImg;
delete keyEnterOverImg;
delete keyEnter;
#endif
delete keyCapsText;
delete keyCapsImg;
delete keyCapsOverImg;
@ -358,10 +461,11 @@ GuiKeyboard::~GuiKeyboard()
delete keySoundOver;
delete keySoundClick;
delete trigA;
delete trig2;
for(int i=0; i<5; i++)
for(int i=0; i<KB_ROWS; i++)
{
for(int j=0; j<12; j++)
for(int j=0; j<KB_COLUMNS; j++)
{
if(keys[i][j].ch != '\0')
{
@ -387,39 +491,50 @@ void GuiKeyboard::Update(GuiTrigger * t)
bool update = false;
#ifdef EXTENDED_KEYBOARD
if(keyEsc->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) < kbtextmaxlen)
size_t len = strlen(kbtextstr);
if(len < kbtextmaxlen-1)
{
kbtextstr[strlen(kbtextstr)] = 27; // Esc key code
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen));
kbtextstr[len] = 27; // Esc key code
kbtextstr[len+1] = '\0';
kbText->SetText(GetDisplayText(kbtextstr));
}
keyEsc->SetState(STATE_SELECTED, t->chan);
}
else if(keyEnter->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) < kbtextmaxlen)
size_t len = strlen(kbtextstr);
if(len < kbtextmaxlen-1)
{
kbtextstr[strlen(kbtextstr)] = 13; // Enter key code
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen));
kbtextstr[len] = 13; // Enter key code
kbtextstr[len+1] = '\0';
kbText->SetText(GetDisplayText(kbtextstr));
}
keyEnter->SetState(STATE_SELECTED, t->chan);
}
else if(keySpace->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) < kbtextmaxlen)
#else
if(keySpace->GetState() == STATE_CLICKED)
#endif
{ // body for if from macro!
size_t len = strlen(kbtextstr);
if(len < kbtextmaxlen-1)
{
kbtextstr[strlen(kbtextstr)] = ' ';
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen));
kbtextstr[len] = ' ';
kbtextstr[len+1] = '\0';
kbText->SetText(kbtextstr);
}
keySpace->SetState(STATE_SELECTED, t->chan);
}
else if(keyBack->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) > 0)
size_t len = strlen(kbtextstr);
if(len > 0)
{
kbtextstr[strlen(kbtextstr)-1] = 0;
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen));
kbtextstr[len-1] = '\0';
kbText->SetText(GetDisplayText(kbtextstr));
}
keyBack->SetState(STATE_SELECTED, t->chan);
}
@ -440,13 +555,17 @@ void GuiKeyboard::Update(GuiTrigger * t)
startloop:
for(int i=0; i<5; i++)
for(int i=0; i<KB_ROWS; i++)
{
for(int j=0; j<12; j++)
for(int j=0; j<KB_COLUMNS; j++)
{
if(keys[i][j].ch != '\0')
{
if(update && keys[i][j].ch > 31)
#ifdef EXTENDED_KEYBOARD
if(update && keys[i][j].ch >= 32)
#else
if(update)
#endif
{
if(shift || caps)
txt[0] = keys[i][j].chShift;
@ -458,18 +577,21 @@ void GuiKeyboard::Update(GuiTrigger * t)
if(keyBtn[i][j]->GetState() == STATE_CLICKED)
{
if(strlen(kbtextstr) < kbtextmaxlen)
size_t len = strlen(kbtextstr);
if(len < kbtextmaxlen-1)
{
if(shift || caps)
{
kbtextstr[strlen(kbtextstr)] = keys[i][j].chShift;
kbtextstr[len] = keys[i][j].chShift;
}
else
{
kbtextstr[strlen(kbtextstr)] = keys[i][j].ch;
kbtextstr[len] = keys[i][j].ch;
}
kbtextstr[len+1] = '\0';
}
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen));
kbText->SetText(GetDisplayText(kbtextstr));
keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);
if(shift)

View File

@ -28,12 +28,15 @@ GuiSound::GuiSound(const u8 * s, s32 l, int t)
*/
GuiSound::~GuiSound()
{
#ifndef NO_SOUND
if(type == SOUND_OGG)
StopOgg();
#endif
}
void GuiSound::Play()
{
#ifndef NO_SOUND
int vol;
switch(type)
@ -55,10 +58,12 @@ void GuiSound::Play()
SetVolumeOgg(255*(volume/100.0));
break;
}
#endif
}
void GuiSound::Stop()
{
#ifndef NO_SOUND
if(voice < 0)
return;
@ -72,10 +77,12 @@ void GuiSound::Stop()
StopOgg();
break;
}
#endif
}
void GuiSound::Pause()
{
#ifndef NO_SOUND
if(voice < 0)
return;
@ -89,10 +96,12 @@ void GuiSound::Pause()
PauseOgg(1);
break;
}
#endif
}
void GuiSound::Resume()
{
#ifndef NO_SOUND
if(voice < 0)
return;
@ -106,6 +115,7 @@ void GuiSound::Resume()
PauseOgg(0);
break;
}
#endif
}
bool GuiSound::IsPlaying()
@ -118,6 +128,7 @@ bool GuiSound::IsPlaying()
void GuiSound::SetVolume(int vol)
{
#ifndef NO_SOUND
volume = vol;
if(voice < 0)
@ -135,6 +146,7 @@ void GuiSound::SetVolume(int vol)
SetVolumeOgg(255*(volume/100.0));
break;
}
#endif
}
void GuiSound::SetLoop(bool l)

View File

@ -9,6 +9,7 @@
***************************************************************************/
#include "gui.h"
//#include "../gettext.h"
static GXColor presetColor = (GXColor){255, 255, 255, 255};
static int currentSize = 0;
@ -21,6 +22,12 @@ static u16 presetStyle = 0;
#define TEXT_SCROLL_DELAY 8
#define TEXT_SCROLL_INITIAL_DELAY 6
static const char *gettext(const char *msg)
{
return msg;
}
/**
* Constructor for the GuiText class.
*/
@ -46,7 +53,7 @@ GuiText::GuiText(const char * t, int s, GXColor c)
if(t)
{
origText = strdup(t);
text = charToWideChar(t);
text = charToWideChar(gettext(t));
}
for(int i=0; i < 20; i++)
@ -78,7 +85,7 @@ GuiText::GuiText(const char * t)
if(t)
{
origText = strdup(t);
text = charToWideChar(t);
text = charToWideChar(gettext(t));
}
for(int i=0; i < 20; i++)
@ -126,7 +133,7 @@ void GuiText::SetText(const char * t)
if(t)
{
origText = strdup(t);
text = charToWideChar(t);
text = charToWideChar(gettext(t));
}
}
@ -300,7 +307,7 @@ void GuiText::ResetText()
if(text)
delete[] text;
text = charToWideChar(origText);
text = charToWideChar(gettext(origText));
for(int i=0; i < textDynNum; i++)
{

View File

@ -93,6 +93,8 @@ void GuiTrigger::SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns)
s8 GuiTrigger::WPAD_Stick(u8 stick, int axis)
{
#ifdef HW_RVL
float mag = 0.0;
float ang = 0.0;
@ -135,6 +137,10 @@ s8 GuiTrigger::WPAD_Stick(u8 stick, int axis)
val = mag * cos((PI * ang)/180.0f);
return (s8)(val * 128.0f);
#else
return 0;
#endif
}
s8 GuiTrigger::WPAD_StickX(u8 stick)