Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: simplify button prompts #128

Merged
merged 14 commits into from
Jun 28, 2023
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ jobs:
run: make createzip

- name: Build Apollo App Package
run: make
run: |
make
mv IV0000-APOL00004_00-APOLLO0000000PS4.pkg apollo-ps4-build_${{ env.sha_name }}.pkg

- name: Push package artifact
uses: actions/upload-artifact@v3
with:
name: apollo-ps4-build_${{ env.sha_name }}
path: IV0000-APOL00004_00-APOLLO0000000PS4.pkg
path: apollo-ps4-build_${{ env.sha_name }}.pkg
if-no-files-found: error
3 changes: 2 additions & 1 deletion include/orbisPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ typedef struct OrbisPadConfig
unsigned int buttonsHold;
unsigned int idle;
int padHandle;
int crossButtonOK;
}OrbisPadConfig;

int orbisPadInit();
int orbisPadInit(void);
void orbisPadFinish();
OrbisPadConfig *orbisPadGetConf();
bool orbisPadGetButtonHold(unsigned int filter);
Expand Down
102 changes: 65 additions & 37 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ SDL_Renderer* renderer; // SDL software renderer
uint32_t* texture_mem; // Pointers to texture memory
uint32_t* free_mem; // Pointer after last texture


const char * menu_pad_help[TOTAL_MENU_IDS] = { NULL, //Main
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //Trophy list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //USB list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //HDD list
"\x10 Select \x13 Back \x11 Refresh", //Online list
"\x10 Select \x13 Back \x11 Refresh", //User backup
"\x10 Select \x13 Back", //Options
"\x13 Back", //About
"\x10 Select \x12 View Code \x13 Back", //Select Cheats
"\x13 Back", //View Cheat
"\x10 Select \x13 Back", //Cheat Option
"\x13 Back", //View Details
"\x10 Value Up \x11 Value Down \x13 Exit", //Hex Editor
};

/*
* HDD save list
*/
Expand Down Expand Up @@ -152,6 +136,67 @@ save_list_t user_backup = {
.UpdatePath = NULL,
};

static const char* get_button_prompts(int menu_id)
{
const char* prompt = NULL;

switch (menu_id)
{
case MENU_TROPHIES:
case MENU_USB_SAVES:
case MENU_HDD_SAVES:
prompt = "\x10 Select \x13 Back \x12 Details \x11 Refresh";
break;

case MENU_USER_BACKUP:
case MENU_ONLINE_DB:
prompt = "\x10 Select \x13 Back \x11 Refresh";
break;

case MENU_SETTINGS:
case MENU_CODE_OPTIONS:
prompt = "\x10 Select \x13 Back";
break;

case MENU_CREDITS:
case MENU_PATCH_VIEW:
case MENU_SAVE_DETAILS:
prompt = "\x13 Back";
break;

case MENU_PATCHES:
prompt = "\x10 Select \x12 View Code \x13 Back";
break;

case MENU_HEX_EDITOR:
prompt = "\x10 Value Up \x11 Value Down \x13 Exit";
break;

case MENU_MAIN_SCREEN:
default:
prompt = "";
break;
}

return prompt;
}

static void helpFooter(void)
{
u8 alpha = 0xFF;

if (apollo_config.doAni && orbisPadGetConf()->idle > 0x100)
{
int dec = (orbisPadGetConf()->idle - 0x100) * 2;
alpha = (dec > alpha) ? 0 : (alpha - dec);
}

SetFontSize(APP_FONT_SIZE_DESCRIPTION);
SetFontAlign(FONT_ALIGN_SCREEN_CENTER);
SetFontColor(APP_FONT_COLOR | alpha, 0);
DrawString(0, SCREEN_HEIGHT - 94, get_button_prompts(menu_id));
SetFontAlign(FONT_ALIGN_LEFT);
}

static int initPad()
{
Expand Down Expand Up @@ -355,7 +400,7 @@ void update_db_path(char* path)
strcpy(path, apollo_config.save_db);
}

static void registerSpecialChars()
static void registerSpecialChars(void)
{
// Register save tags
RegisterSpecialCharacter(CHAR_TAG_PS1, 2, 1.5, &menu_textures[tag_ps1_png_index]);
Expand All @@ -374,10 +419,10 @@ static void registerSpecialChars()
RegisterSpecialCharacter(CHAR_TAG_TRANSFER, 0, 1.0, &menu_textures[tag_transfer_png_index]);

// Register button icons
RegisterSpecialCharacter(CHAR_BTN_X, 0, 1.2, &menu_textures[footer_ico_cross_png_index]);
RegisterSpecialCharacter(orbisPadGetConf()->crossButtonOK ? CHAR_BTN_X : CHAR_BTN_O, 0, 1.2, &menu_textures[footer_ico_cross_png_index]);
RegisterSpecialCharacter(CHAR_BTN_S, 0, 1.2, &menu_textures[footer_ico_square_png_index]);
RegisterSpecialCharacter(CHAR_BTN_T, 0, 1.2, &menu_textures[footer_ico_triangle_png_index]);
RegisterSpecialCharacter(CHAR_BTN_O, 0, 1.2, &menu_textures[footer_ico_circle_png_index]);
RegisterSpecialCharacter(orbisPadGetConf()->crossButtonOK ? CHAR_BTN_O : CHAR_BTN_X, 0, 1.2, &menu_textures[footer_ico_circle_png_index]);

// Register trophy icons
RegisterSpecialCharacter(CHAR_TRP_BRONZE, 2, 0.9f, &menu_textures[trp_bronze_png_index]);
Expand Down Expand Up @@ -584,24 +629,7 @@ s32 main(s32 argc, const char* argv[])
drawScene();

//Draw help
if (menu_pad_help[menu_id])
{
u8 alpha = 0xFF;
if (orbisPadGetConf()->idle > 0x100)
{
int dec = (orbisPadGetConf()->idle - 0x100) * 2;
if (dec > alpha)
dec = alpha;
alpha -= dec;
}

SetFontSize(APP_FONT_SIZE_DESCRIPTION);
SetCurrentFont(font_adonais_regular);
SetFontAlign(FONT_ALIGN_SCREEN_CENTER);
SetFontColor(APP_FONT_COLOR | alpha, 0);
DrawString(0, SCREEN_HEIGHT - 94, (char *)menu_pad_help[menu_id]);
SetFontAlign(FONT_ALIGN_LEFT);
}
helpFooter();

#ifdef APOLLO_ENABLE_LOGGING
// Calculate FPS and ms/frame
Expand Down
3 changes: 2 additions & 1 deletion source/menu_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "menu.h"
#include "menu_gui.h"
#include "libfont.h"
#include "orbisPad.h"

static void _draw_OptionsMenu(u8 alpha)
{
Expand All @@ -32,7 +33,7 @@ static void _draw_OptionsMenu(u8 alpha)
DrawTexture(&menu_textures[c], OPTION_ITEM_OFF - 29, y_off, 0, menu_textures[c].width, menu_textures[c].height, 0xFFFFFF00 | alpha);
break;
case APP_OPTION_CALL:
DrawTexture(&menu_textures[footer_ico_cross_png_index], OPTION_ITEM_OFF - 29, y_off+2, 0, menu_textures[footer_ico_cross_png_index].width, menu_textures[footer_ico_cross_png_index].height, 0xFFFFFF00 | alpha);
DrawTexture(&menu_textures[orbisPadGetConf()->crossButtonOK ? footer_ico_cross_png_index : footer_ico_circle_png_index], OPTION_ITEM_OFF - 29, y_off+2, 0, menu_textures[footer_ico_cross_png_index].width, menu_textures[footer_ico_cross_png_index].height, 0xFFFFFF00 | alpha);
break;
case APP_OPTION_LIST:
SetFontAlign(FONT_ALIGN_CENTER);
Expand Down
14 changes: 13 additions & 1 deletion source/orbisPad.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <stdint.h>
#include <sys/time.h>
#include <dbglogger.h>
#include <orbis/SystemService.h>
#include "orbisPad.h"

#define LOG dbglogger_log
Expand Down Expand Up @@ -103,6 +104,9 @@ bool orbisPadGetButtonHold(unsigned int filter)

bool orbisPadGetButtonPressed(unsigned int filter)
{
if (!orbisPadConf.crossButtonOK && (filter & (ORBIS_PAD_BUTTON_CROSS|ORBIS_PAD_BUTTON_CIRCLE)))
filter ^= (ORBIS_PAD_BUTTON_CROSS|ORBIS_PAD_BUTTON_CIRCLE);

if((orbisPadConf.buttonsPressed&filter)==filter)
{
orbisPadConf.buttonsPressed ^= filter;
Expand Down Expand Up @@ -173,7 +177,7 @@ int orbisPadUpdate()
return -1;
}

int orbisPadInit()
int orbisPadInit(void)
{
int ret;
OrbisUserServiceInitializeParams param;
Expand Down Expand Up @@ -214,6 +218,14 @@ int orbisPadInit()
return -1;
}

ret = sceSystemServiceParamGetInt(ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN, &orbisPadConf.crossButtonOK);
if (ret < 0)
{
LOG("sceSystemServiceParamGetInt error 0x%08X", ret);
LOG("Failed to obtain ORBIS_SYSTEM_SERVICE_PARAM_ID_ENTER_BUTTON_ASSIGN info!, assigning X as main button.");
orbisPadConf.crossButtonOK = 1;
}

orbispad_initialized=1;
g_time = timeInMilliseconds();
LOG("ORBISPAD initialized: scePadOpen return handle 0x%X", orbisPadConf.padHandle);
Expand Down