diff --git a/MiSTer.sln b/MiSTer.sln index 87178b2..307739e 100644 --- a/MiSTer.sln +++ b/MiSTer.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33801.468 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MiSTer", "MiSTer.vcxproj", "{C1D6BEA2-1469-4FBC-8A27-A82BDE9041AC}" EndProject @@ -16,4 +16,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2089D6CB-559A-43F3-B74D-478279388F62} + EndGlobalSection EndGlobal diff --git a/MiSTer.vcxproj b/MiSTer.vcxproj index 12d66ac..06f0622 100644 --- a/MiSTer.vcxproj +++ b/MiSTer.vcxproj @@ -9,12 +9,13 @@ {C1D6BEA2-1469-4FBC-8A27-A82BDE9041AC} MakeFileProj + Makefile true - v141 + v143 @@ -24,13 +25,12 @@ - wsl bash -lic ./build.sh MiSTer wsl bash -lic ./clean.sh - __arm__;__GNUC__;__USE_GNU ;_GNU_SOURCE;VDATE="000000";_FILE_OFFSET_BITS=64;_LARGEFILE64_SOURCE;$(NMakePreprocessorDefinitions) - c:\Work\MiSTer\toolchain\gcc103\arm-none-linux-gnueabihf\libc\usr\include;c:\Work\MiSTer\toolchain\gcc103\lib\gcc\arm-none-linux-gnueabihf\10.3.1\include;c:\Work\MiSTer\toolchain\gcc103\arm-none-linux-gnueabihf\include\c++\10.3.1;c:\Work\MiSTer\toolchain\gcc103\arm-none-linux-gnueabihf\include\c++\10.3.1\arm-linux-gnueabihf;$(NMakeIncludeSearchPath);lib\libco;lib\miniz;lib\lodepng;lib\libchdr\include;lib\bluetooth + __arm__;__GNUC__;__USE_GNU;_GNU_SOURCE;VDATE="000000";_FILE_OFFSET_BITS=64;_LARGEFILE64_SOURCE;USE_PROTOTYPES=1;$(NMakePreprocessorDefinitions) + C:\Work\MiSTer\toolchain\gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf\arm-none-linux-gnueabihf\libc\usr\include;C:\Work\MiSTer\toolchain\gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf\lib\gcc\arm-none-linux-gnueabihf\10.3.1\include;C:\Work\MiSTer\toolchain\gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf\arm-none-linux-gnueabihf\include\c++\10.3.1;C:\Work\MiSTer\toolchain\gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf\arm-none-linux-gnueabihf\include\c++\10.3.1\arm-linux-gnueabihf;$(NMakeIncludeSearchPath);lib\libco;lib\miniz;lib\lodepng;lib\libchdr\include;lib\bluetooth $(TEMP) $(TEMP) @@ -139,6 +139,7 @@ + @@ -175,6 +176,7 @@ + diff --git a/cfg.h b/cfg.h index 054926b..e5a5b0a 100644 --- a/cfg.h +++ b/cfg.h @@ -72,7 +72,7 @@ typedef struct { char shmask_default[1023]; char preset_default[1023]; char player_controller[6][8][256]; - char controller_deadzone[8][256]; + char controller_deadzone[32][256]; uint8_t rumble; uint8_t wheel_force; uint16_t wheel_range; diff --git a/input.cpp b/input.cpp index d3ae54a..53106dc 100644 --- a/input.cpp +++ b/input.cpp @@ -2382,6 +2382,83 @@ static void restore_player(int dev) update_num_hw(dev, input[dev].num); } +// Analog joystick dead zone +static void setup_deadzone(struct input_event* ev, int dev) +{ + // Lightgun/wheel has no dead zone + if (ev->type != EV_ABS || (ev->code <= 1 && (input[dev].lightgun || input[dev].quirk == QUIRK_WHEEL))) + { + input[dev].deadzone = 0U; + } + // Dual Shock 3/4 + else if (input[dev].quirk == QUIRK_DS3 || input[dev].quirk == QUIRK_DS4) + { + printf("DETECTED MOTHER FUCKING DS3!\n"); + input[dev].deadzone = 10U; + } + // Default dead zone + else + { + input[dev].deadzone = 2U; + } + + char cfg_format[32]; + char cfg_uid[sizeof(*cfg.controller_deadzone)]; + + snprintf(cfg_format, sizeof(cfg_format), "%%%u[^ \t,]%%*[ \t,]%%u%%n", (size_t)(sizeof(cfg_uid) - 1)); + + const char* dev_uid = get_unique_mapping(dev, 1); + + for (size_t i = 0; i < sizeof(cfg.controller_deadzone) / sizeof(*cfg.controller_deadzone); i++) + { + const char* cfg_line = cfg.controller_deadzone[i]; + if (!cfg_line || !strlen(cfg_line)) break; + + uint32_t cfg_vidpid, cfg_deadzone; + size_t scan_pos; + char vp; + + if ((sscanf(cfg_line, cfg_format, cfg_uid, &cfg_deadzone, &scan_pos) < 2) || + (scan_pos != strlen(cfg_line))) continue; + + if (( + sscanf(cfg_uid, "0%*[Xx]%08x%n", &cfg_vidpid, &scan_pos) || + sscanf(cfg_uid, "%08x%n", &cfg_vidpid, &scan_pos)) && + (scan_pos == strlen(cfg_uid))) + { + const uint32_t vidpid = (input[dev].vid << 16) | input[dev].pid; + if (vidpid != cfg_vidpid) continue; + } + else if (( + (sscanf(cfg_uid, "%[VvPp]%*[Ii]%*[Dd]:0%*[Xx]%04x%n", &vp, &cfg_vidpid, &scan_pos) == 2) || + (sscanf(cfg_uid, "%[VvPp]%*[Ii]%*[Dd]:%04x%n", &vp, &cfg_vidpid, &scan_pos) == 2)) && + (scan_pos == strlen(cfg_uid))) + { + if (vp == 'V' || vp == 'v') + { + if (input[dev].vid != cfg_vidpid) continue; + } + else + { + if (input[dev].pid != cfg_vidpid) continue; + } + } + else if ( + !strcasestr(input[dev].id, cfg_uid) && + !strcasestr(input[dev].sysfs, cfg_uid) && + !strcasestr(dev_uid, cfg_uid)) + { + continue; + } + + if (cfg_deadzone > 64) cfg_deadzone = 64; + + printf("Analog device %s was given a dead zone of %u\n", input[dev].id, cfg_deadzone); + input[dev].deadzone = cfg_deadzone; + break; + } +} + void unflag_players() { for (int k = 1; k < NUMPLAYERS; k++) @@ -2654,81 +2731,6 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int map_joystick_show(input[dev].map, input[dev].mmap, input[dev].num); } } - - // Analog joystick dead zone - { - // Lightgun/wheel has no dead zone - if (ev->type != EV_ABS || (ev->code <= 1 && (input[dev].lightgun || input[dev].quirk == QUIRK_WHEEL))) - { - input[dev].deadzone = 0U; - } - // Dual Shock 3/4 - else if (input[dev].quirk == QUIRK_DS3 || input[dev].quirk == QUIRK_DS4) - { - input[dev].deadzone = 10U; - } - // Default dead zone - else - { - input[dev].deadzone = 2U; - } - - char cfg_format[32]; - char cfg_uid[sizeof(*cfg.controller_deadzone)]; - - snprintf(cfg_format, sizeof(cfg_format), "%%%u[^ \t,]%%*[ \t,]%%u%%n", (size_t)(sizeof(cfg_uid) - 1)); - - const char* dev_uid = get_unique_mapping(dev, 1); - - for (size_t i = 0; i < sizeof(cfg.controller_deadzone) / sizeof(*cfg.controller_deadzone); i++) - { - const char* cfg_line = cfg.controller_deadzone[i]; - if (!cfg_line || !strlen(cfg_line)) break; - - uint32_t cfg_vidpid, cfg_deadzone; - size_t scan_pos; - char vp; - - if ((sscanf(cfg_line, cfg_format, cfg_uid, &cfg_deadzone, &scan_pos) < 2) || - (scan_pos != strlen(cfg_line))) continue; - - if (( - sscanf(cfg_uid, "0%*[Xx]%08x%n", &cfg_vidpid, &scan_pos) || - sscanf(cfg_uid, "%08x%n", &cfg_vidpid, &scan_pos)) && - (scan_pos == strlen(cfg_uid))) - { - const uint32_t vidpid = (input[dev].vid << 16) | input[dev].pid; - if (vidpid != cfg_vidpid) continue; - } - else if (( - (sscanf(cfg_uid, "%[VvPp]%*[Ii]%*[Dd]:0%*[Xx]%04x%n", &vp, &cfg_vidpid, &scan_pos) == 2) || - (sscanf(cfg_uid, "%[VvPp]%*[Ii]%*[Dd]:%04x%n", &vp, &cfg_vidpid, &scan_pos) == 2)) && - (scan_pos == strlen(cfg_uid))) - { - if (vp == 'V' || vp == 'v') - { - if (input[dev].vid != cfg_vidpid) continue; - } - else - { - if (input[dev].pid != cfg_vidpid) continue; - } - } - else if ( - !strcasestr(input[dev].id, cfg_uid) && - !strcasestr(input[dev].sysfs, cfg_uid) && - !strcasestr(dev_uid, cfg_uid)) - { - continue; - } - - if (cfg_deadzone > 64) cfg_deadzone = 64; - - printf("Analog device %s was given a dead zone of %u\n", input[dev].id, cfg_deadzone); - input[dev].deadzone = cfg_deadzone; - break; - } - } } int old_combo = input[dev].osd_combo; @@ -4939,6 +4941,7 @@ int input_test(int getchar) { printf("opened %d(%2d): %s (%04x:%04x:%08x) %d \"%s\" \"%s\"\n", i, input[i].bind, input[i].devname, input[i].vid, input[i].pid, input[i].unique_hash, input[i].quirk, input[i].id, input[i].name); restore_player(i); + setup_deadzone(&ev, i); } unflag_players(); } diff --git a/setup_default_toolchain.sh b/setup_default_toolchain.sh index 902adb3..13554f3 100644 --- a/setup_default_toolchain.sh +++ b/setup_default_toolchain.sh @@ -9,7 +9,7 @@ fi echo "Setting up default toolchain..." SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -GCC_VER=10.2-2020.11 +GCC_VER=10.3-2021.07 GCC_PACKAGE_NAME=gcc-arm-$GCC_VER-x86_64-arm-none-linux-gnueabihf GCC_DIR=$SCRIPT_DIR/$GCC_PACKAGE_NAME @@ -26,4 +26,3 @@ export CC=$GCC_DIR/bin/arm-none-gnueabihf-gcc export PATH="$GCC_DIR/bin:$PATH" echo "Done!" - diff --git a/support/n64/n64.cpp b/support/n64/n64.cpp index 13cbe55..c77671a 100644 --- a/support/n64/n64.cpp +++ b/support/n64/n64.cpp @@ -1274,10 +1274,9 @@ int n64_rom_tx(const char *name, unsigned char idx, uint32_t load_addr) { auto save_type = get_cart_save_type(); char old_save_path[1024]; get_old_save_path(old_save_path, name); - bool do_reset = false; if (save_type != MemoryType::NONE) { - do_reset |= mount_save_file(name, save_type, old_save_path); + mount_save_file(name, save_type, old_save_path); } auto use_cpak = (bool)user_io_status_get(CPAK_OPT); @@ -1285,15 +1284,15 @@ int n64_rom_tx(const char *name, unsigned char idx, uint32_t load_addr) { // First controller can be either tpak or cpak. Tpak is prioritized. if (use_tpak || use_cpak) { - do_reset |= mount_save_file(name, + mount_save_file(name, (use_tpak ? MemoryType::TPAK : MemoryType::CPAK), old_save_path); } if (use_cpak) { - do_reset |= mount_save_file(name, MemoryType::CPAK, old_save_path); - do_reset |= mount_save_file(name, MemoryType::CPAK, old_save_path); - do_reset |= mount_save_file(name, MemoryType::CPAK, old_save_path); + mount_save_file(name, MemoryType::CPAK, old_save_path); + mount_save_file(name, MemoryType::CPAK, old_save_path); + mount_save_file(name, MemoryType::CPAK, old_save_path); } // Signal end of transmission @@ -1301,13 +1300,6 @@ int n64_rom_tx(const char *name, unsigned char idx, uint32_t load_addr) { ProgressMessage(0, 0, 0, 0); - // reset if new save files were - if (do_reset) { - user_io_status_set("[0]", 1); - usleep(100000); - user_io_status_set("[0]", 0); - } - if (!is_auto()) { return 1; }