Update to current devkitPro/libogc version. Some bugfixes for keyboard and some updates from libwiigui repo.

This commit is contained in:
retro100 2021-04-20 21:34:01 +02:00
parent 02a83be576
commit 0ff5205acb
11 changed files with 304 additions and 190 deletions

View File

@ -37,7 +37,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
# any extra libraries we wish to link with # any extra libraries we wish to link with
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBS := -lSDL -lfat -lwiiuse -lbte -lasnd -logc -lwiikeyboard \ LIBS := -lSDL -lfat -lwiiuse -lbte -lasnd -logc -lwiikeyboard \
-lpng -lvorbisidec -lfreetype -lz -lpng -lvorbisidec -logg -lfreetype -lbz2 -lz
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing
@ -66,10 +66,9 @@ CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf))) BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf) \
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) $(wildcard $(dir)/*.lang) $(wildcard $(dir)/*.png) \
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg))) $(wildcard $(dir)/*.ogg) $(wildcard $(dir)/*.pcm)))
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm)))
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C # use CXX for linking C++ projects, CC for standard C
@ -80,10 +79,11 @@ else
export LD := $(CXX) export LD := $(CXX)
endif endif
export OFILES := $(addsuffix .o,$(BINFILES)) \ export OFILES_BIN := $(addsuffix .o,$(BINFILES))
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
$(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.o) \ export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
$(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o)
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# build a list of include paths # build a list of include paths
@ -91,7 +91,7 @@ export OFILES := $(addsuffix .o,$(BINFILES)) \
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \ -I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC) -I$(LIBOGC_INC)/SDL -I$(PORTLIBS)/include/freetype2 -I$(LIBOGC_INC) -I$(PORTLIBS_PATH)/wii/include/SDL -I$(PORTLIBS_PATH)/ppc/include/freetype2
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# build a list of library paths # build a list of library paths
@ -131,22 +131,27 @@ DEPENDS := $(OFILES:.o=.d)
$(OUTPUT).dol: $(OUTPUT).elf $(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES) $(OUTPUT).elf: $(OFILES)
$(OFILES_SOURCES): $(HFILES)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# This rule links in binary data with .ttf, .png, and .mp3 extensions # This rule links in binary data with .ttf, .png, and .mp3 extensions
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
%.ttf.o : %.ttf %.ttf.o %_ttf.h : %.ttf
@echo $(notdir $<) @echo $(notdir $<)
$(bin2o) $(bin2o)
%.png.o : %.png %.lang.o %_lang.h : %.lang
@echo $(notdir $<) @echo $(notdir $<)
$(bin2o) $(bin2o)
%.ogg.o : %.ogg %.png.o %_png.h : %.png
@echo $(notdir $<) @echo $(notdir $<)
$(bin2o) $(bin2o)
%.pcm.o : %.pcm %.ogg.o %_ogg.h : %.ogg
@echo $(notdir $<)
$(bin2o)
%.pcm.o %_pcm.h : %.pcm
@echo $(notdir $<) @echo $(notdir $<)
$(bin2o) $(bin2o)

View File

@ -1486,6 +1486,12 @@ void GFX_Events() {
// check for home button // check for home button
u32 btns; u32 btns;
u16 btns_gc; u16 btns_gc;
// Very important to update/scan the current pad/button states.
// Otherwise on newer libogc versions the button states are not updated.
WPAD_ScanPads();
PAD_ScanPads();
for(int i=0; i<4; i++) for(int i=0; i<4; i++)
{ {
btns = WPAD_ButtonsHeld(i); btns = WPAD_ButtonsHeld(i);

View File

@ -11,102 +11,39 @@
#ifndef _FILELIST_H_ #ifndef _FILELIST_H_
#define _FILELIST_H_ #define _FILELIST_H_
#include <gccore.h> //#include <gccore.h>
extern const u8 font_ttf[]; #include "battery_bar_png.h"
extern const u32 font_ttf_size; #include "battery_png.h"
#include "battery_red_png.h"
extern const u8 enter_ogg[]; #include "bg_bottom_png.h"
extern const u32 enter_ogg_size; #include "bg_top_png.h"
#include "button_click_pcm.h"
extern const u8 exit_ogg[]; #include "button_large_over_png.h"
extern const u32 exit_ogg_size; #include "button_large_png.h"
#include "button_over_pcm.h"
extern const u8 button_over_pcm[]; #include "button_over_png.h"
extern const u32 button_over_pcm_size; #include "button_png.h"
#include "button_small_over_png.h"
extern const u8 button_click_pcm[]; #include "button_small_png.h"
extern const u32 button_click_pcm_size; #include "credits_box_png.h"
#include "enter_ogg.h"
extern const u8 logo_png[]; #include "exit_ogg.h"
extern const u32 logo_png_size; #include "font_ttf.h"
#include "keyboard_key_over_png.h"
extern const u8 logo_over_png[]; #include "keyboard_key_png.h"
extern const u32 logo_over_png_size; #include "keyboard_largekey_over_png.h"
#include "keyboard_largekey_png.h"
extern const u8 bg_top_png[]; #include "keyboard_mediumkey_over_png.h"
extern const u32 bg_top_png_size; #include "keyboard_mediumkey_png.h"
#include "keyboard_textbox_png.h"
extern const u8 bg_bottom_png[]; #include "logo_over_png.h"
extern const u32 bg_bottom_png_size; #include "logo_png.h"
#include "player1_point_png.h"
extern const u8 button_png[]; #include "player2_point_png.h"
extern const u32 button_png_size; #include "player3_point_png.h"
#include "player4_point_png.h"
extern const u8 button_over_png[]; #include "tv_over_png.h"
extern const u32 button_over_png_size; #include "tv_png.h"
extern const u8 button_small_png[];
extern const u32 button_small_png_size;
extern const u8 button_small_over_png[];
extern const u32 button_small_over_png_size;
extern const u8 button_large_png[];
extern const u32 button_large_png_size;
extern const u8 button_large_over_png[];
extern const u32 button_large_over_png_size;
extern const u8 battery_png[];
extern const u32 battery_png_size;
extern const u8 battery_red_png[];
extern const u32 battery_red_png_size;
extern const u8 battery_bar_png[];
extern const u32 battery_bar_png_size;
extern const u8 credits_box_png[];
extern const u32 credits_box_png_size;
extern const u8 keyboard_textbox_png[];
extern const u32 keyboard_textbox_png_size;
extern const u8 keyboard_key_png[];
extern const u32 keyboard_key_png_size;
extern const u8 keyboard_key_over_png[];
extern const u32 keyboard_key_over_png_size;
extern const u8 keyboard_mediumkey_png[];
extern const u32 keyboard_mediumkey_png_size;
extern const u8 keyboard_mediumkey_over_png[];
extern const u32 keyboard_mediumkey_over_png_size;
extern const u8 keyboard_largekey_png[];
extern const u32 keyboard_largekey_png_size;
extern const u8 keyboard_largekey_over_png[];
extern const u32 keyboard_largekey_over_png_size;
extern const u8 player1_point_png[];
extern const u32 player1_point_png_size;
extern const u8 player2_point_png[];
extern const u32 player2_point_png_size;
extern const u8 player3_point_png[];
extern const u32 player3_point_png_size;
extern const u8 player4_point_png[];
extern const u32 player4_point_png_size;
extern const u8 tv_png[];
extern const u32 tv_png_size;
extern const u8 tv_over_png[];
extern const u32 tv_over_png_size;
#endif #endif

View File

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

View File

@ -9,20 +9,23 @@
***************************************************************************/ ***************************************************************************/
#include "gui.h" #include "gui.h"
#ifdef EXTENDED_KEYBOARD
#include <string> #include <string>
#endif
using namespace std; #define KB_FONTSIZE 22
static char tmptxt[MAX_KEYBOARD_DISPLAY]; 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 searchLen = strlen(search);
int replaceLen = strlen(replace); 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.erase(pos, searchLen);
str.insert(pos, replace); 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) if(!t || t[0] == 0)
return t; return t;
string tempStr(t); std::string tempStr(t);
char txt[2] = { 0, 0 }; char txt[2] = { 0, 0 };
txt[0] = 13; str_replace(tempStr, txt, "<ENTER>"); txt[0] = 13; str_replace(tempStr, txt, "<ENTER>");
txt[0] = 27; str_replace(tempStr, txt, "<ESC>"); txt[0] = 27; str_replace(tempStr, txt, "<ESC>");
@ -58,25 +61,44 @@ static char * GetDisplayText(char * t, int max)
return &tmptxt[0]; 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. * Constructor for the GuiKeyboard class.
*/ */
GuiKeyboard::GuiKeyboard(char * t, u32 max) GuiKeyboard::GuiKeyboard(char * t, u32 max)
{ {
#ifdef EXTENDED_KEYBOARD
width = 610; width = 610;
height = 440; height = 440;
#else
width = 540;
height = 400;
#endif
shift = 0; shift = 0;
caps = 0; caps = 0;
selectable = true; selectable = true;
focus = 0; // allow focus focus = 0; // allow focus
alignmentHor = ALIGN_CENTRE; alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE; alignmentVert = ALIGN_MIDDLE;
strncpy(kbtextstr, t, max); snprintf(kbtextstr, 255, "%s", t);
kbtextstr[max] = 0;
kbtextmaxlen = max; kbtextmaxlen = max;
Key thekeys[5][12] = { #ifdef EXTENDED_KEYBOARD
Key thekeys[KB_ROWS][KB_COLUMNS] = {
{ {
{14,0}, // F1 {14,0}, // F1
{15,0}, // F2 {15,0}, // F2
@ -89,7 +111,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
{22,0}, // F9 {22,0}, // F9
{23,0}, // F10 {23,0}, // F10
{24,0}, // F11 {24,0}, // F11
{25,0}, // F12 {25,0} // F12
}, },
{ {
{'`','~'}, {'`','~'},
@ -149,17 +171,79 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
{'\0','\0'} {'\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)); memcpy(keys, thekeys, sizeof(thekeys));
#ifdef EXTENDED_KEYBOARD
int yoff_1 = 20;
#else
int yoff_1 = 0;
#endif
keyTextbox = new GuiImageData(keyboard_textbox_png); keyTextbox = new GuiImageData(keyboard_textbox_png);
keyTextboxImg = new GuiImage(keyTextbox); keyTextboxImg = new GuiImage(keyTextbox);
keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keyTextboxImg->SetPosition(0, 20); keyTextboxImg->SetPosition(0, yoff_1);
this->Append(keyTextboxImg); 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->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText->SetPosition(0, 33); kbText->SetPosition(0, yoff_1 + 13);
this->Append(kbText); this->Append(kbText);
key = new GuiImageData(keyboard_key_png); 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); keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM); keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
trigA = new GuiTrigger; trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger; trig2 = new GuiTrigger;
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); trig2->SetSimpleTrigger(-1, WPAD_BUTTON_2, 0);
int yoff = 80; int yoff = 80;
#ifdef EXTENDED_KEYBOARD
keyEscImg = new GuiImage(keyMedium); keyEscImg = new GuiImage(keyMedium);
keyEscOverImg = new GuiImage(keyMediumOver); 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 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyEsc->SetImage(keyEscImg); keyEsc->SetImage(keyEscImg);
keyEsc->SetImageOver(keyEscOverImg); keyEsc->SetImageOver(keyEscOverImg);
@ -188,13 +274,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyEsc->SetSoundOver(keySoundOver); keyEsc->SetSoundOver(keySoundOver);
keyEsc->SetSoundClick(keySoundClick); keyEsc->SetSoundClick(keySoundClick);
keyEsc->SetTrigger(trigA); keyEsc->SetTrigger(trigA);
keyEsc->SetTrigger(trig2);
keyEsc->SetPosition(0, yoff); keyEsc->SetPosition(0, yoff);
keyEsc->SetEffectGrow(); keyEsc->SetEffectGrow();
this->Append(keyEsc); this->Append(keyEsc);
keyEnterImg = new GuiImage(keyMedium); keyEnterImg = new GuiImage(keyMedium);
keyEnterOverImg = new GuiImage(keyMediumOver); 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 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyEnter->SetImage(keyEnterImg); keyEnter->SetImage(keyEnterImg);
keyEnter->SetImageOver(keyEnterOverImg); keyEnter->SetImageOver(keyEnterOverImg);
@ -202,13 +289,15 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyEnter->SetSoundOver(keySoundOver); keyEnter->SetSoundOver(keySoundOver);
keyEnter->SetSoundClick(keySoundClick); keyEnter->SetSoundClick(keySoundClick);
keyEnter->SetTrigger(trigA); keyEnter->SetTrigger(trigA);
keyEnter->SetTrigger(trig2);
keyEnter->SetPosition(12*42+18, 4*42+yoff); keyEnter->SetPosition(12*42+18, 4*42+yoff);
keyEnter->SetEffectGrow(); keyEnter->SetEffectGrow();
this->Append(keyEnter); this->Append(keyEnter);
#endif
keyBackImg = new GuiImage(keyMedium); keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver); 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 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyBack->SetImage(keyBackImg); keyBack->SetImage(keyBackImg);
keyBack->SetImageOver(keyBackOverImg); keyBack->SetImageOver(keyBackOverImg);
@ -216,14 +305,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyBack->SetSoundOver(keySoundOver); keyBack->SetSoundOver(keySoundOver);
keyBack->SetSoundClick(keySoundClick); keyBack->SetSoundClick(keySoundClick);
keyBack->SetTrigger(trigA); keyBack->SetTrigger(trigA);
keyBack->SetTrigger(trigB); keyBack->SetTrigger(trig2);
keyBack->SetPosition(11*42+40, 1*42+yoff); keyBack->SetPosition((KB_COLUMNS-1)*42+40, (KB_ROWS-4)*42+yoff);
keyBack->SetEffectGrow(); keyBack->SetEffectGrow();
this->Append(keyBack); this->Append(keyBack);
keyCapsImg = new GuiImage(keyMedium); keyCapsImg = new GuiImage(keyMedium);
keyCapsOverImg = new GuiImage(keyMediumOver); 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 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyCaps->SetImage(keyCapsImg); keyCaps->SetImage(keyCapsImg);
keyCaps->SetImageOver(keyCapsOverImg); keyCaps->SetImageOver(keyCapsOverImg);
@ -231,13 +320,14 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyCaps->SetSoundOver(keySoundOver); keyCaps->SetSoundOver(keySoundOver);
keyCaps->SetSoundClick(keySoundClick); keyCaps->SetSoundClick(keySoundClick);
keyCaps->SetTrigger(trigA); keyCaps->SetTrigger(trigA);
keyCaps->SetPosition(0, 3*42+yoff); keyCaps->SetTrigger(trig2);
keyCaps->SetPosition(0, (KB_ROWS-2)*42+yoff);
keyCaps->SetEffectGrow(); keyCaps->SetEffectGrow();
this->Append(keyCaps); this->Append(keyCaps);
keyShiftImg = new GuiImage(keyMedium); keyShiftImg = new GuiImage(keyMedium);
keyShiftOverImg = new GuiImage(keyMediumOver); 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 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyShift->SetImage(keyShiftImg); keyShift->SetImage(keyShiftImg);
keyShift->SetImageOver(keyShiftOverImg); keyShift->SetImageOver(keyShiftOverImg);
@ -245,7 +335,8 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keyShift->SetSoundOver(keySoundOver); keyShift->SetSoundOver(keySoundOver);
keyShift->SetSoundClick(keySoundClick); keyShift->SetSoundClick(keySoundClick);
keyShift->SetTrigger(trigA); keyShift->SetTrigger(trigA);
keyShift->SetPosition(21, 4*42+yoff); keyShift->SetTrigger(trig2);
keyShift->SetPosition(21, (KB_ROWS-1)*42+yoff);
keyShift->SetEffectGrow(); keyShift->SetEffectGrow();
this->Append(keyShift); this->Append(keyShift);
@ -257,41 +348,46 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
keySpace->SetSoundOver(keySoundOver); keySpace->SetSoundOver(keySoundOver);
keySpace->SetSoundClick(keySoundClick); keySpace->SetSoundClick(keySoundClick);
keySpace->SetTrigger(trigA); 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->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keySpace->SetEffectGrow(); keySpace->SetEffectGrow();
this->Append(keySpace); this->Append(keySpace);
char txt[2] = { 0, 0 }; 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') if(keys[i][j].ch != '\0')
{ {
txt[0] = keys[i][j].ch; txt[0] = keys[i][j].ch;
keyImg[i][j] = new GuiImage(key); keyImg[i][j] = new GuiImage(key);
keyImgOver[i][j] = new GuiImage(keyOver); keyImgOver[i][j] = new GuiImage(keyOver);
#ifdef EXTENDED_KEYBOARD
switch(keys[i][j].ch) switch(keys[i][j].ch)
{ {
case 14: keyTxt[i][j] = new GuiText("F1", 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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (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", 22, (GXColor){0, 0, 0, 0xff}); break; case 25: keyTxt[i][j] = new GuiText("F12", KB_FONTSIZE, (GXColor){0, 0, 0, 0xff}); break;
default: 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; 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]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
keyTxt[i][j]->SetPosition(0, -10); keyTxt[i][j]->SetPosition(0, -10);
keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight()); 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]->SetSoundOver(keySoundOver);
keyBtn[i][j]->SetSoundClick(keySoundClick); keyBtn[i][j]->SetSoundClick(keySoundClick);
keyBtn[i][j]->SetTrigger(trigA); keyBtn[i][j]->SetTrigger(trigA);
keyBtn[i][j]->SetTrigger(trig2);
keyBtn[i][j]->SetLabel(keyTxt[i][j]); keyBtn[i][j]->SetLabel(keyTxt[i][j]);
#ifdef EXTENDED_KEYBOARD
int stagger; int stagger;
switch(i) switch(i)
{ {
@ -311,6 +409,9 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max)
} }
keyBtn[i][j]->SetPosition(j*42+stagger+40, i*42+yoff); 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(); keyBtn[i][j]->SetEffectGrow();
this->Append(keyBtn[i][j]); this->Append(keyBtn[i][j]);
} }
@ -326,6 +427,7 @@ GuiKeyboard::~GuiKeyboard()
delete kbText; delete kbText;
delete keyTextbox; delete keyTextbox;
delete keyTextboxImg; delete keyTextboxImg;
#ifdef EXTENDED_KEYBOARD
delete keyEscText; delete keyEscText;
delete keyEscImg; delete keyEscImg;
delete keyEscOverImg; delete keyEscOverImg;
@ -334,6 +436,7 @@ GuiKeyboard::~GuiKeyboard()
delete keyEnterImg; delete keyEnterImg;
delete keyEnterOverImg; delete keyEnterOverImg;
delete keyEnter; delete keyEnter;
#endif
delete keyCapsText; delete keyCapsText;
delete keyCapsImg; delete keyCapsImg;
delete keyCapsOverImg; delete keyCapsOverImg;
@ -358,10 +461,11 @@ GuiKeyboard::~GuiKeyboard()
delete keySoundOver; delete keySoundOver;
delete keySoundClick; delete keySoundClick;
delete trigA; 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') if(keys[i][j].ch != '\0')
{ {
@ -387,39 +491,50 @@ void GuiKeyboard::Update(GuiTrigger * t)
bool update = false; bool update = false;
#ifdef EXTENDED_KEYBOARD
if(keyEsc->GetState() == STATE_CLICKED) 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 kbtextstr[len] = 27; // Esc key code
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen)); kbtextstr[len+1] = '\0';
kbText->SetText(GetDisplayText(kbtextstr));
} }
keyEsc->SetState(STATE_SELECTED, t->chan); keyEsc->SetState(STATE_SELECTED, t->chan);
} }
else if(keyEnter->GetState() == STATE_CLICKED) 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 kbtextstr[len] = 13; // Enter key code
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen)); kbtextstr[len+1] = '\0';
kbText->SetText(GetDisplayText(kbtextstr));
} }
keyEnter->SetState(STATE_SELECTED, t->chan); keyEnter->SetState(STATE_SELECTED, t->chan);
} }
else if(keySpace->GetState() == STATE_CLICKED) else if(keySpace->GetState() == STATE_CLICKED)
#else
if(keySpace->GetState() == STATE_CLICKED)
#endif
{ // body for if from macro!
size_t len = strlen(kbtextstr);
if(len < kbtextmaxlen-1)
{ {
if(strlen(kbtextstr) < kbtextmaxlen) kbtextstr[len] = ' ';
{ kbtextstr[len+1] = '\0';
kbtextstr[strlen(kbtextstr)] = ' '; kbText->SetText(kbtextstr);
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen));
} }
keySpace->SetState(STATE_SELECTED, t->chan); keySpace->SetState(STATE_SELECTED, t->chan);
} }
else if(keyBack->GetState() == STATE_CLICKED) else if(keyBack->GetState() == STATE_CLICKED)
{ {
if(strlen(kbtextstr) > 0) size_t len = strlen(kbtextstr);
if(len > 0)
{ {
kbtextstr[strlen(kbtextstr)-1] = 0; kbtextstr[len-1] = '\0';
kbText->SetText(GetDisplayText(kbtextstr, kbtextmaxlen)); kbText->SetText(GetDisplayText(kbtextstr));
} }
keyBack->SetState(STATE_SELECTED, t->chan); keyBack->SetState(STATE_SELECTED, t->chan);
} }
@ -440,13 +555,17 @@ void GuiKeyboard::Update(GuiTrigger * t)
startloop: 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(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) if(shift || caps)
txt[0] = keys[i][j].chShift; txt[0] = keys[i][j].chShift;
@ -458,18 +577,21 @@ void GuiKeyboard::Update(GuiTrigger * t)
if(keyBtn[i][j]->GetState() == STATE_CLICKED) if(keyBtn[i][j]->GetState() == STATE_CLICKED)
{ {
if(strlen(kbtextstr) < kbtextmaxlen) size_t len = strlen(kbtextstr);
if(len < kbtextmaxlen-1)
{ {
if(shift || caps) if(shift || caps)
{ {
kbtextstr[strlen(kbtextstr)] = keys[i][j].chShift; kbtextstr[len] = keys[i][j].chShift;
} }
else 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); keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);
if(shift) if(shift)

View File

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

View File

@ -9,6 +9,7 @@
***************************************************************************/ ***************************************************************************/
#include "gui.h" #include "gui.h"
//#include "../gettext.h"
static GXColor presetColor = (GXColor){255, 255, 255, 255}; static GXColor presetColor = (GXColor){255, 255, 255, 255};
static int currentSize = 0; static int currentSize = 0;
@ -21,6 +22,12 @@ static u16 presetStyle = 0;
#define TEXT_SCROLL_DELAY 8 #define TEXT_SCROLL_DELAY 8
#define TEXT_SCROLL_INITIAL_DELAY 6 #define TEXT_SCROLL_INITIAL_DELAY 6
static const char *gettext(const char *msg)
{
return msg;
}
/** /**
* Constructor for the GuiText class. * Constructor for the GuiText class.
*/ */
@ -46,7 +53,7 @@ GuiText::GuiText(const char * t, int s, GXColor c)
if(t) if(t)
{ {
origText = strdup(t); origText = strdup(t);
text = charToWideChar(t); text = charToWideChar(gettext(t));
} }
for(int i=0; i < 20; i++) for(int i=0; i < 20; i++)
@ -78,7 +85,7 @@ GuiText::GuiText(const char * t)
if(t) if(t)
{ {
origText = strdup(t); origText = strdup(t);
text = charToWideChar(t); text = charToWideChar(gettext(t));
} }
for(int i=0; i < 20; i++) for(int i=0; i < 20; i++)
@ -126,7 +133,7 @@ void GuiText::SetText(const char * t)
if(t) if(t)
{ {
origText = strdup(t); origText = strdup(t);
text = charToWideChar(t); text = charToWideChar(gettext(t));
} }
} }
@ -300,7 +307,7 @@ void GuiText::ResetText()
if(text) if(text)
delete[] text; delete[] text;
text = charToWideChar(origText); text = charToWideChar(gettext(origText));
for(int i=0; i < textDynNum; i++) 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) s8 GuiTrigger::WPAD_Stick(u8 stick, int axis)
{ {
#ifdef HW_RVL
float mag = 0.0; float mag = 0.0;
float ang = 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); val = mag * cos((PI * ang)/180.0f);
return (s8)(val * 128.0f); return (s8)(val * 128.0f);
#else
return 0;
#endif
} }
s8 GuiTrigger::WPAD_StickX(u8 stick) s8 GuiTrigger::WPAD_StickX(u8 stick)

View File

@ -15,6 +15,7 @@
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <sys/param.h>
#include "libwiigui/gui.h" #include "libwiigui/gui.h"
#include "wiihardware.h" #include "wiihardware.h"

View File

@ -4,6 +4,7 @@
#include <errno.h> #include <errno.h>
#include <libgen.h> #include <libgen.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h>
#include "dos_inc.h" #include "dos_inc.h"
static char tmp[MAXPATHLEN]; static char tmp[MAXPATHLEN];

View File

@ -149,7 +149,7 @@ static void * PressKeys (void *arg)
static bool gecko = false; static bool gecko = false;
static mutex_t gecko_mutex = 0; static mutex_t gecko_mutex = 0;
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len) static ssize_t __out_write(struct _reent *r, void* fd, const char *ptr, size_t len)
{ {
u32 level; u32 level;