Multijoystick initial support, toggle autofire option

This commit is contained in:
Toni Wilen 2023-02-25 17:19:25 +02:00
parent 1f521d0744
commit 4adb1f4295
10 changed files with 848 additions and 526 deletions

View File

@ -198,7 +198,7 @@ static const TCHAR *autoscale_rtg[] = { _T("resize"), _T("scale"), _T("center"),
static const TCHAR *autoscalelimit[] = { _T("1/1"), _T("1/2"), _T("1/4"), _T("1/8"), 0 };
static const TCHAR *joyportmodes[] = { _T(""), _T("mouse"), _T("mousenowheel"), _T("djoy"), _T("gamepad"), _T("ajoy"), _T("cdtvjoy"), _T("cd32joy"), _T("lightpen"), 0 };
static const TCHAR *joyportsubmodes_lightpen[] = { _T(""), _T("trojan"), 0 };
static const TCHAR *joyaf[] = { _T("none"), _T("normal"), _T("toggle"), _T("always"), 0 };
static const TCHAR *joyaf[] = { _T("none"), _T("normal"), _T("toggle"), _T("always"), _T("togglebutton"), 0 };
static const TCHAR *epsonprinter[] = { _T("none"), _T("ascii"), _T("epson_matrix_9pin"), _T("epson_matrix_24pin"), _T("epson_matrix_48pin"), 0 };
static const TCHAR *aspects[] = { _T("none"), _T("vga"), _T("tv"), 0 };
static const TCHAR *vsyncmodes[] = { _T("false"), _T("true"), _T("autoswitch"), 0 };
@ -2202,7 +2202,8 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
for (i = 0; i < MAX_JPORTS; i++) {
struct jport *jp = &p->jports[i];
int v = jp->id;
struct jport_dev *jd = &jp->jd[0];
int v = jd->id;
TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
if (v == JPORT_NONE) {
_tcscpy (tmp2, _T("none"));
@ -2217,26 +2218,26 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
if (v - JSEM_MICE > 0)
_stprintf (tmp2, _T("mouse%d"), v - JSEM_MICE);
}
if (i < 2 || jp->id >= 0) {
if (i < 2 || jd->id >= 0) {
_stprintf (tmp1, _T("joyport%d"), i);
cfgfile_write (f, tmp1, tmp2);
_stprintf (tmp1, _T("joyport%dautofire"), i);
cfgfile_write_strarr(f, tmp1, joyaf, jp->autofire);
if (i < 2 && jp->mode > 0) {
cfgfile_write_strarr(f, tmp1, joyaf, jd->autofire);
if (i < 2 && jd->mode > 0) {
_stprintf (tmp1, _T("joyport%dmode"), i);
cfgfile_write_strarr(f, tmp1, joyportmodes, jp->mode);
if (jp->submode > 0 && jp->mode == 8) {
cfgfile_write_strarr(f, tmp1, joyportmodes, jd->mode);
if (jd->submode > 0 && jd->mode == 8) {
_stprintf(tmp1, _T("joyport%dsubmode"), i);
cfgfile_write_strarr(f, tmp1, joyportsubmodes_lightpen, jp->submode);
cfgfile_write_strarr(f, tmp1, joyportsubmodes_lightpen, jd->submode);
}
}
if (jp->idc.name[0]) {
if (jd->idc.name[0]) {
_stprintf (tmp1, _T("joyportfriendlyname%d"), i);
cfgfile_write (f, tmp1, jp->idc.name);
cfgfile_write (f, tmp1, jd->idc.name);
}
if (jp->idc.configname[0]) {
if (jd->idc.configname[0]) {
_stprintf (tmp1, _T("joyportname%d"), i);
cfgfile_write (f, tmp1, jp->idc.configname);
cfgfile_write (f, tmp1, jd->idc.configname);
}
if (jp->nokeyboardoverride) {
_stprintf (tmp1, _T("joyport%dkeyboardoverride"), i);
@ -2244,6 +2245,53 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
}
}
}
for (i = 0; i < MAX_JPORTS; i++) {
struct jport *jp = &p->jports[i];
for (int j = 1; j < MAX_JPORT_DEVS; j++) {
struct jport_dev *jd = &jp->jd[j];
TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
int v = jd->id;
if (v >= 0) {
tmp2[0] = 0;
if (v < JSEM_CUSTOM) {
_stprintf(tmp2, _T("kbd%d"), v + 1);
} else if (v < JSEM_JOYS) {
_stprintf(tmp2, _T("custom%d"), v - JSEM_CUSTOM);
} else if (v < JSEM_MICE) {
_stprintf(tmp2, _T("joy%d"), v - JSEM_JOYS);
} else {
_tcscpy(tmp2, _T("mouse"));
if (v - JSEM_MICE > 0)
_stprintf(tmp2, _T("mouse%d"), v - JSEM_MICE);
}
if (tmp2[0]) {
_stprintf(tmp1, _T("joyport%d_%d"), i, j);
cfgfile_write(f, tmp1, tmp2);
}
}
if (jd->autofire > 0) {
_stprintf(tmp1, _T("joyport%dautofire_%d"), i, j);
cfgfile_write_strarr(f, tmp1, joyaf, jd->autofire);
}
if (i < 2 && jd->mode > 0) {
_stprintf(tmp1, _T("joyport%dmode_%d"), i, j);
cfgfile_write_strarr(f, tmp1, joyportmodes, jd->mode);
if (jd->submode > 0 && jd->mode == 8) {
_stprintf(tmp1, _T("joyport%dsubmode_%d"), i, j);
cfgfile_write_strarr(f, tmp1, joyportsubmodes_lightpen, jd->submode);
}
}
if (jd->idc.name[0]) {
_stprintf(tmp1, _T("joyportfriendlyname%d_%d"), i, j);
cfgfile_write(f, tmp1, jd->idc.name);
}
if (jd->idc.configname[0]) {
_stprintf(tmp1, _T("joyportname%d_%d"), i, j);
cfgfile_write(f, tmp1, jd->idc.configname);
}
}
}
for (i = 0; i < MAX_JPORTS_CUSTOM; i++) {
struct jport_custom *jp = &p->jports_custom[i];
if (jp->custom[0]) {
@ -4145,58 +4193,58 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
return 1;
if (_tcscmp (option, _T("joyportfriendlyname0")) == 0 || _tcscmp (option, _T("joyportfriendlyname1")) == 0) {
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname0")) == 0 ? 0 : 1, -1, -1, 2);
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname0")) == 0 ? 0 : 1, -1, -1, 2, 0);
return 1;
}
if (_tcscmp (option, _T("joyportfriendlyname2")) == 0 || _tcscmp (option, _T("joyportfriendlyname3")) == 0) {
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname2")) == 0 ? 2 : 3, -1, -1, 2);
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname2")) == 0 ? 2 : 3, -1, -1, 2, 0);
return 1;
}
if (_tcscmp (option, _T("joyportname0")) == 0 || _tcscmp (option, _T("joyportname1")) == 0) {
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname0")) == 0 ? 0 : 1, -1, -1, 1);
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname0")) == 0 ? 0 : 1, -1, -1, 1, 0);
return 1;
}
if (_tcscmp (option, _T("joyportname2")) == 0 || _tcscmp (option, _T("joyportname3")) == 0) {
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname2")) == 0 ? 2 : 3, -1, -1, 1);
inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname2")) == 0 ? 2 : 3, -1, -1, 1, 0);
return 1;
}
if (_tcscmp (option, _T("joyport0")) == 0 || _tcscmp (option, _T("joyport1")) == 0) {
int port = _tcscmp (option, _T("joyport0")) == 0 ? 0 : 1;
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 1);
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 2);
inputdevice_joyport_config_store(p, value, port, -1, -1, 0);
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 1, 0);
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 2, 0);
inputdevice_joyport_config_store(p, value, port, -1, -1, 0, 0);
return 1;
}
if (_tcscmp (option, _T("joyport2")) == 0 || _tcscmp (option, _T("joyport3")) == 0) {
int port = _tcscmp (option, _T("joyport2")) == 0 ? 2 : 3;
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 1);
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 2);
inputdevice_joyport_config_store(p, value, port, -1, -1, 0);
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 1, 0);
inputdevice_joyport_config_store(p, _T(""), port, -1, -1, 2, 0);
inputdevice_joyport_config_store(p, value, port, -1, -1, 0, 0);
return 1;
}
if (cfgfile_strval(option, value, _T("joyport0mode"), &p->jports[0].mode, joyportmodes, 0))
if (cfgfile_strval(option, value, _T("joyport0mode"), &p->jports[0].jd[0].mode, joyportmodes, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport1mode"), &p->jports[1].mode, joyportmodes, 0))
if (cfgfile_strval(option, value, _T("joyport1mode"), &p->jports[1].jd[0].mode, joyportmodes, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport2mode"), &p->jports[2].mode, joyportmodes, 0))
if (cfgfile_strval(option, value, _T("joyport2mode"), &p->jports[2].jd[0].mode, joyportmodes, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport3mode"), &p->jports[3].mode, joyportmodes, 0))
if (cfgfile_strval(option, value, _T("joyport3mode"), &p->jports[3].jd[0].mode, joyportmodes, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport0submode"), &p->jports[0].submode, joyportsubmodes_lightpen, 0))
if (cfgfile_strval(option, value, _T("joyport0submode"), &p->jports[0].jd[0].submode, joyportsubmodes_lightpen, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport1submode"), &p->jports[1].submode, joyportsubmodes_lightpen, 0))
if (cfgfile_strval(option, value, _T("joyport1submode"), &p->jports[1].jd[0].submode, joyportsubmodes_lightpen, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport2submode"), &p->jports[2].submode, joyportsubmodes_lightpen, 0))
if (cfgfile_strval(option, value, _T("joyport2submode"), &p->jports[2].jd[0].submode, joyportsubmodes_lightpen, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport3submode"), &p->jports[3].submode, joyportsubmodes_lightpen, 0))
if (cfgfile_strval(option, value, _T("joyport3submode"), &p->jports[3].jd[0].submode, joyportsubmodes_lightpen, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport0autofire"), &p->jports[0].autofire, joyaf, 0))
if (cfgfile_strval(option, value, _T("joyport0autofire"), &p->jports[0].jd[0].autofire, joyaf, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport1autofire"), &p->jports[1].autofire, joyaf, 0))
if (cfgfile_strval(option, value, _T("joyport1autofire"), &p->jports[1].jd[0].autofire, joyaf, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport2autofire"), &p->jports[2].autofire, joyaf, 0))
if (cfgfile_strval(option, value, _T("joyport2autofire"), &p->jports[2].jd[0].autofire, joyaf, 0))
return 1;
if (cfgfile_strval(option, value, _T("joyport3autofire"), &p->jports[3].autofire, joyaf, 0))
if (cfgfile_strval(option, value, _T("joyport3autofire"), &p->jports[3].jd[0].autofire, joyaf, 0))
return 1;
if (cfgfile_yesno (option, value, _T("joyport0keyboardoverride"), &vb)) {
@ -4215,6 +4263,45 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
p->jports[3].nokeyboardoverride = !vb;
return 1;
}
if (_tcsncmp(option, _T("joyport"), 7) == 0) {
for (int i = 0; i < MAX_JPORTS; i++) {
for (int j = 1; j < MAX_JPORT_DEVS; j++) {
_stprintf(tmpbuf, _T("joyport%d_%d"), i, j);
if (!_tcscmp(option, tmpbuf)) {
inputdevice_joyport_config_store(p, _T(""), i, -1, -1, 1, j);
inputdevice_joyport_config_store(p, _T(""), i, -1, -1, 2, j);
inputdevice_joyport_config_store(p, value, i, -1, -1, 0, j);
return 1;
}
_stprintf(tmpbuf, _T("joyportfriendlyname%d_%d"), i, j);
if (!_tcscmp(option, tmpbuf)) {
inputdevice_joyport_config_store(p, value, i, -1, -1, 2, j);
return 1;
}
_stprintf(tmpbuf, _T("joyportname%d_%d"), i, j);
if (!_tcscmp(option, tmpbuf)) {
inputdevice_joyport_config_store(p, value, i, -1, -1, 1, j);
return 1;
}
_stprintf(tmpbuf, _T("joyport%dautofire_%d"), i, j);
if (!_tcscmp(option, tmpbuf)) {
cfgfile_strval(option, value, tmpbuf, &p->jports[i].jd[j].autofire, joyaf, 0);
return 1;
}
_stprintf(tmpbuf, _T("joyport%dsubmode_%d"), i, j);
if (!_tcscmp(option, tmpbuf)) {
cfgfile_strval(option, value, tmpbuf, &p->jports[i].jd[j].submode, joyportsubmodes_lightpen, 0);
return 1;
}
_stprintf(tmpbuf, _T("joyport%dmode_%d"), i, j);
if (!_tcscmp(option, tmpbuf)) {
cfgfile_strval(option, value, tmpbuf, &p->jports[i].jd[j].mode, joyportmodes, 0);
return 1;
}
}
}
return 0;
}
if (cfgfile_path(option, value, _T("trainerfile"), p->trainerfile, sizeof p->trainerfile / sizeof(TCHAR)))
return 1;
@ -6527,7 +6614,10 @@ void cfgfile_compatibility_romtype(struct uae_prefs *p)
addbcromtype(p, ROMTYPE_CDTVCR, p->cs_cdtvcr, NULL, 0);
addbcromtype(p, ROMTYPE_CD32CART, p->cs_cd32fmv, p->cartfile,0);
if (p->cs_cd32fmv) {
addbcromtype(p, ROMTYPE_CD32CART, p->cs_cd32fmv, p->cartfile, 0);
}
p->cs_cd32fmv = get_device_romconfig(p, ROMTYPE_CD32CART, 0) != NULL;
if (p->config_version < ((3 << 16) | (4 << 8) | (0 << 0))) {
// 3.3.0 or older
@ -7088,8 +7178,8 @@ end:
memcpy(&p->gfx_monitor[i], &p->gfx_monitor[0], sizeof(struct monconfig));
}
fixup_prefs (p, userconfig != 0);
for (int i = 0; i < MAX_JPORTS; i++) {
inputdevice_jportcustom_fixup(p->jports_custom[i].custom);
for (int i = 0; i < MAX_JPORTS_CUSTOM; i++) {
inputdevice_jportcustom_fixup(p, p->jports_custom[i].custom, i);
}
return v;
}
@ -7329,8 +7419,8 @@ bad:
_T("can be 0 for joystick 0, 1 for joystick 1, M for mouse, and\n")
_T("a, b or c for different keyboard settings.\n"));
p->jports[0].id = v0;
p->jports[1].id = v1;
p->jports[0].jd[0].id = v0;
p->jports[1].jd[0].id = v1;
}
static void parse_filesys_spec (struct uae_prefs *p, bool readonly, const TCHAR *spec)
@ -8176,9 +8266,33 @@ void copy_prefs(struct uae_prefs *src, struct uae_prefs *dst)
}
}
void copy_inputdevice_prefs(struct uae_prefs *src, struct uae_prefs *dst)
{
for (int slot = 0; slot < MAX_INPUT_SETTINGS; slot++) {
for (int m = 0; m < MAX_INPUT_DEVICES; m++) {
copy_inputdevice_settings_free(&src->joystick_settings[slot][m], &dst->joystick_settings[slot][m]);
copy_inputdevice_settings_free(&src->mouse_settings[slot][m], &dst->mouse_settings[slot][m]);
copy_inputdevice_settings_free(&src->keyboard_settings[slot][m], &dst->keyboard_settings[slot][m]);
}
}
for (int i = 0; i < MAX_INPUT_SETTINGS; i++) {
for (int j = 0; j < MAX_INPUT_DEVICES; j++) {
memcpy(&dst->joystick_settings[i][j], &src->joystick_settings[i][j], sizeof(struct uae_input_device));
memcpy(&dst->mouse_settings[i][j], &src->mouse_settings[i][j], sizeof(struct uae_input_device));
memcpy(&dst->keyboard_settings[i][j], &src->keyboard_settings[i][j], sizeof(struct uae_input_device));
}
}
for (int slot = 0; slot < MAX_INPUT_SETTINGS; slot++) {
for (int m = 0; m < MAX_INPUT_DEVICES; m++) {
copy_inputdevice_settings(&src->joystick_settings[slot][m], &dst->joystick_settings[slot][m]);
copy_inputdevice_settings(&src->mouse_settings[slot][m], &dst->mouse_settings[slot][m]);
copy_inputdevice_settings(&src->keyboard_settings[slot][m], &dst->keyboard_settings[slot][m]);
}
}
}
void default_prefs (struct uae_prefs *p, bool reset, int type)
{
int i;
int roms[] = { 6, 7, 8, 9, 10, 14, 5, 4, 3, 2, 1, -1 };
TCHAR zero = 0;
struct zfile *f;
@ -8214,13 +8328,14 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
clearmountitems(p);
p->jports[0].id = -1;
p->jports[1].id = -1;
p->jports[2].id = -1;
p->jports[3].id = -1;
for (int i = 0; i < MAX_JPORTS; i++) {
for (int j = 0; j < MAX_JPORT_DEVS; j++) {
p->jports[i].jd[j].id = -1;
}
}
if (reset) {
inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, -1, 0);
inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, -1, 0);
inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, -1, 0, 0);
inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, -1, 0, 0);
}
p->keyboard_lang = KBD_LANG_US;
p->keyboard_connected = true;
@ -8260,7 +8375,7 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
p->gfx_monitor[0].gfx_size_fs.height = 600;
p->gfx_monitor[0].gfx_size_win.width = 720;
p->gfx_monitor[0].gfx_size_win.height = 568;
for (i = 0; i < GFX_SIZE_EXTRA_NUM; i++) {
for (int i = 0; i < GFX_SIZE_EXTRA_NUM; i++) {
p->gfx_monitor[0].gfx_size_fs_xtra[i].width = 0;
p->gfx_monitor[0].gfx_size_fs_xtra[i].height = 0;
p->gfx_monitor[0].gfx_size_win_xtra[i].width = 0;

View File

@ -81,6 +81,8 @@ struct inputevent {
int portid;
};
#define INPUTDEVICE_ALLOWSAMEJPORT 0
#define MAX_INPUT_QUALIFIERS (8 + 5)
/* event flags */
@ -96,7 +98,7 @@ struct inputevent {
#define ID_FLAG_SET_ONOFF_VAL2 512
#define ID_FLAG_GAMEPORTSCUSTOM_MASK (ID_FLAG_GAMEPORTSCUSTOM1 | ID_FLAG_GAMEPORTSCUSTOM2)
#define ID_FLAG_AUTOFIRE_MASK (ID_FLAG_TOGGLE | ID_FLAG_INVERTTOGGLE | ID_FLAG_AUTOFIRE)
#define ID_FLAG_AUTOFIRE_MASK (ID_FLAG_TOGGLE | ID_FLAG_INVERTTOGGLE | ID_FLAG_INVERT | ID_FLAG_AUTOFIRE)
#define ID_FLAG_QUALIFIER1 0x000000100000000ULL
#define ID_FLAG_QUALIFIER1_R 0x000000200000000ULL
@ -293,12 +295,12 @@ extern void inputdevice_reset (void);
extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f);
extern void read_inputdevice_config (struct uae_prefs *p, const TCHAR *option, TCHAR *value);
extern void reset_inputdevice_config (struct uae_prefs *pr, bool reset);
extern int inputdevice_joyport_config(struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int submode, int type, bool candefault);
extern void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int submode, int type);
extern int inputdevice_joyport_config(struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int submode, int type, int subdev, bool candefault);
extern void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int submode, int type, int subdev);
extern int inputdevice_getjoyportdevice (int port, int val);
extern void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool *fixedports);
extern void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool fixedports[MAX_JPORTS][MAX_JPORT_DEVS]);
extern void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig);
extern void inputdevice_jportcustom_fixup(TCHAR*);
extern void inputdevice_jportcustom_fixup(struct uae_prefs *p, TCHAR*, int);
extern void inputdevice_init (void);
extern void inputdevice_close (void);
@ -306,7 +308,7 @@ extern void inputdevice_default_prefs (struct uae_prefs *p);
extern void inputdevice_acquire (int allmode);
extern void inputdevice_unacquire(void);
extern void inputdevice_unacquire(bool emulationactive, int inputmask);
extern void inputdevice_unacquire(int inputmask);
extern void inputdevice_releasebuttons(void);
extern void indicator_leds (int num, int state);
@ -345,17 +347,17 @@ extern void setsystime (void);
#define JSEM_JOYS 100
#define JSEM_MICE 200
#define JSEM_END 300
#define JSEM_DECODEVAL(port,p) ((p)->jports[port].id)
#define JSEM_DECODEVAL(port,sub,p) ((p)->jports[port].jd[sub].id)
#define JSEM_ISNUMPAD(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT)
#define JSEM_ISCURSOR(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT + 1)
#define JSEM_ISSOMEWHEREELSE(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT + 2)
#define JSEM_ISCUSTOM(port,p) ((p)->jports[port].id >= JSEM_CUSTOM && (p)->jports[port].id < JSEM_CUSTOM + MAX_JPORTS_CUSTOM)
#define JSEM_GETCUSTOMIDX(port,p) ((p)->jports[port].id - JSEM_CUSTOM)
#define JSEM_ISCUSTOM(port,sub,p) ((p)->jports[port].jd[sub].id >= JSEM_CUSTOM && (p)->jports[port].jd[0].id < JSEM_CUSTOM + MAX_JPORTS_CUSTOM)
#define JSEM_GETCUSTOMIDX(port,sub,p) ((p)->jports[port].jd[sub].id - JSEM_CUSTOM)
#define JSEM_LASTKBD 3
#define JSEM_ISANYKBD(port,p) (jsem_iskbdjoy(port,p) >= JSEM_KBDLAYOUT && jsem_iskbdjoy(port,p) < JSEM_KBDLAYOUT + JSEM_LASTKBD)
extern int jsem_isjoy (int port, const struct uae_prefs *p);
extern int jsem_ismouse (int port, const struct uae_prefs *p);
extern int jsem_isjoy (int port, int sub, const struct uae_prefs *p);
extern int jsem_ismouse (int port, int sub, const struct uae_prefs *p);
extern int jsem_iskbdjoy (int port, const struct uae_prefs *p);
extern int inputdevice_uaelib (const TCHAR *, const TCHAR *);

View File

@ -99,12 +99,16 @@ struct inputdevconfig {
TCHAR configname[MAX_JPORT_CONFIG];
TCHAR shortid[16];
};
struct jport {
struct jport_dev {
int id;
int mode; // 0=def,1=mouse,2=joy,3=anajoy,4=lightpen
int submode;
int autofire;
struct inputdevconfig idc;
};
#define MAX_JPORT_DEVS 10
struct jport {
struct jport_dev jd[MAX_JPORT_DEVS];
bool nokeyboardoverride;
bool changed;
};
@ -114,6 +118,7 @@ struct jport {
#define JPORT_AF_NORMAL 1
#define JPORT_AF_TOGGLE 2
#define JPORT_AF_ALWAYS 3
#define JPORT_AF_TOGGLENOAF 4
#define KBTYPE_AMIGA 0
#define KBTYPE_PC1 1
@ -984,6 +989,7 @@ extern bool is_error_log (void);
extern void default_prefs (struct uae_prefs *, bool, int);
extern void discard_prefs (struct uae_prefs *, int);
extern void copy_prefs(struct uae_prefs *src, struct uae_prefs *dst);
extern void copy_inputdevice_prefs(struct uae_prefs *src, struct uae_prefs *dst);
int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR*);

File diff suppressed because it is too large Load Diff

View File

@ -4433,8 +4433,25 @@ int input_get_default_keyboard (int i)
return 0;
}
static int nextsub(struct uae_input_device *uid, int i, int slot, int sub)
{
#if INPUTDEVICE_ALLOWSAMEJPORT
while (uid[i].eventid[slot][sub] > 0) {
sub++;
if (sub >= MAX_INPUT_SUB_EVENT_ALL) {
return -1;
}
}
#endif
return sub;
}
static void setid (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt, bool gp)
{
sub = nextsub(uid, i, slot, sub);
if (sub < 0) {
return;
}
if (gp)
inputdevice_sparecopy (&uid[i], slot, 0);
uid[i].eventid[slot][sub] = evt;
@ -4442,6 +4459,10 @@ static void setid (struct uae_input_device *uid, int i, int slot, int sub, int p
}
static void setid (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt, int af, bool gp)
{
sub = nextsub(uid, i, slot, sub);
if (sub < 0) {
return;
}
setid (uid, i, slot, sub, port, evt, gp);
uid[i].flags[slot][sub] &= ~ID_FLAG_AUTOFIRE_MASK;
if (af >= JPORT_AF_NORMAL)
@ -4450,6 +4471,8 @@ static void setid (struct uae_input_device *uid, int i, int slot, int sub, int p
uid[i].flags[slot][sub] |= ID_FLAG_TOGGLE;
if (af == JPORT_AF_ALWAYS)
uid[i].flags[slot][sub] |= ID_FLAG_INVERTTOGGLE;
if (af == JPORT_AF_TOGGLENOAF)
uid[i].flags[slot][sub] |= ID_FLAG_INVERT;
}
int input_get_default_mouse (struct uae_input_device *uid, int i, int port, int af, bool gp, bool wheel, bool joymouseswap)

View File

@ -415,6 +415,7 @@
#define IDS_GENLOCK_OPTIONS 420
#define IDS_READONLYCONFIRMATION 421
#define IDS_SCREEN_NATIVELACE 422
#define IDS_PORT_AUTOFIRE_TOGGLENOAF 423
#define IDS_QS_MODELS 1000
#define IDS_QS_MODEL_A500 1001
#define IDS_QS_MODEL_A500P 1002

View File

@ -2133,7 +2133,7 @@ BEGIN
IDS_PORT_AUTOFIRE "Autofire"
IDS_PORT_AUTOFIRE_TOGGLE "Autofire (toggle)"
IDS_PORT_AUTOFIRE_ALWAYS "Autofire (always)"
IDS_PORT_AUTOFIRE_NO "No autofire"
IDS_PORT_AUTOFIRE_NO "No autofire (normal)"
IDS_AUTOSCALE_INTEGER "Integer scaling"
IDS_SCREEN_VSYNC2_AUTOSWITCH "Lagless VS (BR), 50/60Hz"
IDS_SCREEN_VSYNC2 "Lagless VSync (Beamraced)"
@ -2187,6 +2187,7 @@ BEGIN
IDS_READONLYCONFIRMATION
"Selected configuration file is write protected.\nDo you want to overwrite it?\n%s\n"
IDS_SCREEN_NATIVELACE "Native (Interlaced)"
IDS_PORT_AUTOFIRE_TOGGLENOAF "No autofire (toggle)"
END
STRINGTABLE

View File

@ -409,7 +409,7 @@ static bool port_get_custom (int inputmap_port, TCHAR *out)
int devicetype = -1;
for (int i = 0; inputdevmode[i * 2]; i++) {
if (inputdevmode[i * 2 + 1] == currprefs.jports[inputmap_port].mode) {
if (inputdevmode[i * 2 + 1] == currprefs.jports[inputmap_port].jd[0].mode) {
devicetype = inputdevmode[i * 2 + 0];
break;
}
@ -561,7 +561,7 @@ static int port_insert (int inputmap_port, int devicetype, DWORD flags, const TC
if (inputmap_port >= 0 && inputmap_port < 4) {
dacttype[inputmap_port] = devicetype;
inputdevice_compa_clear(&changed_prefs, inputmap_port);
inputdevice_joyport_config(&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, 0, true);
inputdevice_joyport_config(&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, 0, 0, true);
return 1;
}
return 0;
@ -573,7 +573,7 @@ static int port_insert (int inputmap_port, int devicetype, DWORD flags, const TC
inputdevice_compa_clear (&changed_prefs, inputmap_port);
if (name[0] == '\0') {
inputdevice_joyport_config (&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, 0, true);
inputdevice_joyport_config (&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, 0, 0, true);
return TRUE;
}
devicetype2 = -1;
@ -595,11 +595,11 @@ static int port_insert (int inputmap_port, int devicetype, DWORD flags, const TC
_stprintf (tmp2, _T("KeyboardLayout%d"), i);
if (!_tcscmp (tmp2, name)) {
_stprintf (tmp2, _T("kbd%d"), i + 1);
ret = inputdevice_joyport_config (&changed_prefs, tmp2, NULL, inputmap_port, devicetype2, 0, 0, true);
ret = inputdevice_joyport_config (&changed_prefs, tmp2, NULL, inputmap_port, devicetype2, 0, 0, 0, true);
return ret;
}
}
ret = inputdevice_joyport_config (&changed_prefs, name, name, inputmap_port, devicetype2, 0, 1, true);
ret = inputdevice_joyport_config (&changed_prefs, name, name, inputmap_port, devicetype2, 0, 1, 0, true);
return ret;
}
@ -1855,7 +1855,7 @@ void rp_fixup_options (struct uae_prefs *p)
int parportmask = 0;
for (int i = 0; i < 2; i++) {
if (p->jports[i + 2].idc.configname[0] || p->jports[i + 2].idc.name[0] || p->jports[i + 2].idc.shortid[0])
if (p->jports[i + 2].jd[0].idc.configname[0] || p->jports[i + 2].jd[0].idc.name[0] || p->jports[i + 2].jd[0].idc.shortid[0])
parportmask |= 1 << i;
}
if (parportmask) {
@ -1935,9 +1935,9 @@ static void rp_device_change (int dev, int num, int mode, bool readonly, const T
void rp_input_change (int num)
{
int j = jsem_isjoy (num, &currprefs);
int m = jsem_ismouse (num, &currprefs);
int k = jsem_iskbdjoy (num, &currprefs);
int j = jsem_isjoy(num, 0, &currprefs);
int m = jsem_ismouse(num, 0, &currprefs);
int k = jsem_iskbdjoy(num, &currprefs);
TCHAR name[MAX_DPATH];
int mode;
@ -1945,7 +1945,7 @@ void rp_input_change (int num)
return;
name[0] = 0;
if (JSEM_ISCUSTOM(num, &currprefs)) {
if (JSEM_ISCUSTOM(num, 0, &currprefs)) {
port_get_custom (num, name);
} else if (k >= 0) {
_stprintf (name, _T("KeyboardLayout%d"), k);
@ -1956,7 +1956,7 @@ void rp_input_change (int num)
}
mode = RP_INPUTDEVICE_EMPTY;
for (int i = 0; inputdevmode[i * 2]; i++) {
if (inputdevmode[i * 2 + 1] == currprefs.jports[num].mode) {
if (inputdevmode[i * 2 + 1] == currprefs.jports[num].jd[0].mode) {
mode = inputdevmode[i * 2 + 0];
break;
}

View File

@ -4335,13 +4335,15 @@ struct remapcustoms_s
};
static struct remapcustoms_s remapcustoms[] =
{
{ 0, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
{ 0, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE | IDEV_MAPPED_INVERT,
NULL },
{ IDEV_MAPPED_AUTOFIRE_SET, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
{ IDEV_MAPPED_AUTOFIRE_SET, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE | IDEV_MAPPED_INVERT,
NULL },
{ IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
{ IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE | IDEV_MAPPED_INVERT,
NULL },
{ IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_INVERTTOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE,
{ IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_INVERTTOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE | IDEV_MAPPED_INVERT,
NULL },
{ IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_INVERT | IDEV_MAPPED_TOGGLE, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE | IDEV_MAPPED_INVERT,
NULL },
{ NULL }
};
@ -4581,6 +4583,8 @@ static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum,
_tcscat(target, remapcustoms[2].name);
else if (flags & IDEV_MAPPED_INVERTTOGGLE)
_tcscat(target, remapcustoms[3].name);
else if (flags & IDEV_MAPPED_INVERT)
_tcscat(target, remapcustoms[4].name);
else
_tcscat(target, remapcustoms[1].name);
_tcscat(target, _T("]"));
@ -17328,8 +17332,8 @@ static void updatejoyport (HWND hDlg, int changedport)
int idx = joyxprevious[i];
int id = joys[i];
int idm = joysm[i];
int v = workprefs.jports[i].id;
int vm = workprefs.jports[i].mode + workprefs.jports[i].submode;
int v = workprefs.jports[i].jd[0].id;
int vm = workprefs.jports[i].jd[0].mode + workprefs.jports[i].jd[0].submode;
TCHAR *p1, *p2;
if (idm > 0)
@ -17375,11 +17379,11 @@ static void updatejoyport (HWND hDlg, int changedport)
idx = 0;
xSendDlgItemMessage (hDlg, id, CB_SETCURSEL, idx, 0);
if (joysaf[i] >= 0)
xSendDlgItemMessage (hDlg, joysaf[i], CB_SETCURSEL, workprefs.jports[i].autofire, 0);
xSendDlgItemMessage (hDlg, joysaf[i], CB_SETCURSEL, workprefs.jports[i].jd[0].autofire, 0);
ew(hDlg, joyremap[i], idx >= 2);
ew(hDlg, joysm[i], idx >= 2);
ew(hDlg, joysaf[i], !JSEM_ISCUSTOM(i, &workprefs) && idx >= 2);
ew(hDlg, joysaf[i], !JSEM_ISCUSTOM(i, 0, &workprefs) && idx >= 2);
}
}
@ -17412,9 +17416,9 @@ static void values_from_gameportsdlg (HWND hDlg, int d, int changedport)
for (i = 0; i < MAX_JPORTS; i++) {
int idx = 0;
int *port = &workprefs.jports[i].id;
int *portm = &workprefs.jports[i].mode;
int *portsm = &workprefs.jports[i].submode;
int *port = &workprefs.jports[i].jd[0].id;
int *portm = &workprefs.jports[i].jd[0].mode;
int *portsm = &workprefs.jports[i].jd[0].submode;
int prevport = *port;
int id = joys[i];
int idm = joysm[i];
@ -17462,7 +17466,7 @@ static void values_from_gameportsdlg (HWND hDlg, int d, int changedport)
}
if (joysaf[i] >= 0) {
int af = xSendDlgItemMessage (hDlg, joysaf[i], CB_GETCURSEL, 0, 0L);
workprefs.jports[i].autofire = af;
workprefs.jports[i].jd[0].autofire = af;
}
if (*port != prevport)
changed = 1;
@ -17878,6 +17882,10 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
if (!remapcustoms[3].name)
remapcustoms[3].name = my_strdup(tmp);
xSendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
WIN32GUI_LoadUIString(IDS_PORT_AUTOFIRE_TOGGLENOAF, tmp, MAX_DPATH);
if (!remapcustoms[4].name)
remapcustoms[4].name = my_strdup(tmp);
xSendDlgItemMessage(hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
}
xSendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_RESETCONTENT, 0, 0L);
@ -18440,6 +18448,10 @@ static void showextramap (HWND hDlg)
_tcscat (out, _T(" ; "));
if (evt > 0) {
_tcscat (out, name);
const struct inputevent *ev = inputdevice_get_eventinfo(evt);
if (ev->allow_mask == AM_K) {
_stprintf(out + _tcslen(out), _T(" (0x%02x)"), ev->data);
}
if (flags & IDEV_MAPPED_AUTOFIRE_SET)
_tcscat (out, _T(" (AF)"));
if (flags & IDEV_MAPPED_TOGGLE)
@ -19074,7 +19086,7 @@ static INT_PTR CALLBACK RemapSpecialsProc(HWND hDlg, UINT msg, WPARAM wParam, LP
entry = listview_entry_from_click(list, &column, false);
if (entry >= 0 && inputmap_selected >= 0) {
if (inputmap_handle(NULL, -1, -1, NULL, NULL, -1, NULL, inputmap_selected,
remapcustoms[entry].flags, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE, NULL)) {
remapcustoms[entry].flags, IDEV_MAPPED_AUTOFIRE_SET | IDEV_MAPPED_TOGGLE | IDEV_MAPPED_INVERTTOGGLE | IDEV_MAPPED_INVERT, NULL)) {
inputdevice_generate_jport_custom(&workprefs, inputmap_port);
EndDialog(hDlg, 1);
}
@ -19140,7 +19152,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
inputdevice_updateconfig (NULL, &workprefs);
InitializeListView (hDlg);
ew(hDlg, IDC_INPUTMAP_SPECIALS, inputmap_selected >= 0);
if (!JSEM_ISCUSTOM(inputmap_port, &workprefs)) {
if (!JSEM_ISCUSTOM(inputmap_port, 0, &workprefs)) {
ew(hDlg, IDC_INPUTMAP_CAPTURE, FALSE);
ew(hDlg, IDC_INPUTMAP_DELETE, FALSE);
ew(hDlg, IDC_INPUTMAP_DELETEALL, FALSE);
@ -19168,7 +19180,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
if (lv->iItem >= 0) {
inputmap_selected = lv->iItem;
inputmap_remap_counter = getremapcounter (lv->iItem);
if (JSEM_ISCUSTOM(inputmap_port, &workprefs)) {
if (JSEM_ISCUSTOM(inputmap_port, 0, &workprefs)) {
input_find (hDlg, hDlg, 1, true, true);
}
if (inputmapselected_old < 0)
@ -19241,7 +19253,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
}
break;
case IDC_INPUTMAP_DELETE:
if (JSEM_ISCUSTOM(inputmap_port, &workprefs)) {
if (JSEM_ISCUSTOM(inputmap_port, 0, &workprefs)) {
update_listview_inputmap (hDlg, inputmap_selected);
inputdevice_generate_jport_custom(&workprefs, inputmap_port);
InitializeListView (hDlg);

View File

@ -68,8 +68,8 @@ static uae_u32 emulib_EnableSound (uae_u32 val)
*/
static uae_u32 emulib_EnableJoystick (uae_u32 val)
{
currprefs.jports[0].id = val & 255;
currprefs.jports[1].id = (val >> 8) & 255;
currprefs.jports[0].jd[0].id = val & 255;
currprefs.jports[1].jd[0].id = (val >> 8) & 255;
return 1;
}
@ -220,7 +220,7 @@ static uae_u32 emulib_GetUaeConfig(TrapContext *ctx, uaecptr place)
trap_put_long(ctx, place + 12, fastmem_bank[0].allocated_size);
trap_put_long(ctx, place + 16, currprefs.gfx_framerate);
trap_put_long(ctx, place + 20, currprefs.produce_sound);
trap_put_long(ctx, place + 24, currprefs.jports[0].id | (currprefs.jports[1].id << 8));
trap_put_long(ctx, place + 24, currprefs.jports[0].jd[0].id | (currprefs.jports[1].jd[0].id << 8));
trap_put_long(ctx, place + 28, currprefs.keyboard_lang);
if (disk_empty (0))
trap_put_byte(ctx, place + 32, 0);