Skip to content

Commit

Permalink
Fix Circle/Cross button assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Jun 27, 2023
1 parent ad3e252 commit f39b07c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
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
6 changes: 3 additions & 3 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,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 @@ -432,10 +432,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
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(orbisPadGetConf()->crossButtonOK ? &menu_textures[footer_ico_cross_png_index] : &menu_textures[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

0 comments on commit f39b07c

Please sign in to comment.