From 0ff5205acbf9b426697de97917036bde0ad298ba Mon Sep 17 00:00:00 2001 From: retro100 Date: Tue, 20 Apr 2021 21:34:01 +0200 Subject: [PATCH] Update to current devkitPro/libogc version. Some bugfixes for keyboard and some updates from libwiigui repo. --- Makefile | 37 +-- src/gui/sdlmain.cpp | 6 + src/platform/wii/filelist.h | 129 +++------- src/platform/wii/libwiigui/gui.h | 35 ++- src/platform/wii/libwiigui/gui_keyboard.cpp | 250 +++++++++++++++----- src/platform/wii/libwiigui/gui_sound.cpp | 12 + src/platform/wii/libwiigui/gui_text.cpp | 15 +- src/platform/wii/libwiigui/gui_trigger.cpp | 6 + src/platform/wii/menu.cpp | 1 + src/platform/wii/missingfunctions.cpp | 1 + src/platform/wii/wiihardware.cpp | 2 +- 11 files changed, 304 insertions(+), 190 deletions(-) diff --git a/Makefile b/Makefile index 8e3bd6b..c00ba73 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map # any extra libraries we wish to link with #--------------------------------------------------------------------------------- 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 @@ -66,10 +66,9 @@ CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) -TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf))) -PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) -OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg))) -PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm))) +BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf) \ + $(wildcard $(dir)/*.lang) $(wildcard $(dir)/*.png) \ + $(wildcard $(dir)/*.ogg) $(wildcard $(dir)/*.pcm))) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C @@ -80,10 +79,11 @@ else export LD := $(CXX) endif -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ - $(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.o) \ - $(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.o) +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) + +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) #--------------------------------------------------------------------------------- # build a list of include paths @@ -91,7 +91,7 @@ export OFILES := $(addsuffix .o,$(BINFILES)) \ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -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 @@ -131,22 +131,27 @@ DEPENDS := $(OFILES:.o=.d) $(OUTPUT).dol: $(OUTPUT).elf $(OUTPUT).elf: $(OFILES) +$(OFILES_SOURCES): $(HFILES) #--------------------------------------------------------------------------------- # This rule links in binary data with .ttf, .png, and .mp3 extensions #--------------------------------------------------------------------------------- -%.ttf.o : %.ttf +%.ttf.o %_ttf.h : %.ttf @echo $(notdir $<) $(bin2o) -%.png.o : %.png +%.lang.o %_lang.h : %.lang @echo $(notdir $<) $(bin2o) - -%.ogg.o : %.ogg + +%.png.o %_png.h : %.png @echo $(notdir $<) $(bin2o) - -%.pcm.o : %.pcm + +%.ogg.o %_ogg.h : %.ogg + @echo $(notdir $<) + $(bin2o) + +%.pcm.o %_pcm.h : %.pcm @echo $(notdir $<) $(bin2o) diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 1cc8076..284d0e9 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -1486,6 +1486,12 @@ void GFX_Events() { // check for home button u32 btns; 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++) { btns = WPAD_ButtonsHeld(i); diff --git a/src/platform/wii/filelist.h b/src/platform/wii/filelist.h index d07ff7c..f485529 100644 --- a/src/platform/wii/filelist.h +++ b/src/platform/wii/filelist.h @@ -11,102 +11,39 @@ #ifndef _FILELIST_H_ #define _FILELIST_H_ -#include +//#include -extern const u8 font_ttf[]; -extern const u32 font_ttf_size; - -extern const u8 enter_ogg[]; -extern const u32 enter_ogg_size; - -extern const u8 exit_ogg[]; -extern const u32 exit_ogg_size; - -extern const u8 button_over_pcm[]; -extern const u32 button_over_pcm_size; - -extern const u8 button_click_pcm[]; -extern const u32 button_click_pcm_size; - -extern const u8 logo_png[]; -extern const u32 logo_png_size; - -extern const u8 logo_over_png[]; -extern const u32 logo_over_png_size; - -extern const u8 bg_top_png[]; -extern const u32 bg_top_png_size; - -extern const u8 bg_bottom_png[]; -extern const u32 bg_bottom_png_size; - -extern const u8 button_png[]; -extern const u32 button_png_size; - -extern const u8 button_over_png[]; -extern const u32 button_over_png_size; - -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; +#include "battery_bar_png.h" +#include "battery_png.h" +#include "battery_red_png.h" +#include "bg_bottom_png.h" +#include "bg_top_png.h" +#include "button_click_pcm.h" +#include "button_large_over_png.h" +#include "button_large_png.h" +#include "button_over_pcm.h" +#include "button_over_png.h" +#include "button_png.h" +#include "button_small_over_png.h" +#include "button_small_png.h" +#include "credits_box_png.h" +#include "enter_ogg.h" +#include "exit_ogg.h" +#include "font_ttf.h" +#include "keyboard_key_over_png.h" +#include "keyboard_key_png.h" +#include "keyboard_largekey_over_png.h" +#include "keyboard_largekey_png.h" +#include "keyboard_mediumkey_over_png.h" +#include "keyboard_mediumkey_png.h" +#include "keyboard_textbox_png.h" +#include "logo_over_png.h" +#include "logo_png.h" +#include "player1_point_png.h" +#include "player2_point_png.h" +#include "player3_point_png.h" +#include "player4_point_png.h" +#include "tv_over_png.h" +#include "tv_png.h" #endif diff --git a/src/platform/wii/libwiigui/gui.h b/src/platform/wii/libwiigui/gui.h index 53412ff..daa6847 100644 --- a/src/platform/wii/libwiigui/gui.h +++ b/src/platform/wii/libwiigui/gui.h @@ -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 diff --git a/src/platform/wii/libwiigui/gui_keyboard.cpp b/src/platform/wii/libwiigui/gui_keyboard.cpp index 42c3d07..0d272be 100644 --- a/src/platform/wii/libwiigui/gui_keyboard.cpp +++ b/src/platform/wii/libwiigui/gui_keyboard.cpp @@ -9,20 +9,23 @@ ***************************************************************************/ #include "gui.h" +#ifdef EXTENDED_KEYBOARD #include +#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, ""); txt[0] = 27; str_replace(tempStr, txt, ""); @@ -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; iSetAlignment(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; iGetState() == 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 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) diff --git a/src/platform/wii/libwiigui/gui_sound.cpp b/src/platform/wii/libwiigui/gui_sound.cpp index 8a718c7..95c51cf 100644 --- a/src/platform/wii/libwiigui/gui_sound.cpp +++ b/src/platform/wii/libwiigui/gui_sound.cpp @@ -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) diff --git a/src/platform/wii/libwiigui/gui_text.cpp b/src/platform/wii/libwiigui/gui_text.cpp index 842ba43..2e8c5d2 100644 --- a/src/platform/wii/libwiigui/gui_text.cpp +++ b/src/platform/wii/libwiigui/gui_text.cpp @@ -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++) { diff --git a/src/platform/wii/libwiigui/gui_trigger.cpp b/src/platform/wii/libwiigui/gui_trigger.cpp index d4f98c6..33684a8 100644 --- a/src/platform/wii/libwiigui/gui_trigger.cpp +++ b/src/platform/wii/libwiigui/gui_trigger.cpp @@ -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) diff --git a/src/platform/wii/menu.cpp b/src/platform/wii/menu.cpp index 020d3f6..5d22339 100644 --- a/src/platform/wii/menu.cpp +++ b/src/platform/wii/menu.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "libwiigui/gui.h" #include "wiihardware.h" diff --git a/src/platform/wii/missingfunctions.cpp b/src/platform/wii/missingfunctions.cpp index 90bcbce..fb316fc 100644 --- a/src/platform/wii/missingfunctions.cpp +++ b/src/platform/wii/missingfunctions.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "dos_inc.h" static char tmp[MAXPATHLEN]; diff --git a/src/platform/wii/wiihardware.cpp b/src/platform/wii/wiihardware.cpp index 665966e..71a57cd 100644 --- a/src/platform/wii/wiihardware.cpp +++ b/src/platform/wii/wiihardware.cpp @@ -149,7 +149,7 @@ static void * PressKeys (void *arg) static bool gecko = false; 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;