From 860ff14d3fd5d3d4c0c958dcf73c47ccba8fca7f Mon Sep 17 00:00:00 2001 From: sorgelig Date: Thu, 8 Jul 2021 15:05:19 +0800 Subject: [PATCH] Add milti-instance no_merge_vidpid INI option. --- MiSTer.ini | 4 ++++ cfg.cpp | 12 +++++++++++- cfg.h | 1 + input.cpp | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/MiSTer.ini b/MiSTer.ini index 9f2a39c..38c8535 100644 --- a/MiSTer.ini +++ b/MiSTer.ini @@ -117,6 +117,10 @@ jamma_pid=0xF3AD ;no_merge_vid=0x045E ;no_merge_pid=0x028E +; Same as above but can add multiple devices (one entry per VIDPID). Format is VIDPID in hex number +;no_merge_vidpid=0x12345678 +;no_merge_vidpid=0x11112222 + ; Speeds in sniper/non-sniper modes of mouse emulation by joystick ; 0 - (default) - faster move in non-sniper mode, slower move in sniper mode. ; 1 - movement speeds are swapped. diff --git a/cfg.cpp b/cfg.cpp index 58dcb4c..62393d5 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -16,7 +16,7 @@ cfg_t cfg; typedef enum { - UINT8 = 0, INT8, UINT16, INT16, UINT32, INT32, FLOAT, STRING + UINT8 = 0, INT8, UINT16, INT16, UINT32, INT32, FLOAT, STRING, UINT32ARR } ini_vartypes_t; typedef struct @@ -74,6 +74,7 @@ static const ini_var_t ini_vars[] = { "SHARED_FOLDER", (void*)(&(cfg.shared_folder)), STRING, 0, sizeof(cfg.shared_folder) - 1 }, { "NO_MERGE_VID", (void*)(&(cfg.no_merge_vid)), UINT16, 0, 0xFFFF }, { "NO_MERGE_PID", (void*)(&(cfg.no_merge_pid)), UINT16, 0, 0xFFFF }, + { "NO_MERGE_VIDPID", (void*)(cfg.no_merge_vidpid), UINT32ARR, 0, (int)0xFFFFFFFF }, { "CUSTOM_ASPECT_RATIO_1", (void*)(&(cfg.custom_aspect_ratio[0])), STRING, 0, sizeof(cfg.custom_aspect_ratio[0]) - 1 }, { "CUSTOM_ASPECT_RATIO_2", (void*)(&(cfg.custom_aspect_ratio[1])), STRING, 0, sizeof(cfg.custom_aspect_ratio[1]) - 1 }, { "SPINNER_VID", (void*)(&(cfg.spinner_vid)), UINT16, 0, 0xFFFF }, @@ -231,6 +232,15 @@ static void ini_parse_var(char* buf) if (*(uint16_t*)(ini_vars[var_id].var) > ini_vars[var_id].max) *(uint16_t*)(ini_vars[var_id].var) = ini_vars[var_id].max; if (*(uint16_t*)(ini_vars[var_id].var) < ini_vars[var_id].min) *(uint16_t*)(ini_vars[var_id].var) = ini_vars[var_id].min; break; + case UINT32ARR: + { + uint32_t *arr = (uint32_t*)ini_vars[var_id].var; + uint32_t pos = ++arr[0]; + arr[pos] = strtoul(&(buf[i]), NULL, 0); + if (arr[pos] > (uint32_t)ini_vars[var_id].max) arr[pos] = (uint32_t)ini_vars[var_id].max; + if (arr[pos] < (uint32_t)ini_vars[var_id].min) arr[pos] = (uint32_t)ini_vars[var_id].min; + } + break; case INT16: *(int16_t*)(ini_vars[var_id].var) = strtol(&(buf[i]), NULL, 0); if (*(int16_t*)(ini_vars[var_id].var) > ini_vars[var_id].max) *(int16_t*)(ini_vars[var_id].var) = ini_vars[var_id].max; diff --git a/cfg.h b/cfg.h index d443d96..bbd56e9 100644 --- a/cfg.h +++ b/cfg.h @@ -44,6 +44,7 @@ typedef struct { uint16_t jamma_pid; uint16_t no_merge_vid; uint16_t no_merge_pid; + uint32_t no_merge_vidpid[256]; uint16_t spinner_vid; uint16_t spinner_pid; int spinner_throttle; diff --git a/input.cpp b/input.cpp index 88cca89..adb5361 100644 --- a/input.cpp +++ b/input.cpp @@ -2663,6 +2663,8 @@ void make_unique(uint16_t vid, uint16_t pid, int type) int lastmin = -1; int min; + printf("make_unique(%04X,%04X,%d)\n", vid, pid, type); + while(1) { int idx = -1; @@ -2767,6 +2769,8 @@ void mergedevs() make_unique(cfg.no_merge_vid, cfg.no_merge_pid, (cfg.no_merge_pid ? 1 : 0)); } + for (int i = 0; i < (int)cfg.no_merge_vidpid[0]; i++) make_unique(cfg.no_merge_vidpid[i + 1] >> 16, (uint16_t)(cfg.no_merge_vidpid[i + 1]), 1); + // merge multifunctional devices by id for (int i = 0; i < NUMDEV; i++) {