Skip to content

Commit 7291811

Browse files
committed
add SetChannel and sanity check some ops
1 parent 8254bad commit 7291811

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/main.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static void Show_About_uLE(void)
383383
#define SET_NEXT_CARD 1
384384
#define SET_PREV_CARD 2
385385
#define BUILD_SETCARD(param, type, mode, num) param = type << 24; param |= mode << 16; param |= num;
386-
386+
#define BUILD_SETCHANNEL(param, mode, num) param = mode << 16; param |= num;
387387
enum mmceman_cmds {
388388
MMCE_CMD_PING = 0x1,
389389
MMCE_CMD_GET_STATUS,
@@ -429,9 +429,10 @@ static void refresh_mmceman_data(struct cardinfo_t* CardInfo) {
429429
} else CardInfo[i].validcard = FALSE;
430430
}
431431
}
432-
432+
#define INFORM_ERR(res, cause) if (res == -1) snprintf(Notifs, MAX_TEXT_LINE, cause": %s", LNG(Failed))
433433
static void Show_MMCEManager(void)
434434
{
435+
char Notifs[MAX_TEXT_LINE] = "MMCE Manager";
435436
int event = 1, post_event = 0, curcard = 0, res, i;
436437
int hpos[2] = {2, 40};
437438
char TextRow[256];
@@ -459,17 +460,29 @@ static void Show_MMCEManager(void)
459460
} else if (new_pad & PAD_CROSS) {
460461
curcard ^= 1;
461462
event |= 2;
462-
} else if (new_pad & PAD_R1 || new_pad & PAD_R2) {
463-
u32 param;
464-
BUILD_SETCARD(param, VMC_NORMAL, (new_pad & PAD_R1) ? SET_PREV_CARD : SET_NEXT_CARD, 0)
465-
res = fileXioDevctl(mmce, MMCE_CMD_SET_CARD, &param, sizeof(param), NULL, 0);
466-
event |= 2;
467463
} else if (new_pad & PAD_SELECT) {
468464
refresh_mmceman_data(CardInfo);
469465
event |= 2;
470-
} else if (new_pad & PAD_START) {
471-
if (keyboard(TextRow, 36) > 0) {
472-
fileXioDevctl(mmce, MMCE_CMD_SET_GAMEID, TextRow, 255, NULL, 0);
466+
strcpy(Notifs, "MMCE Manager");
467+
}
468+
if (CardInfo[curcard].validcard) {
469+
if (new_pad & PAD_START) {
470+
if (keyboard(TextRow, 36) > 0) {
471+
res = fileXioDevctl(mmce, MMCE_CMD_SET_GAMEID, TextRow, 255, NULL, 0);
472+
event |= 2;
473+
INFORM_ERR(res, "SetGameID");
474+
}
475+
} else if (new_pad & PAD_R1 || new_pad & PAD_R2) {
476+
u32 param;
477+
BUILD_SETCARD(param, VMC_NORMAL, (new_pad & PAD_R1) ? SET_PREV_CARD : SET_NEXT_CARD, 0)
478+
res = fileXioDevctl(mmce, MMCE_CMD_SET_CARD, &param, sizeof(param), NULL, 0);
479+
INFORM_ERR(res, "SetCard");
480+
event |= 2;
481+
} else if (new_pad & PAD_L1 || new_pad & PAD_L2) {
482+
u32 param;
483+
BUILD_SETCHANNEL(param, (new_pad & PAD_L1) ? SET_PREV_CARD : SET_NEXT_CARD, 0)
484+
res = fileXioDevctl(mmce, MMCE_CMD_SET_CHANNEL, &param, sizeof(param), NULL, 0);
485+
INFORM_ERR(res, "SetChannel");
473486
event |= 2;
474487
}
475488
}

0 commit comments

Comments
 (0)