Add milti-instance no_merge_vidpid INI option.

This commit is contained in:
sorgelig
2021-07-08 15:05:19 +08:00
parent 2694da70a5
commit 860ff14d3f
4 changed files with 20 additions and 1 deletions

View File

@@ -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.

12
cfg.cpp
View File

@@ -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;

1
cfg.h
View File

@@ -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;

View File

@@ -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++)
{