Skip to content

Commit

Permalink
sLaunchMOD 1.17
Browse files Browse the repository at this point in the history
- Fixed polling pads too fast
- Fixed analog to DPAD conversion
- Fixed issue accessing Favorites
  • Loading branch information
aldostools committed Jan 10, 2024
1 parent 5f0066b commit 4ec12f2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 42 deletions.
68 changes: 39 additions & 29 deletions _Projects_/slaunch/include/pad.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
((((uint32_t)v) & 0x000000FF) << 24)))
*/
static CellPadData pdata;
static uint32_t oldpad=0, curpad=0;
static uint32_t oldpad = 0, curpad = 0;
static int32_t pad_port = 0;

/***********************************************************************
* search and return vsh_process toc
Expand Down Expand Up @@ -126,6 +127,8 @@ static void start_stop_vsh_pad(uint8_t flag)
***********************************************************************/
static void MyPadGetData(int32_t port_no, CellPadData *data)
{
//memset(data, 0, sizeof(CellPadData));

uint32_t port = *(uint32_t*)(*(uint32_t*)(get_vsh_pad_obj() + 4) + 0x104 + port_no * 0xE8);

// sys_hid_manager_read()
Expand All @@ -150,35 +153,42 @@ static int32_t rsx_fifo_pause(uint8_t pause)
static void pad_read(void)
{
// check only pad all ports
for(int32_t port=0; port<8; port++)
{MyPadGetData(port, &pdata); curpad = (pdata.button[2] | (pdata.button[3] << 8)); if(curpad && (pdata.len > 0)) break;} // use MyPadGetData() during VSH menu

/* Analog left stick management */
if (pdata.button[6] < 0x10)
curpad |= PAD_LEFT;
else if (pdata.button[6] > 0xe0)
curpad |= PAD_RIGHT;

if (pdata.button[7] < 0x10)
curpad |= PAD_UP;
else if (pdata.button[7] > 0xe0)
curpad |= PAD_DOWN;

/* Analog right stick management */
if (pdata.button[4] < 0x10)
curpad |= PAD_LEFT;
else if (pdata.button[4] > 0xe0)
curpad |= PAD_RIGHT;

if (pdata.button[5] < 0x10)
curpad |= PAD_UP;
else if (pdata.button[5] > 0xe0)
curpad |= PAD_DOWN;

sys_timer_usleep(10000);
for(int32_t port = 0; port < 8; port++)
{
MyPadGetData(port, &pdata); // use MyPadGetData() during VSH menu
curpad = (pdata.button[2] | (pdata.button[3] << 8));
if(pdata.len > 0)
{
/* Analog left stick management */
if (pdata.button[6] < 0x10)
curpad |= PAD_LEFT;
else if (pdata.button[6] > 0xf0)
curpad |= PAD_RIGHT;

if (pdata.button[7] < 0x10)
curpad |= PAD_UP;
else if (pdata.button[7] > 0xf0)
curpad |= PAD_DOWN;

/* Analog right stick management */
if (pdata.button[4] < 0x10)
curpad |= PAD_LEFT;
else if (pdata.button[4] > 0xf0)
curpad |= PAD_RIGHT;

if (pdata.button[5] < 0x10)
curpad |= PAD_UP;
else if (pdata.button[5] > 0xf0)
curpad |= PAD_DOWN;

if(curpad) {pad_port = port; break;}
}
}

sys_timer_usleep(18000);
}

static void release_cross(void)
static void wait_for_button_release(uint32_t button)
{
while(true) {pad_read(); if(curpad & PAD_CROSS) sys_timer_usleep(150000); else break;}
while(true) {pad_read(); if(curpad & button) sys_timer_usleep(150000); else break;}
}
32 changes: 19 additions & 13 deletions _Projects_/slaunch/slaunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SYS_MODULE_STOP(slaunch_stop);
#define STR_UNLOAD "Unload webMAN"
#define STR_QUIT "Quit"

#define APP_VERSION "1.16b"
#define APP_VERSION "1.17"

typedef struct {
uint8_t gmode;
Expand Down Expand Up @@ -205,15 +205,15 @@ static void draw_page(uint16_t game_idx, uint8_t key_repeat)

if(!games) return;

const int left_margin=56;
const int left_margin = 56;

uint8_t slot = 0;
uint16_t i, j, p;
int px=left_margin, py; // top-left

// draw background and menu strip
flip_frame();
memcpy((uint8_t *)ctx.menu, (uint8_t *)(ctx.canvas)+INFOBAR_Y*CANVAS_W*4, CANVAS_W*INFOBAR_H*4);
memcpy((uint8_t *)ctx.menu, (uint8_t *)(ctx.canvas) + INFOBAR_Y * CANVAS_W * 4, CANVAS_W * INFOBAR_H * 4);

set_textbox(LIGHT_GRAY, 0, INFOBAR_Y - 10, CANVAS_W, 1);
set_textbox(GRAY, 0, INFOBAR_Y - 9, CANVAS_W, 1);
Expand All @@ -223,21 +223,21 @@ static void draw_page(uint16_t game_idx, uint8_t key_repeat)
set_textbox(GRAY, 0, INFOBAR_Y + INFOBAR_H + 3, CANVAS_W, 1);
set_textbox(LIGHT_GRAY, 0, INFOBAR_Y + INFOBAR_H + 4, CANVAS_W, 1);

if(disp_h<720) gpp=10;
if(disp_h<720) gpp = 10;

draw_selection(game_idx);

// draw game icons (5x2) or (10x4)
j=(game_idx/gpp)*gpp;
p=(games-1) - ((games-1) % gpp);
for(i=j;slot<gpp;i++)
for(i = j; slot < gpp; i++)
{
if(i>=games) break;
if(i >= games) break;

// abort drawing if page is changed with L1 or R1 while processing
if(i & 1)
{
MyPadGetData(0, &pdata); // poll only pad 0
MyPadGetData(pad_port, &pdata); // poll last pad port only

if(pdata.len > 0)
{
Expand Down Expand Up @@ -396,6 +396,8 @@ static uint8_t draw_side_menu(void)

draw_side_menu_option(option);

wait_for_button_release(PAD_TRIANGLE);

while(slaunch_running)
{
pad_read();
Expand All @@ -404,8 +406,8 @@ static uint8_t draw_side_menu(void)
{
if(curpad==oldpad) // key-repeat
{
if(++init_delay<=40) continue;
else { sys_timer_usleep(40000); key_repeat=1; }
if(++init_delay <= 20) continue;
sys_timer_usleep(40000); key_repeat=1;
}
else
{
Expand Down Expand Up @@ -776,7 +778,7 @@ static void stop_VSH_Menu(void)
save_config();

// prevent pass cross button to XMB
release_cross();
wait_for_button_release(PAD_CROSS);

// continue rsx rendering
rsx_fifo_pause(0);
Expand Down Expand Up @@ -945,7 +947,7 @@ static void slaunch_thread(uint64_t arg)
init_delay = 0;

// prevent set favorite with start button
while(slaunch_running) {pad_read(); if(curpad & PAD_START) sys_timer_usleep(20000); else break;}
wait_for_button_release(PAD_START);

continue;
}
Expand All @@ -964,7 +966,7 @@ static void slaunch_thread(uint64_t arg)
init_delay = 0;

// prevent set favorite with start button
while(slaunch_running) {pad_read(); if(curpad & PAD_START) sys_timer_usleep(20000); else break;}
wait_for_button_release(PAD_START);

continue;
}
Expand Down Expand Up @@ -993,6 +995,7 @@ static void slaunch_thread(uint64_t arg)
if(curpad & (PAD_SELECT | PAD_SQUARE | PAD_CIRCLE | PAD_CROSS))
{
if(fav_mode) fav_game = cur_game; else cur_game_ = cur_game;
if(!(curpad & PAD_R3)) init_delay = 1;
}

if(curpad & PAD_TRIANGLE) // open side-menu
Expand All @@ -1002,6 +1005,7 @@ static void slaunch_thread(uint64_t arg)
if(option) break;

load_data(); cur_game=_cur_game;
wait_for_button_release(PAD_TRIANGLE | PAD_CIRCLE | PAD_CROSS);
}
else if(curpad & PAD_CIRCLE) // back to XMB
{
Expand All @@ -1015,11 +1019,12 @@ static void slaunch_thread(uint64_t arg)
else if(curpad & PAD_R3 && games) {gpp^=34; draw_page(cur_game, 0); sys_timer_usleep(250000); curpad = init_delay = 0;}

else if(curpad & PAD_L3) {return_to_xmb(); send_wm_request("/refresh_ps3"); break;}
else if((curpad & PAD_SQUARE) && !fav_mode && !(curpad & PAD_L2)) {if(++gmode>=TYPE_FAV) gmode=TYPE_ALL; dmode=TYPE_ALL; reload_data(curpad); continue;}
else if((curpad & PAD_SQUARE) && !fav_mode && !(curpad & PAD_L2)) {if(++gmode>=TYPE_FAV) gmode=TYPE_ALL; dmode=TYPE_ALL; reload_data(curpad); wait_for_button_release(PAD_SQUARE); continue;}
else if((curpad & PAD_SQUARE) && !fav_mode && (curpad & PAD_L2)) {if(++dmode> DEVS_MAX) dmode=TYPE_ALL; reload_data(curpad); continue;}
else if((curpad == PAD_START) && games) // favorite game XMB
{
if(fav_mode) remove_game(); else add_game();
wait_for_button_release(PAD_START);
continue;
}
if(curpad & PAD_SELECT) // favorites menu
Expand All @@ -1029,6 +1034,7 @@ static void slaunch_thread(uint64_t arg)
play_rco_sound("snd_cursor");
fav_mode^=1; init_delay = 0;
reload_data(curpad);
wait_for_button_release(PAD_SELECT);
}
else if(curpad & PAD_R3) {return_to_xmb(); send_wm_request("/popup.ps3"); break;}
continue;
Expand Down
Binary file modified _Projects_/updater/pkgfiles/USRDIR/res/slaunch.sprx
Binary file not shown.
Binary file modified _Projects_/updater/update/dev_hdd0/tmp/wm_res/slaunch.sprx
Binary file not shown.

0 comments on commit 4ec12f2

Please sign in to comment.