From 99454336cbe0f6d5c54f48db489814301da3fc96 Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sat, 19 Jan 2013 22:46:32 +0000 Subject: [PATCH] Fixed Restore key as binding key, install on usb device, case insensitive file order --- Src/Display.cpp | 9 ++++++++- Src/Prefs.cpp | 10 +++++++--- Src/Prefs.h | 3 ++- Src/gui/gui.cpp | 1 + Src/gui/gui.hh | 2 ++ Src/gui/main_menu.cpp | 6 ++++-- Src/gui/menu_messages.c | 2 +- Src/gui/options_menu.cpp | 16 ++++++++++------ Src/gui/virtual_keyboard.cpp | 13 +++++++++---- Src/main.cpp | 25 +++++++++++++++++++------ Src/utils.cpp | 2 +- 11 files changed, 64 insertions(+), 25 deletions(-) diff --git a/Src/Display.cpp b/Src/Display.cpp index 99af9a9..1784875 100644 --- a/Src/Display.cpp +++ b/Src/Display.cpp @@ -969,7 +969,14 @@ uint8 C64::poll_joystick_buttons(int port, uint8 *table, bool *has_event) bool cur = SDL_JoystickGetButton (js, i) ? true : false; int kc = ThePrefs.JoystickButtons[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) { Gui::gui->pushJoystickEvent(ev); diff --git a/Src/Prefs.cpp b/Src/Prefs.cpp index 1b812b3..40d8c2a 100644 --- a/Src/Prefs.cpp +++ b/Src/Prefs.cpp @@ -108,7 +108,7 @@ Prefs::Prefs() AlwaysCopy = false; SystemKeys = true; ShowLEDs = true; - Port = PORT_SD; + Port = PORT_DEFAULT; Rumble = false; this->SetupJoystickDefaults(); @@ -541,9 +541,10 @@ void Prefs::Load(const char *filename) else if (!strcmp(keyword, "CursorKeysForJoystick")) CursorKeysForJoystick = !strcmp(value, "TRUE"); 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 Port = PORT_SD; } + else Port = PORT_DEFAULT; } else if (!strcmp(keyword, "Rumble")) Rumble = !strcmp(value, "TRUE"); else if (!strcmp(keyword, "SmbUser")) @@ -672,6 +673,9 @@ bool Prefs::Save(const char *filename) { fprintf(file, "Port = "); switch (Port) { + case PORT_DEFAULT: + fprintf(file, "DEFAULT\n"); + break; case PORT_SD: fprintf(file, "SD\n"); break; diff --git a/Src/Prefs.h b/Src/Prefs.h index 981215b..6f7d0a0 100644 --- a/Src/Prefs.h +++ b/Src/Prefs.h @@ -96,6 +96,7 @@ enum { // Device Port enum { + PORT_DEFAULT, // Load from the device of dol file PORT_SD, // Load from SD card PORT_USB, // Load from USB port PORT_SMB //Load from network @@ -181,7 +182,7 @@ public: char Theme[128]; bool CursorKeysForJoystick; - int Port; //SD, USB or SMB + int Port; //DEFAULT, SD, USB or SMB char SmbUser[32]; char SmbPwd[32]; diff --git a/Src/gui/gui.cpp b/Src/gui/gui.cpp index 7964ada..fc25a7c 100644 --- a/Src/gui/gui.cpp +++ b/Src/gui/gui.cpp @@ -94,6 +94,7 @@ Gui::Gui() this->metadata_base_path = METADATA_ROOT_PATH; this->game_base_path = GAME_ROOT_PATH; #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_smb = GAME_ROOT_PATH_SMB; #endif diff --git a/Src/gui/gui.hh b/Src/gui/gui.hh index 575f54f..773ba46 100644 --- a/Src/gui/gui.hh +++ b/Src/gui/gui.hh @@ -17,6 +17,7 @@ #define THEME_ROOT_PATH "/frodo/themes" #define METADATA_ROOT_PATH "/frodo/metadata" #define GAME_ROOT_PATH "/frodo/images" +#define GAME_ROOT_PATH_SD "sd:/" #define GAME_ROOT_PATH_USB "usb:/" #define GAME_ROOT_PATH_SMB "smb:/" #define TMP_ROOT_PATH "/frodo/tmp" @@ -145,6 +146,7 @@ public: const char *metadata_base_path; const char *theme_base_path; const char *game_base_path; + const char *game_base_path_sd; const char *game_base_path_usb; const char *game_base_path_smb; const char *tmp_path; diff --git a/Src/gui/main_menu.cpp b/Src/gui/main_menu.cpp index 16d2914..2056c53 100644 --- a/Src/gui/main_menu.cpp +++ b/Src/gui/main_menu.cpp @@ -3,6 +3,7 @@ extern bool usbismount; extern bool smbismount; +extern bool sdismount; class KeyboardTypingListener : public KeyboardListener, TimeoutHandler { @@ -71,9 +72,10 @@ public: switch (which) { 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 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); diff --git a/Src/gui/menu_messages.c b/Src/gui/menu_messages.c index 0fbc3ed..d84be9e 100644 --- a/Src/gui/menu_messages.c +++ b/Src/gui/menu_messages.c @@ -248,7 +248,7 @@ const char *options_menu_messages[15] = { /*06*/ "Speed (approx. %)", /*07*/ "^|95|100|110", /*08*/ "Port", - /*09*/ "^|SD|USB|SMB", + /*09*/ "^|DEFAULT|SD|USB|SMB", /*10*/ "Rumble", /*11*/ "^|ON|OFF", /*12*/ " ", diff --git a/Src/gui/options_menu.cpp b/Src/gui/options_menu.cpp index 4ebf158..db221c7 100644 --- a/Src/gui/options_menu.cpp +++ b/Src/gui/options_menu.cpp @@ -68,11 +68,13 @@ public: switch (this->p_submenus[4].sel) { case 0: - Gui::gui->np->Port = PORT_SD; break; + Gui::gui->np->Port = PORT_DEFAULT; break; case 1: - Gui::gui->np->Port = PORT_USB; break; + Gui::gui->np->Port = PORT_SD; break; case 2: - Gui::gui->np->Port = PORT_SMB; break; + Gui::gui->np->Port = PORT_USB; break; + case 3: + Gui::gui->np->Port = PORT_SMB; break; default: panic("Impossible submenu value: %d\n", this->p_submenus[4].sel); } @@ -102,12 +104,14 @@ public: switch (Gui::gui->np->Port) { - case PORT_USB: + case PORT_SD: submenu_defs[4] = 1; break; + case PORT_USB: + submenu_defs[4] = 2; break; case PORT_SMB: - submenu_defs[4] = 2; break; + submenu_defs[4] = 3; break; default: - /* If it has some other value... SD */ + /* If it has some other value... DEFAULT */ submenu_defs[4] = 0; break; } diff --git a/Src/gui/virtual_keyboard.cpp b/Src/gui/virtual_keyboard.cpp index d8f4eb5..c7ccd57 100644 --- a/Src/gui/virtual_keyboard.cpp +++ b/Src/gui/virtual_keyboard.cpp @@ -65,7 +65,7 @@ static inline bool IS_INVALID_VIRTKEY(virtkey_t *k) 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("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("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"), @@ -169,6 +169,9 @@ const char *VirtualKeyboard::keycodeToString(int kc) int kc_raw = kc & ~0x80; const char *out = "Unknown"; + if (kc == MATRIX(0,0x1FF)) + return "Rstr"; + if (kc < 0) return "None"; @@ -323,9 +326,6 @@ void VirtualKeyboard::runLogic() else if (ev & KEY_SELECT) { 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) return; @@ -344,7 +344,12 @@ void VirtualKeyboard::runLogic() } else this->pushKey(key); + + //Special case for Restore + if (strcmp(key->name,"Rstr")==0) TheC64->NMI(); } + + } void VirtualKeyboard::pushKey(struct virtkey *vk) diff --git a/Src/main.cpp b/Src/main.cpp index a93bb0a..0b7ebfc 100644 --- a/Src/main.cpp +++ b/Src/main.cpp @@ -48,6 +48,7 @@ C64 *TheC64 = NULL; // Global C64 object char AppDirPath[1024]; // Path of application directory bool usbismount = false; bool smbismount = false; +bool sdismount = false; #ifndef GEKKO bool networkisinit = true; @@ -201,14 +202,26 @@ extern "C" int main(int argc, char **argv) printf("\x1b[2;0H"); //initialize libfat library - if (!fatInitDefault()) - { - printf("Couldn't initialize SD fat subsytem\n\n"); + if (fatInitDefault()) + printf("FAT subsytem initialized\n\n"); + else + { + printf("Couldn't initialize FAT subsytem\n\n"); sleep(3); exit(0); - } - else + } + + DIR *dp; + + dp = opendir ("sd:/"); + if (dp) sdismount = 1; else sdismount = 0; + + if (sdismount) printf("SD FAT subsytem initialized\n\n"); + else + printf("Couldn't initialize SD fat subsytem\n\n"); + + if (sdismount) closedir (dp); usbismount = InitUSB(); if (usbismount) @@ -218,7 +231,7 @@ extern "C" int main(int argc, char **argv) networkisinit = InitNetwork(); - sleep(3); + sleep(2); //create tmp directory if it does not exist dir_tmp = opendir("/frodo/tmp"); diff --git a/Src/utils.cpp b/Src/utils.cpp index 887deab..53078c5 100644 --- a/Src/utils.cpp +++ b/Src/utils.cpp @@ -62,7 +62,7 @@ static int cmpstringp(const void *p1, const void *p2) return -1; if (*p1_s != '[' && *p2_s == '[') 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) */