initial changes for an rpx homebrew launcher

This commit is contained in:
dimok789 2016-10-19 17:56:50 +02:00
parent bac8f15944
commit 8904f9600c
4 changed files with 32 additions and 24 deletions

View File

@ -42,9 +42,9 @@ DirList::DirList()
Depth = 0; Depth = 0;
} }
DirList::DirList(const std::string & path, const char *filter, u32 flags, u32 maxDepth) DirList::DirList(const std::string & path, const char *filter, u32 flags, u32 depth)
{ {
this->LoadPath(path, filter, flags, maxDepth); this->LoadPath(path, filter, flags, depth);
this->SortList(); this->SortList();
} }
@ -53,13 +53,13 @@ DirList::~DirList()
ClearList(); ClearList();
} }
bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags, u32 maxDepth) bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags, u32 depth)
{ {
if(folder.empty()) return false; if(folder.empty()) return false;
Flags = flags; Flags = flags;
Filter = filter; Filter = filter;
Depth = maxDepth; Depth = depth;
std::string folderpath(folder); std::string folderpath(folder);
u32 length = folderpath.size(); u32 length = folderpath.size();
@ -78,6 +78,7 @@ bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags
return InternalLoadPath(folderpath); return InternalLoadPath(folderpath);
} }
#include "utils/logger.h"
bool DirList::InternalLoadPath(std::string &folderpath) bool DirList::InternalLoadPath(std::string &folderpath)
{ {
if(folderpath.size() < 3) if(folderpath.size() < 3)
@ -86,6 +87,7 @@ bool DirList::InternalLoadPath(std::string &folderpath)
struct dirent *dirent = NULL; struct dirent *dirent = NULL;
DIR *dir = NULL; DIR *dir = NULL;
log_printf("open %s\n", folderpath.c_str());
dir = opendir(folderpath.c_str()); dir = opendir(folderpath.c_str());
if (dir == NULL) if (dir == NULL)
return false; return false;

View File

@ -45,11 +45,11 @@ public:
//!\param path Path from where to load the filelist of all files //!\param path Path from where to load the filelist of all files
//!\param filter A fileext that needs to be filtered //!\param filter A fileext that needs to be filtered
//!\param flags search/filter flags from the enum //!\param flags search/filter flags from the enum
DirList(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 maxDepth = 0xffffffff); DirList(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 depth = 0xffffffff);
//!Destructor //!Destructor
virtual ~DirList(); virtual ~DirList();
//! Load all the files from a directory //! Load all the files from a directory
bool LoadPath(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 maxDepth = 0xffffffff); bool LoadPath(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 depth = 0xffffffff);
//! Get a filename of the list //! Get a filename of the list
//!\param list index //!\param list index
const char * GetFilename(int index) const; const char * GetFilename(int index) const;

View File

@ -20,15 +20,15 @@
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>. * along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "FreeTypeGX.h"
#include "video/CVideo.h" #include "video/CVideo.h"
#include "video/shaders/Texture2DShader.h" #include "video/shaders/Texture2DShader.h"
#include "utils/logger.h" #include "FreeTypeGX.h"
using namespace std; using namespace std;
#define ALIGN4(x) (((x) + 3) & ~3) #define ALIGN4(x) (((x) + 3) & ~3)
#include "utils/logger.h"
/** /**
* Default constructor for the FreeTypeGX class for WiiXplorer. * Default constructor for the FreeTypeGX class for WiiXplorer.
*/ */
@ -370,7 +370,7 @@ int16_t FreeTypeGX::getStyleOffsetHeight(int16_t format, uint16_t pixelSize)
* @return The number of characters printed. * @return The number of characters printed.
*/ */
uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, const wchar_t *text, int16_t pixelSize, const glm::vec4 & color, uint16_t textStyle, uint16_t textWidth, const float &textBlur, const float & colorBlurIntensity, const glm::vec4 & blurColor, const float & internalRenderingScale) uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, const wchar_t *text, int16_t pixelSize, const glm::vec4 & color, uint16_t textStyle, uint16_t textWidth, const float &textBlur, const float &colorBlurIntensity, const glm::vec4 & blurColor)
{ {
if (!text) if (!text)
return 0; return 0;
@ -401,9 +401,9 @@ uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, co
{ {
FT_Get_Kerning(ftFace, fontData[pixelSize].ftgxCharMap[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta); FT_Get_Kerning(ftFace, fontData[pixelSize].ftgxCharMap[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta);
x_pos += (pairDelta.x >> 6); x_pos += (pairDelta.x >> 6);
} }
copyTextureToFramebuffer(video, glyphData->texture,x_pos + glyphData->renderOffsetX + x_offset, y + glyphData->renderOffsetY - y_offset, z, color, textBlur, colorBlurIntensity, blurColor,internalRenderingScale);
copyTextureToFramebuffer(video, glyphData->texture, x_pos + glyphData->renderOffsetX + x_offset, y + glyphData->renderOffsetY - y_offset, z, color, textBlur, colorBlurIntensity, blurColor);
x_pos += glyphData->glyphAdvanceX; x_pos += glyphData->glyphAdvanceX;
++printed; ++printed;
@ -548,13 +548,13 @@ void FreeTypeGX::getOffset(const wchar_t *text, int16_t pixelSize, uint16_t widt
* @param screenY The screen Y coordinate at which to output the rendered texture. * @param screenY The screen Y coordinate at which to output the rendered texture.
* @param color Color to apply to the texture. * @param color Color to apply to the texture.
*/ */
void FreeTypeGX::copyTextureToFramebuffer(CVideo *pVideo, GX2Texture *texture, int16_t x, int16_t y, int16_t z, const glm::vec4 & color, const float & defaultBlur, const float & blurIntensity, const glm::vec4 & blurColor, const float & internalRenderingScale) void FreeTypeGX::copyTextureToFramebuffer(CVideo *pVideo, GX2Texture *texture, int16_t x, int16_t y, int16_t z, const glm::vec4 & color, const float & defaultBlur, const float & blurIntensity, const glm::vec4 & blurColor)
{ {
static const f32 imageAngle = 0.0f; static const f32 imageAngle = 0.0f;
static const f32 blurScale = (2.0f/ (internalRenderingScale)); static const f32 blurScale = 2.0f;
f32 offsetLeft = blurScale * ((f32)x + 0.5f * (f32)texture->surface.width) * (f32)pVideo->getWidthScaleFactor(); f32 offsetLeft = 2.0f * ((f32)x + 0.5f * (f32)texture->surface.width) * (f32)pVideo->getWidthScaleFactor();
f32 offsetTop = blurScale * ((f32)y - 0.5f * (f32)texture->surface.height) * (f32)pVideo->getHeightScaleFactor(); f32 offsetTop = 2.0f * ((f32)y - 0.5f * (f32)texture->surface.height) * (f32)pVideo->getHeightScaleFactor();
f32 widthScale = blurScale * (f32)texture->surface.width * pVideo->getWidthScaleFactor(); f32 widthScale = blurScale * (f32)texture->surface.width * pVideo->getWidthScaleFactor();
f32 heightScale = blurScale * (f32)texture->surface.height * pVideo->getHeightScaleFactor(); f32 heightScale = blurScale * (f32)texture->surface.height * pVideo->getHeightScaleFactor();

View File

@ -21,7 +21,6 @@
#include "fs/fs_utils.h" #include "fs/fs_utils.h"
#include "system/AsyncDeleter.h" #include "system/AsyncDeleter.h"
#include "utils/HomebrewXML.h" #include "utils/HomebrewXML.h"
#include "utils/utils.h"
#include "HomebrewLaunchWindow.h" #include "HomebrewLaunchWindow.h"
#define DEFAULT_WIILOAD_PORT 4299 #define DEFAULT_WIILOAD_PORT 4299
@ -52,15 +51,16 @@ HomebrewWindow::HomebrewWindow(int w, int h)
currentLeftPosition = 0; currentLeftPosition = 0;
listOffset = 0; listOffset = 0;
DirList dirList("sd:/wiiu/apps", ".elf,.rpx", DirList::Files | DirList::CheckSubfolders, 1); DirList dirList("fs:/", NULL, DirList::Files | DirList::CheckSubfolders, 1);
dirList.SortList(); dirList.SortList();
for(int i = 0; i < dirList.GetFilecount(); i++) for(int i = 0; i < dirList.GetFilecount(); i++)
{ {
log_printf("%i: %s\n", i, dirList.GetFilepath(i));
//! skip our own application in the listing //! skip our own application in the listing
if(strcasecmp(dirList.GetFilename(i), "homebrew_launcher.elf") == 0) //!if(strcasecmp(dirList.GetFilename(i), "homebrew_launcher.elf") == 0)
continue; //! continue;
//! skip hidden linux and mac files //! skip hidden linux and mac files
if(dirList.GetFilename(i)[0] == '.' || dirList.GetFilename(i)[0] == '_') if(dirList.GetFilename(i)[0] == '.' || dirList.GetFilename(i)[0] == '_')
@ -105,8 +105,8 @@ HomebrewWindow::HomebrewWindow(int w, int h)
const char *cpName = xmlReadSuccess ? metaXml.GetName() : homebrewButtons[idx].execPath.c_str(); const char *cpName = xmlReadSuccess ? metaXml.GetName() : homebrewButtons[idx].execPath.c_str();
const char *cpDescription = xmlReadSuccess ? metaXml.GetShortDescription() : ""; const char *cpDescription = xmlReadSuccess ? metaXml.GetShortDescription() : "";
if(strncmp(cpName, "sd:/wiiu/apps/", strlen("sd:/wiiu/apps/")) == 0) if(strncmp(cpName, "fs:/wiiu/apps/", strlen("fs:/wiiu/apps/")) == 0)
cpName += strlen("sd:/wiiu/apps/"); cpName += strlen("fs:/wiiu/apps/");
homebrewButtons[idx].nameLabel = new GuiText(cpName, 32, glm::vec4(1.0f)); homebrewButtons[idx].nameLabel = new GuiText(cpName, 32, glm::vec4(1.0f));
homebrewButtons[idx].nameLabel->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE); homebrewButtons[idx].nameLabel->setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
@ -124,8 +124,8 @@ HomebrewWindow::HomebrewWindow(int w, int h)
homebrewButtons[idx].button->setLabel(homebrewButtons[idx].nameLabel, 0); homebrewButtons[idx].button->setLabel(homebrewButtons[idx].nameLabel, 0);
homebrewButtons[idx].button->setLabel(homebrewButtons[idx].descriptionLabel, 1); homebrewButtons[idx].button->setLabel(homebrewButtons[idx].descriptionLabel, 1);
homebrewButtons[idx].button->setIcon(homebrewButtons[idx].iconImg); homebrewButtons[idx].button->setIcon(homebrewButtons[idx].iconImg);
float fXOffset = (idx / MAX_BUTTONS_ON_PAGE) * width; float fXOffset = (i / MAX_BUTTONS_ON_PAGE) * width;
float fYOffset = (homebrewButtons[idx].image->getHeight() + 20.0f) * 1.5f - (homebrewButtons[idx].image->getHeight() + 20) * (idx % MAX_BUTTONS_ON_PAGE); float fYOffset = (homebrewButtons[idx].image->getHeight() + 20.0f) * 1.5f - (homebrewButtons[idx].image->getHeight() + 20) * (i % MAX_BUTTONS_ON_PAGE);
homebrewButtons[idx].button->setPosition(currentLeftPosition + fXOffset, fYOffset); homebrewButtons[idx].button->setPosition(currentLeftPosition + fXOffset, fYOffset);
homebrewButtons[idx].button->setTrigger(&touchTrigger); homebrewButtons[idx].button->setTrigger(&touchTrigger);
homebrewButtons[idx].button->setTrigger(&wpadTouchTrigger); homebrewButtons[idx].button->setTrigger(&wpadTouchTrigger);
@ -314,6 +314,8 @@ void HomebrewWindow::OnCloseTcpReceiverFinish(GuiElement *element)
void HomebrewWindow::OnTcpReceiveStart(GuiElement *element, u32 ip) void HomebrewWindow::OnTcpReceiveStart(GuiElement *element, u32 ip)
{ {
setState(STATE_DISABLED);
element->setEffect(EFFECT_FADE, 15, 255); element->setEffect(EFFECT_FADE, 15, 255);
element->effectFinished.connect(this, &HomebrewWindow::OnOpenEffectFinish); element->effectFinished.connect(this, &HomebrewWindow::OnOpenEffectFinish);
append(element); append(element);
@ -327,7 +329,11 @@ void HomebrewWindow::OnTcpReceiveFinish(GuiElement *element, u32 ip, int result)
if(result > 0) if(result > 0)
{ {
log_printf("Launching homebrew, loaded to address %08X size %08X\n", ELF_DATA_ADDR, ELF_DATA_SIZE); u32 ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
ELF_DATA_ADDR = ApplicationMemoryEnd;
ELF_DATA_SIZE = result;
Application::instance()->quit(EXIT_SUCCESS); Application::instance()->quit(EXIT_SUCCESS);
} }
} }