Fixed Restore key as binding key, install on usb device, case insensitive file order

This commit is contained in:
fabio.olimpieri 2013-01-19 22:46:32 +00:00
parent 706fc918dd
commit 99454336cb
11 changed files with 64 additions and 25 deletions

View File

@ -970,6 +970,13 @@ uint8 C64::poll_joystick_buttons(int port, uint8 *table, bool *has_event)
int kc = ThePrefs.JoystickButtons[i]; int kc = ThePrefs.JoystickButtons[i];
event_t ev = (event_t)ThePrefs.MenuJoystickButtons[i]; event_t ev = (event_t)ThePrefs.MenuJoystickButtons[i];
//Handle special Restore key, since its not actually part of the key mapping
if (kc == MATRIX(0, 0x1FF) && cur) {
NMI();
continue;
}
if (cur && ev != EVENT_NONE) if (cur && ev != EVENT_NONE)
{ {
Gui::gui->pushJoystickEvent(ev); Gui::gui->pushJoystickEvent(ev);

View File

@ -108,7 +108,7 @@ Prefs::Prefs()
AlwaysCopy = false; AlwaysCopy = false;
SystemKeys = true; SystemKeys = true;
ShowLEDs = true; ShowLEDs = true;
Port = PORT_SD; Port = PORT_DEFAULT;
Rumble = false; Rumble = false;
this->SetupJoystickDefaults(); this->SetupJoystickDefaults();
@ -541,9 +541,10 @@ void Prefs::Load(const char *filename)
else if (!strcmp(keyword, "CursorKeysForJoystick")) else if (!strcmp(keyword, "CursorKeysForJoystick"))
CursorKeysForJoystick = !strcmp(value, "TRUE"); CursorKeysForJoystick = !strcmp(value, "TRUE");
else if (!strcmp(keyword, "Port")) { else if (!strcmp(keyword, "Port")) {
if (!strcmp(value, "USB")) Port = PORT_USB; if (!strcmp(value, "SD")) Port = PORT_SD;
else if (!strcmp(value, "USB")) Port = PORT_USB;
else if (!strcmp(value, "SMB")) Port = PORT_SMB; else if (!strcmp(value, "SMB")) Port = PORT_SMB;
else Port = PORT_SD; } else Port = PORT_DEFAULT; }
else if (!strcmp(keyword, "Rumble")) else if (!strcmp(keyword, "Rumble"))
Rumble = !strcmp(value, "TRUE"); Rumble = !strcmp(value, "TRUE");
else if (!strcmp(keyword, "SmbUser")) else if (!strcmp(keyword, "SmbUser"))
@ -672,6 +673,9 @@ bool Prefs::Save(const char *filename)
{ {
fprintf(file, "Port = "); fprintf(file, "Port = ");
switch (Port) { switch (Port) {
case PORT_DEFAULT:
fprintf(file, "DEFAULT\n");
break;
case PORT_SD: case PORT_SD:
fprintf(file, "SD\n"); fprintf(file, "SD\n");
break; break;

View File

@ -96,6 +96,7 @@ enum {
// Device Port // Device Port
enum { enum {
PORT_DEFAULT, // Load from the device of dol file
PORT_SD, // Load from SD card PORT_SD, // Load from SD card
PORT_USB, // Load from USB port PORT_USB, // Load from USB port
PORT_SMB //Load from network PORT_SMB //Load from network
@ -181,7 +182,7 @@ public:
char Theme[128]; char Theme[128];
bool CursorKeysForJoystick; bool CursorKeysForJoystick;
int Port; //SD, USB or SMB int Port; //DEFAULT, SD, USB or SMB
char SmbUser[32]; char SmbUser[32];
char SmbPwd[32]; char SmbPwd[32];

View File

@ -94,6 +94,7 @@ Gui::Gui()
this->metadata_base_path = METADATA_ROOT_PATH; this->metadata_base_path = METADATA_ROOT_PATH;
this->game_base_path = GAME_ROOT_PATH; this->game_base_path = GAME_ROOT_PATH;
#if defined(GEKKO) #if defined(GEKKO)
this->game_base_path_sd = GAME_ROOT_PATH_SD;
this->game_base_path_usb = GAME_ROOT_PATH_USB; this->game_base_path_usb = GAME_ROOT_PATH_USB;
this->game_base_path_smb = GAME_ROOT_PATH_SMB; this->game_base_path_smb = GAME_ROOT_PATH_SMB;
#endif #endif

View File

@ -17,6 +17,7 @@
#define THEME_ROOT_PATH "/frodo/themes" #define THEME_ROOT_PATH "/frodo/themes"
#define METADATA_ROOT_PATH "/frodo/metadata" #define METADATA_ROOT_PATH "/frodo/metadata"
#define GAME_ROOT_PATH "/frodo/images" #define GAME_ROOT_PATH "/frodo/images"
#define GAME_ROOT_PATH_SD "sd:/"
#define GAME_ROOT_PATH_USB "usb:/" #define GAME_ROOT_PATH_USB "usb:/"
#define GAME_ROOT_PATH_SMB "smb:/" #define GAME_ROOT_PATH_SMB "smb:/"
#define TMP_ROOT_PATH "/frodo/tmp" #define TMP_ROOT_PATH "/frodo/tmp"
@ -145,6 +146,7 @@ public:
const char *metadata_base_path; const char *metadata_base_path;
const char *theme_base_path; const char *theme_base_path;
const char *game_base_path; const char *game_base_path;
const char *game_base_path_sd;
const char *game_base_path_usb; const char *game_base_path_usb;
const char *game_base_path_smb; const char *game_base_path_smb;
const char *tmp_path; const char *tmp_path;

View File

@ -3,6 +3,7 @@
extern bool usbismount; extern bool usbismount;
extern bool smbismount; extern bool smbismount;
extern bool sdismount;
class KeyboardTypingListener : public KeyboardListener, TimeoutHandler class KeyboardTypingListener : public KeyboardListener, TimeoutHandler
{ {
@ -71,9 +72,10 @@ public:
switch (which) switch (which)
{ {
case 0: /* Insert disc */ case 0: /* Insert disc */
if (Gui::gui->np->Port == PORT_USB && usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb); if (Gui::gui->np->Port == PORT_SD && sdismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_sd);
else if (Gui::gui->np->Port == PORT_USB && usbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_usb);
else if (Gui::gui->np->Port == PORT_SMB && smbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_smb); else if (Gui::gui->np->Port == PORT_SMB && smbismount) Gui::gui->dv->setDirectory(Gui::gui->game_base_path_smb);
else Gui::gui->dv->setDirectory(Gui::gui->game_base_path); else Gui::gui->dv->setDirectory(Gui::gui->game_base_path); //DEFAULT
Gui::gui->pushView(Gui::gui->dv); Gui::gui->pushView(Gui::gui->dv);

View File

@ -248,7 +248,7 @@ const char *options_menu_messages[15] = {
/*06*/ "Speed (approx. %)", /*06*/ "Speed (approx. %)",
/*07*/ "^|95|100|110", /*07*/ "^|95|100|110",
/*08*/ "Port", /*08*/ "Port",
/*09*/ "^|SD|USB|SMB", /*09*/ "^|DEFAULT|SD|USB|SMB",
/*10*/ "Rumble", /*10*/ "Rumble",
/*11*/ "^|ON|OFF", /*11*/ "^|ON|OFF",
/*12*/ " ", /*12*/ " ",

View File

@ -68,10 +68,12 @@ public:
switch (this->p_submenus[4].sel) switch (this->p_submenus[4].sel)
{ {
case 0: case 0:
Gui::gui->np->Port = PORT_SD; break; Gui::gui->np->Port = PORT_DEFAULT; break;
case 1: case 1:
Gui::gui->np->Port = PORT_USB; break; Gui::gui->np->Port = PORT_SD; break;
case 2: case 2:
Gui::gui->np->Port = PORT_USB; break;
case 3:
Gui::gui->np->Port = PORT_SMB; break; Gui::gui->np->Port = PORT_SMB; break;
default: default:
panic("Impossible submenu value: %d\n", this->p_submenus[4].sel); panic("Impossible submenu value: %d\n", this->p_submenus[4].sel);
@ -102,12 +104,14 @@ public:
switch (Gui::gui->np->Port) switch (Gui::gui->np->Port)
{ {
case PORT_USB: case PORT_SD:
submenu_defs[4] = 1; break; submenu_defs[4] = 1; break;
case PORT_USB:
submenu_defs[4] = 2; break;
case PORT_SMB: case PORT_SMB:
submenu_defs[4] = 2; break; submenu_defs[4] = 3; break;
default: default:
/* If it has some other value... SD */ /* If it has some other value... DEFAULT */
submenu_defs[4] = 0; break; submenu_defs[4] = 0; break;
} }

View File

@ -65,7 +65,7 @@ static inline bool IS_INVALID_VIRTKEY(virtkey_t *k)
static virtkey_t keys[KEY_COLS * KEY_ROWS] = { static virtkey_t keys[KEY_COLS * KEY_ROWS] = {
K("<-",7,1), K("1", 7,0), K("2", 7,3), K("3", 1,0), K("4", 1,3), K("5", 2,0), K("6", 2,3), K("7", 3,0), K("8", 3,3), K("9", 4,0), K("0", 4,3), K("+", 5,0), K("-", 5,3), K("£", 6,0), K("Hom", 6,3), K("<-",7,1), K("1", 7,0), K("2", 7,3), K("3", 1,0), K("4", 1,3), K("5", 2,0), K("6", 2,3), K("7", 3,0), K("8", 3,3), K("9", 4,0), K("0", 4,3), K("+", 5,0), K("-", 5,3), K("£", 6,0), K("Hom", 6,3),
K("Cr", 7,2), K("Q", 7,6), K("W", 1,1), K("E", 1,6), K("R", 2,1), K("T", 2,6), K("Y", 3,1), K("U", 3,6), K("I", 4,1), K("O", 4,6), K("P", 5,1), K("@", 5,6), K("*", 6,1), K("Au", 6,6),K("Rstr",4,0), K("Cr", 7,2), K("Q", 7,6), K("W", 1,1), K("E", 1,6), K("R", 2,1), K("T", 2,6), K("Y", 3,1), K("U", 3,6), K("I", 4,1), K("O", 4,6), K("P", 5,1), K("@", 5,6), K("*", 6,1), K("Au", 6,6),K("Rstr",0,0x1FF),
K("R/Stp", 7,7), K(NULL,0,0), K("A", 1,2), K("S", 1,5), K("D", 2,2), K("F", 2,5), K("G", 3,2), K("H", 3,5), K("J", 4,2), K("K", 4,5), K("L", 5,2), K(":", 5,5), K(";", 6,2), K("=", 6,5), K("Ret", 0,1), K("R/Stp", 7,7), K(NULL,0,0), K("A", 1,2), K("S", 1,5), K("D", 2,2), K("F", 2,5), K("G", 3,2), K("H", 3,5), K("J", 4,2), K("K", 4,5), K("L", 5,2), K(":", 5,5), K(";", 6,2), K("=", 6,5), K("Ret", 0,1),
K("C=", 7,5), S("Shft",1,7),K(NULL,0,0),K("Z", 1,4), K("X", 2,7), K("C", 2,4), K("V", 3,7), K("B", 3,4), K("N", 4,7), K("M", 4,4), K(",", 5,7), K(".", 5,4), K("/", 6,7), K("Dwn",0,7),K("Rgt", 0,2), K("C=", 7,5), S("Shft",1,7),K(NULL,0,0),K("Z", 1,4), K("X", 2,7), K("C", 2,4), K("V", 3,7), K("B", 3,4), K("N", 4,7), K("M", 4,4), K(",", 5,7), K(".", 5,4), K("/", 6,7), K("Dwn",0,7),K("Rgt", 0,2),
N("None"), K(NULL,0,0), K(NULL,0,0), K("space", 7,4),K(0, 0,0),K(NULL,0,0), K("f1",0,4), K("f3",0,5), K("f5",0,6), K("f7",0,3), K("Del",0,0),K(NULL,0,0), K(NULL,0,0), K(NULL,0,0), D("DONE"), N("None"), K(NULL,0,0), K(NULL,0,0), K("space", 7,4),K(0, 0,0),K(NULL,0,0), K("f1",0,4), K("f3",0,5), K("f5",0,6), K("f7",0,3), K("Del",0,0),K(NULL,0,0), K(NULL,0,0), K(NULL,0,0), D("DONE"),
@ -169,6 +169,9 @@ const char *VirtualKeyboard::keycodeToString(int kc)
int kc_raw = kc & ~0x80; int kc_raw = kc & ~0x80;
const char *out = "Unknown"; const char *out = "Unknown";
if (kc == MATRIX(0,0x1FF))
return "Rstr";
if (kc < 0) if (kc < 0)
return "None"; return "None";
@ -324,9 +327,6 @@ void VirtualKeyboard::runLogic()
{ {
virtkey_t *key = &keys[ this->sel_y * KEY_COLS + this->sel_x ]; virtkey_t *key = &keys[ this->sel_y * KEY_COLS + this->sel_x ];
//Special case for Restore
if (strcmp(key->name,"Rstr")==0) {TheC64->NMI();return;}
if (!key) if (!key)
return; return;
@ -344,7 +344,12 @@ void VirtualKeyboard::runLogic()
} }
else else
this->pushKey(key); this->pushKey(key);
//Special case for Restore
if (strcmp(key->name,"Rstr")==0) TheC64->NMI();
} }
} }
void VirtualKeyboard::pushKey(struct virtkey *vk) void VirtualKeyboard::pushKey(struct virtkey *vk)

View File

@ -48,6 +48,7 @@ C64 *TheC64 = NULL; // Global C64 object
char AppDirPath[1024]; // Path of application directory char AppDirPath[1024]; // Path of application directory
bool usbismount = false; bool usbismount = false;
bool smbismount = false; bool smbismount = false;
bool sdismount = false;
#ifndef GEKKO #ifndef GEKKO
bool networkisinit = true; bool networkisinit = true;
@ -201,14 +202,26 @@ extern "C" int main(int argc, char **argv)
printf("\x1b[2;0H"); printf("\x1b[2;0H");
//initialize libfat library //initialize libfat library
if (!fatInitDefault()) if (fatInitDefault())
{ printf("FAT subsytem initialized\n\n");
printf("Couldn't initialize SD fat subsytem\n\n"); else
{
printf("Couldn't initialize FAT subsytem\n\n");
sleep(3); sleep(3);
exit(0); exit(0);
} }
else
DIR *dp;
dp = opendir ("sd:/");
if (dp) sdismount = 1; else sdismount = 0;
if (sdismount)
printf("SD FAT subsytem initialized\n\n"); printf("SD FAT subsytem initialized\n\n");
else
printf("Couldn't initialize SD fat subsytem\n\n");
if (sdismount) closedir (dp);
usbismount = InitUSB(); usbismount = InitUSB();
if (usbismount) if (usbismount)
@ -218,7 +231,7 @@ extern "C" int main(int argc, char **argv)
networkisinit = InitNetwork(); networkisinit = InitNetwork();
sleep(3); sleep(2);
//create tmp directory if it does not exist //create tmp directory if it does not exist
dir_tmp = opendir("/frodo/tmp"); dir_tmp = opendir("/frodo/tmp");

View File

@ -62,7 +62,7 @@ static int cmpstringp(const void *p1, const void *p2)
return -1; return -1;
if (*p1_s != '[' && *p2_s == '[') if (*p1_s != '[' && *p2_s == '[')
return 1; return 1;
return strcmp(* (char * const *) p1, * (char * const *) p2); return strcasecmp(* (char * const *) p1, * (char * const *) p2);
} }
/* Return true if name ends with ext (for filenames) */ /* Return true if name ends with ext (for filenames) */