]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Game ports input preset sub config support. Trojan light gun preset added.
authorToni Wilen <twilen@winuae.net>
Sat, 9 Nov 2019 17:33:39 +0000 (19:33 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 9 Nov 2019 17:33:39 +0000 (19:33 +0200)
cfgfile.cpp
include/inputdevice.h
include/options.h
inputdevice.cpp
od-win32/dinput.cpp
od-win32/resources/winuae.rc
od-win32/rp.cpp
od-win32/win32gui.cpp

index c76a2717b48d661be3739be8bbac0ef7c9e98bf1..a6d4ab2bd66fe61c4d0251852106982df1a17650 100644 (file)
@@ -197,6 +197,7 @@ static const TCHAR *autoscale[] = { _T("none"), _T("auto"), _T("standard"), _T("
 static const TCHAR *autoscale_rtg[] = { _T("resize"), _T("scale"), _T("center"), _T("integer"), 0 };
 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 *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 };
@@ -2015,6 +2016,10 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
                        if (i < 2 && jp->mode > 0) {
                                _stprintf (tmp1, _T("joyport%dmode"), i);
                                cfgfile_write (f, tmp1, joyportmodes[jp->mode]);
+                               if (jp->submode > 0 && jp->mode == 8) {
+                                       _stprintf(tmp1, _T("joyport%dsubmode"), i);
+                                       cfgfile_write(f, tmp1, joyportsubmodes_lightpen[jp->submode]);
+                               }
                        }
                        if (jp->idc.name[0]) {
                                _stprintf (tmp1, _T("joyportfriendlyname%d"), i);
@@ -3799,50 +3804,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, 2);
+               inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname0")) == 0 ? 0 : 1, -1, -1, 2);
                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, 2);
+               inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname2")) == 0 ? 2 : 3, -1, -1, 2);
                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);
+               inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname0")) == 0 ? 0 : 1, -1, -1, 1);
                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);
+               inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname2")) == 0 ? 2 : 3, -1, -1, 1);
                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);
-               inputdevice_joyport_config_store(p, _T(""), port, -1, 2);
-               inputdevice_joyport_config_store(p, value, port, -1, 0);
+               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);
                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);
-               inputdevice_joyport_config_store(p, _T(""), port, -1, 2);
-               inputdevice_joyport_config_store(p, value, port, -1, 0);
+               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);
                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].mode, joyportmodes, 0))
+               return 1;
+       if (cfgfile_strval(option, value, _T("joyport1mode"), &p->jports[1].mode, joyportmodes, 0))
+               return 1;
+       if (cfgfile_strval(option, value, _T("joyport2mode"), &p->jports[2].mode, joyportmodes, 0))
+               return 1;
+       if (cfgfile_strval(option, value, _T("joyport3mode"), &p->jports[3].mode, joyportmodes, 0))
+               return 1;
+       if (cfgfile_strval(option, value, _T("joyport0submode"), &p->jports[0].submode, joyportsubmodes_lightpen, 0))
                return 1;
-       if (cfgfile_strval (option, value, _T("joyport1mode"), &p->jports[1].mode, joyportmodes, 0))
+       if (cfgfile_strval(option, value, _T("joyport1submode"), &p->jports[1].submode, joyportsubmodes_lightpen, 0))
                return 1;
-       if (cfgfile_strval (option, value, _T("joyport2mode"), &p->jports[2].mode, joyportmodes, 0))
+       if (cfgfile_strval(option, value, _T("joyport2submode"), &p->jports[2].submode, joyportsubmodes_lightpen, 0))
                return 1;
-       if (cfgfile_strval (option, value, _T("joyport3mode"), &p->jports[3].mode, joyportmodes, 0))
+       if (cfgfile_strval(option, value, _T("joyport3submode"), &p->jports[3].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].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].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].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].autofire, joyaf, 0))
                return 1;
 
        if (cfgfile_yesno (option, value, _T("joyport0keyboardoverride"), &vb)) {
@@ -7697,8 +7710,8 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
        p->jports[2].id = -1;
        p->jports[3].id = -1;
        if (reset) {
-               inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, 0);
-               inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, 0);
+               inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, -1, 0);
+               inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, -1, 0);
        }
        p->keyboard_lang = KBD_LANG_US;
        p->keyboard_connected = true;
index 81f257a65b2997fd5156bee1dfbbc5485c8c93b8..21a0031ea93ac9e5d63e4bf70bc7d126fe43acf8 100644 (file)
@@ -203,7 +203,7 @@ extern int inputdevice_get_widget_type (int devnum, int num, TCHAR *name, bool i
 extern int send_input_event (int nr, int state, int max, int autofire);
 
 extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp, bool wheel, bool joymouseswap);
-extern int input_get_default_lightpen (struct uae_input_device *uid, int num, int port, int af, bool gp, bool joymouseswap);
+extern int input_get_default_lightpen (struct uae_input_device *uid, int num, int port, int af, bool gp, bool joymouseswap, int submode);
 extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int af, int mode, bool gp, bool joymouseswap);
 extern int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port, int af, bool gp, bool joymouseswap);
 extern int input_get_default_keyboard (int num);
@@ -292,8 +292,8 @@ 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 type, bool candefault);
-extern void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, 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, 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_getjoyportdevice (int port, int val);
 extern void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool *fixedports);
 extern void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig);
index 288e8372c45f9da2dd795d7df37e9bbc9754b54c..e2e25087603a08975d29473655ff60fb8c15c98e 100644 (file)
@@ -102,6 +102,7 @@ struct inputdevconfig {
 struct jport {
        int id;
        int mode; // 0=def,1=mouse,2=joy,3=anajoy,4=lightpen
+       int submode;
        int autofire;
        struct inputdevconfig idc;
        bool nokeyboardoverride;
index d3911f4b7ef67aa85c3dcc224a39742011de0553..994c1a5cb1d019b248afce11f56dd9aebd1f60d1 100644 (file)
@@ -141,7 +141,7 @@ static uae_s16 *qualifiers_evt[MAX_INPUT_QUALIFIERS];
 // fire/left mouse button pullup resistors enabled?
 static bool mouse_pullup = true;
 
-static int joymodes[MAX_JPORTS];
+static int joymodes[MAX_JPORTS], joysubmodes[MAX_JPORTS];
 static const int *joyinputs[MAX_JPORTS];
 
 static int input_acquired;
@@ -473,6 +473,7 @@ static void copyjport (const struct uae_prefs *src, struct uae_prefs *dst, int n
        memcpy(&dst->jports[num].idc, &src->jports[num].idc, sizeof(struct inputdevconfig));
        dst->jports[num].id = src->jports[num].id;
        dst->jports[num].mode = src->jports[num].mode;
+       dst->jports[num].submode = src->jports[num].submode;
        dst->jports[num].autofire = src->jports[num].autofire;
        dst->jports[num].nokeyboardoverride = src->jports[num].nokeyboardoverride;
 }
@@ -636,6 +637,7 @@ static void inputdevice_store_unplugged_port(struct uae_prefs *p, struct inputde
                if (!_tcscmp(jp->idc.name, idc->name) && !_tcscmp(jp->idc.configname, idc->configname)) {
                        write_log(_T("On the fly unplugged stored, port %d '%s' (%s)\n"), i, jpt.idc.name, jpt.idc.configname);
                        jpt.mode = jp->mode;
+                       jpt.submode = jp->submode;
                        jpt.autofire = jp->autofire;
                        inputdevice_store_used_device(&jpt, i, false);
                }
@@ -5107,6 +5109,7 @@ static void inputdevice_checkconfig (void)
        for (int i = 0; i < MAX_JPORTS; i++) {
                if (currprefs.jports[i].id != changed_prefs.jports[i].id ||
                        currprefs.jports[i].mode != changed_prefs.jports[i].mode ||
+                       currprefs.jports[i].submode != changed_prefs.jports[i].submode ||
                        _tcscmp(currprefs.jports_custom[i].custom, changed_prefs.jports_custom[i].custom))
                                changed = true;
        }
@@ -5402,9 +5405,9 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode)
                        if (newslot >= 0) {
                                TCHAR cust[100];
                                _stprintf(cust, _T("custom%d"), newslot);
-                               inputdevice_joyport_config(&changed_prefs, cust, cust, newport, -1, 0, true);
+                               inputdevice_joyport_config(&changed_prefs, cust, cust, newport, -1, -1, 0, true);
                        } else {
-                               inputdevice_joyport_config (&changed_prefs, name, name, newport, -1, 1, true);
+                               inputdevice_joyport_config(&changed_prefs, name, name, newport, -1, -1, 1, true);
                        }
                        inputdevice_validate_jports (&changed_prefs, -1, NULL);
                        inputdevice_copyconfig (&changed_prefs, &currprefs);
@@ -6198,6 +6201,15 @@ static const int ip_arcadia[] = {
        INPUTEVENT_SPC_ARCADIA_COIN1, INPUTEVENT_SPC_ARCADIA_COIN2,
        -1
 };
+static const int ip_analog1[] = {
+       INPUTEVENT_JOY1_HORIZ_POT, INPUTEVENT_JOY1_VERT_POT, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT,
+       -1
+};
+static const int ip_analog2[] = {
+       INPUTEVENT_JOY2_HORIZ_POT, INPUTEVENT_JOY2_VERT_POT, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT,
+       -1
+};
+
 static const int ip_lightpen1[] = {
        INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY1_3RD_BUTTON,
        -1
@@ -6206,15 +6218,16 @@ static const int ip_lightpen2[] = {
        INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY2_3RD_BUTTON,
        -1
 };
-static const int ip_analog1[] = {
-       INPUTEVENT_JOY1_HORIZ_POT, INPUTEVENT_JOY1_VERT_POT, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT,
+static const int ip_lightpen1_trojan[] = {
+       INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY1_LEFT,
        -1
 };
-static const int ip_analog2[] = {
-       INPUTEVENT_JOY2_HORIZ_POT, INPUTEVENT_JOY2_VERT_POT, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT,
+static const int ip_lightpen2_trojan[] = {
+       INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY2_LEFT,
        -1
 };
 
+
 static const int ip_arcadiaxa[] = {
        -1
 };
@@ -6621,6 +6634,17 @@ static void setjoydevices (struct uae_prefs *prefs, bool gameportsmode, int port
        }
 }
 
+static const int *getlightpen(int port, int submode)
+{
+       switch (submode)
+       {
+       case 1:
+               return port ? ip_lightpen2_trojan : ip_lightpen1_trojan;
+       default:
+               return port ? ip_lightpen2 : ip_lightpen1;
+       }
+}
+
 static void setjoyinputs (struct uae_prefs *prefs, int port)
 {
        joyinputs[port] = NULL;
@@ -6646,7 +6670,8 @@ static void setjoyinputs (struct uae_prefs *prefs, int port)
                        joyinputs[port] = port ? ip_mouse2 : ip_mouse1;
                break;
                case JSEM_MODE_LIGHTPEN:
-                       joyinputs[port] = port ? ip_lightpen2 : ip_lightpen1;
+                       joyinputs[port] = getlightpen(port, joysubmodes[port]);
+               break;
                break;
                case JSEM_MODE_MOUSE_CDTV:
                        joyinputs[port] = ip_mousecdtv;
@@ -6699,6 +6724,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
 
        for (i = 0; i < MAX_JPORTS; i++) {
                joymodes[i] = prefs->jports[i].mode;
+               joysubmodes[i] = prefs->jports[i].submode;
                joyinputs[i] = NULL;
                // remove all mappings from this port
                if (gameports)
@@ -6722,7 +6748,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
                                        break;
                                        case JSEM_MODE_LIGHTPEN:
                                        joymodes[i] = JSEM_MODE_LIGHTPEN;
-                                       joyinputs[i] = i ? ip_lightpen2 : ip_lightpen1;
+                                       joyinputs[i] = getlightpen(i, joysubmodes[i]);
                                        break;
                                        case JSEM_MODE_MOUSE_CDTV:
                                        joymodes[i] = JSEM_MODE_MOUSE_CDTV;
@@ -6762,7 +6788,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
                                                break;
                                        case JSEM_MODE_LIGHTPEN:
                                                joymodes[i] = JSEM_MODE_LIGHTPEN;
-                                               joyinputs[i] = i ? ip_lightpen2 : ip_lightpen1;
+                                               joyinputs[i] = getlightpen(i, joysubmodes[i]);
                                                break;
                                        case JSEM_MODE_MOUSE_CDTV:
                                                joymodes[i] = JSEM_MODE_MOUSE_CDTV;
@@ -6792,6 +6818,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
                int af = prefs->jports[i].autofire;
                if (prefs->jports[i].id >= 0) {
                        int mode = prefs->jports[i].mode;
+                       int submode = prefs->jports[i].submode;
                        if ((joy = jsem_ismouse (i, prefs)) >= 0) {
                                if (gameports)
                                        cleardev (mice, joy);
@@ -6805,7 +6832,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
                                        joymodes[i] = JSEM_MODE_WHEELMOUSE;
                                        break;
                                case JSEM_MODE_LIGHTPEN:
-                                       input_get_default_lightpen (mice, joy, i, af, !gameports, false);
+                                       input_get_default_lightpen (mice, joy, i, af, !gameports, false, submode);
                                        joymodes[i] = JSEM_MODE_LIGHTPEN;
                                        break;
                                case JSEM_MODE_JOYSTICK:
@@ -6831,6 +6858,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
                int af = prefs->jports[i].autofire;
                if (prefs->jports[i].id >= 0) {
                        int mode = prefs->jports[i].mode;
+                       int submode = prefs->jports[i].submode;
                        joy = jsem_isjoy (i, prefs);
                        if (joy >= 0) {
                                if (gameports)
@@ -6863,7 +6891,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
                                        joymodes[i] = JSEM_MODE_WHEELMOUSE;
                                        break;
                                case JSEM_MODE_LIGHTPEN:
-                                       input_get_default_lightpen (joysticks, joy, i, af, !gameports, true);
+                                       input_get_default_lightpen (joysticks, joy, i, af, !gameports, true, submode);
                                        joymodes[i] = JSEM_MODE_LIGHTPEN;
                                        break;
                                case JSEM_MODE_MOUSE_CDTV:
@@ -7347,6 +7375,7 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
        TCHAR *jports_configname[MAX_JPORTS];
        int jportskb[MAX_JPORTS], jportscustom[MAX_JPORTS];
        int jportsmode[MAX_JPORTS];
+       int jportssubmode[MAX_JPORTS];
        int jportid[MAX_JPORTS], jportaf[MAX_JPORTS];
        bool changed = false;
 
@@ -7374,6 +7403,7 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
                        jportskb[i] = idx;
                }
                jportsmode[i] = prefs->jports[i].mode;
+               jportssubmode[i] = prefs->jports[i].submode;
                if (jports_name[i] == NULL)
                        jports_name[i] = my_strdup(prefs->jports[i].idc.name);
                if (jports_configname[i] == NULL)
@@ -7453,6 +7483,7 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
                                        jports_configname[portnum] = my_strdup(idc.configname);
                                        jportaf[portnum] = sjp->jp.autofire;
                                        jportsmode[portnum] = sjp->jp.mode;
+                                       jportssubmode[portnum] = sjp->jp.submode;
                                } else {
                                        write_log(_T("Not inserted to any port\n"));
                                }
@@ -7471,18 +7502,18 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
                if (jportscustom[i] >= 0) {
                        TCHAR tmp[10];
                        _stprintf(tmp, _T("custom%d"), jportscustom[i]);
-                       found = inputdevice_joyport_config(prefs, tmp, NULL, i, jportsmode[i], 0, true) != 0;
+                       found = inputdevice_joyport_config(prefs, tmp, NULL, i, jportsmode[i], jportssubmode[i], 0, true) != 0;
                } else if ((jports_name[i] && jports_name[i][0]) || (jports_configname[i] && jports_configname[i][0])) {
-                       if (!inputdevice_joyport_config (prefs, jports_name[i], jports_configname[i], i, jportsmode[i], 1, true)) {
-                               found = inputdevice_joyport_config (prefs, jports_name[i], NULL, i, jportsmode[i], 1, true) != 0;
+                       if (!inputdevice_joyport_config (prefs, jports_name[i], jports_configname[i], i, jportsmode[i], jportssubmode[i], 1, true)) {
+                               found = inputdevice_joyport_config (prefs, jports_name[i], NULL, i, jportsmode[i], jportssubmode[i], 1, true) != 0;
                        }
                        if (!found) {
-                               inputdevice_joyport_config(prefs, _T("joydefault"), NULL, i, jportsmode[i], 0, true);
+                               inputdevice_joyport_config(prefs, _T("joydefault"), NULL, i, jportsmode[i], jportssubmode[i], 0, true);
                        }
                } else if (jportskb[i] >= 0) {
                        TCHAR tmp[10];
                        _stprintf (tmp, _T("kbd%d"), jportskb[i] + 1);
-                       found = inputdevice_joyport_config (prefs, tmp, NULL, i, jportsmode[i], 0, true) != 0;
+                       found = inputdevice_joyport_config (prefs, tmp, NULL, i, jportsmode[i], jportssubmode[i], 0, true) != 0;
                        
                }
                fixedports[i] = found;
@@ -9121,9 +9152,9 @@ static void inputdevice_get_previous_joy(struct uae_prefs *p, int portnum, bool
                if (!jp)
                        break;
                if (jp->idc.configname[0]) {
-                       found = inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, portnum, jp->mode, 1, true) != 0;
+                       found = inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, portnum, jp->mode, jp->submode, 1, true) != 0;
                        if (!found && jp->id == JPORT_UNPLUGGED)
-                               found = inputdevice_joyport_config(p, jp->idc.name, NULL, portnum, jp->mode, 1, true) != 0;
+                               found = inputdevice_joyport_config(p, jp->idc.name, NULL, portnum, jp->mode, jp->submode, 1, true) != 0;
                } else if (jp->id < JSEM_JOYS && jp->id >= 0) {
                        jpx->id = jp->id;
                        found = true;
@@ -9208,7 +9239,7 @@ void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool *fi
        }
 }
 
-void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type)
+void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int submode, int type)
 {
        struct jport *jp = &p->jports[portnum];
        if (type == 2) {
@@ -9218,12 +9249,14 @@ void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, i
        } else {
                _tcscpy(jp->idc.shortid, value);
        }
-       if (mode >= 0)
+       if (mode >= 0) {
                jp->mode = mode;
+               jp->submode = submode;
+       }
        jp->changed = true;
 }
 
-int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int type, bool candefault)
+int inputdevice_joyport_config(struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int submode, int type, bool candefault)
 {
        switch (type)
        {
@@ -9286,8 +9319,10 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value1, const
                                                if (value2)
                                                        _tcscpy(p->jports[portnum].idc.configname, value2);
                                                p->jports[portnum].id = idnum + matched;
-                                               if (mode >= 0)
+                                               if (mode >= 0) {
                                                        p->jports[portnum].mode = mode;
+                                                       p->jports[portnum].submode = submode;
+                                               }
                                                set_config_changed ();
                                        }
                                        return 1;
@@ -9355,8 +9390,10 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value1, const
                                }
                                if (got >= 2) {
                                        p->jports[portnum].id = start;
-                                       if (mode >= 0)
+                                       if (mode >= 0) {
                                                p->jports[portnum].mode = mode;
+                                               p->jports[portnum].submode = submode;
+                                       }
                                        if (start < JSEM_JOYS)
                                                default_keyboard_layout[portnum] = start + 1;
                                        if (got == 2 && candefault) {
@@ -9434,7 +9471,7 @@ void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
                if (!_tcscmp(jpc->custom, _T("#"))) {
                        TCHAR tmp[16];
                        _stprintf(tmp, _T("custom%d"), i);
-                       inputdevice_joyport_config(p, tmp, NULL, i, -1, 0, userconfig);
+                       inputdevice_joyport_config(p, tmp, NULL, i, -1, -1, 0, userconfig);
                        inputdevice_generate_jport_custom(p, i);
                }
        }
@@ -9444,7 +9481,7 @@ void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
                struct jport *jp = &jport_config_store[i];
                matched[i] = false;
                if (jp->idc.configname[0] && jp->idc.name[0] && (p->input_device_match_mask & INPUT_MATCH_BOTH)) {
-                       if (inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, i, jp->mode, 1, userconfig)) {
+                       if (inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, i, jp->mode, jp->submode, 1, userconfig)) {
                                inputdevice_validate_jports(p, i, matched);
                                inputdevice_store_used_device(&p->jports[i], i, defaultports);
                                matched[i] = true;
@@ -9457,7 +9494,7 @@ void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
                if (!matched[i]) {
                        struct jport *jp = &jport_config_store[i];
                        if (jp->idc.configname[0] && (p->input_device_match_mask & INPUT_MATCH_CONFIG_NAME_ONLY)) {
-                               if (inputdevice_joyport_config(p, NULL, jp->idc.configname, i, jp->mode, 1, userconfig)) {
+                               if (inputdevice_joyport_config(p, NULL, jp->idc.configname, i, jp->mode, jp->submode, 1, userconfig)) {
                                        inputdevice_validate_jports(p, i, matched);
                                        inputdevice_store_used_device(&p->jports[i], i, defaultports);
                                        matched[i] = true;
@@ -9471,7 +9508,7 @@ void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
                if (!matched[i]) {
                        struct jport *jp = &jport_config_store[i];
                        if (jp->idc.name[0] && (p->input_device_match_mask & INPUT_MATCH_FRIENDLY_NAME_ONLY)) {
-                               if (inputdevice_joyport_config(p, jp->idc.name, NULL, i, jp->mode, 1, userconfig)) {
+                               if (inputdevice_joyport_config(p, jp->idc.name, NULL, i, jp->mode, jp->submode, 1, userconfig)) {
                                        inputdevice_validate_jports(p, i, matched);
                                        inputdevice_store_used_device(&p->jports[i], i, defaultports);
                                        matched[i] = true;
@@ -9485,7 +9522,7 @@ void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
                if (!matched[i]) {
                        struct jport *jp = &jport_config_store[i];
                        if (jp->idc.shortid[0] && !jp->idc.name[0] && !jp->idc.configname[0]) {
-                               if (inputdevice_joyport_config(p, jp->idc.shortid, NULL, i, jp->mode, 0, userconfig)) {
+                               if (inputdevice_joyport_config(p, jp->idc.shortid, NULL, i, jp->mode, jp->submode, 0, userconfig)) {
                                        inputdevice_validate_jports(p, i, matched);
                                        inputdevice_store_used_device(&p->jports[i], i, defaultports);
                                        matched[i] = true;
index 2dcfc7ded196ae708fabf25158b276d610567cc4..9421a5da03bbb1bbc0283c8bcdd3f56772256388 100644 (file)
@@ -4472,7 +4472,7 @@ int input_get_default_mouse (struct uae_input_device *uid, int i, int port, int
        return 0;
 }
 
-int input_get_default_lightpen (struct uae_input_device *uid, int i, int port, int af, bool gp, bool joymouseswap)
+int input_get_default_lightpen (struct uae_input_device *uid, int i, int port, int af, bool gp, bool joymouseswap, int submode)
 {
        struct didata *did = NULL;
 
@@ -4487,7 +4487,14 @@ int input_get_default_lightpen (struct uae_input_device *uid, int i, int port, i
        }
        setid (uid, i, ID_AXIS_OFFSET + 0, 0, port, INPUTEVENT_LIGHTPEN_HORIZ, gp);
        setid (uid, i, ID_AXIS_OFFSET + 1, 0, port, INPUTEVENT_LIGHTPEN_VERT, gp);
-       setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON, gp);
+       int button = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
+       switch (submode)
+       {
+       case 1:
+               button = port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT;
+               break;
+       }
+       setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, button, gp);
        if (i == 0)
                return 1;
        return 0;
index add39b21617f3fc98819c6170c0420e6f626cd15..731089e6f1c8ee3ecdc0ecd9fc5ceac0bb85c05a 100644 (file)
@@ -2069,7 +2069,7 @@ BEGIN
     IDS_JOYMODE_MOUSE       "Mouse"
     IDS_JOYMODE_JOYSTICK    "Joystick"
     IDS_JOYMODE_JOYSTICKANALOG "Analog joystick"
-    IDS_JOYMODE_LIGHTPEN    "Light pen"
+    IDS_JOYMODE_LIGHTPEN    "Generic light pen/gun\nTrojan Phazer light gun"
     IDS_JOYMODE_MOUSE_CDTV  "CDTV remote mouse"
     IDS_JOYMODE_JOYSTICK_CD32 "CD32 pad"
     IDS_TABLET_BOTH_CURSORS "Show both cursors"
index 82ea6331a762e36cb7bbd580fa7bc93ba8ecda33..f35eed9c6ca933d4226dda02c3d13e405354204e 100644 (file)
@@ -550,7 +550,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, true);
+                       inputdevice_joyport_config(&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, 0, true);
                        return 1;
                }
                return 0;
@@ -562,7 +562,7 @@ static int port_insert (int inputmap_port, int devicetype, DWORD flags, const TC
        inputdevice_compa_clear (&changed_prefs, inputmap_port);
        
        if (_tcslen (name) == 0) {
-               inputdevice_joyport_config (&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, true);
+               inputdevice_joyport_config (&changed_prefs, _T("none"), NULL, inputmap_port, 0, 0, 0, true);
                return TRUE;
        }
        devicetype2 = -1;
@@ -584,11 +584,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, true);
+                       ret = inputdevice_joyport_config (&changed_prefs, tmp2, NULL, inputmap_port, devicetype2, 0, 0, true);
                        return ret;
                }
        }
-       ret = inputdevice_joyport_config (&changed_prefs, name, name, inputmap_port, devicetype2, 1, true);
+       ret = inputdevice_joyport_config (&changed_prefs, name, name, inputmap_port, devicetype2, 0, 1, true);
        return ret;
 }
 
index d43d30938ee14ce43c86edaf0a6ecd3ac0aae023..6dc600482775129ac1ee620760d0e201f9900268 100644 (file)
@@ -16521,6 +16521,9 @@ static const int joysm[] = { IDC_PORT0_JOYSMODE, IDC_PORT1_JOYSMODE, -1, -1 };
 static const int joysaf[] = { IDC_PORT0_AF, IDC_PORT1_AF, -1, -1 };
 static const int joyremap[] = { IDC_PORT0_REMAP, IDC_PORT1_REMAP, IDC_PORT2_REMAP, IDC_PORT3_REMAP };
 
+#define MAX_PORTSUBMODES 16
+static int portsubmodes[MAX_PORTSUBMODES];
+
 static void updatejoyport (HWND hDlg, int changedport)
 {
        int i, j;
@@ -16546,7 +16549,7 @@ static void updatejoyport (HWND hDlg, int changedport)
                int id = joys[i];
                int idm = joysm[i];
                int v = workprefs.jports[i].id;
-               int vm = workprefs.jports[i].mode;
+               int vm = workprefs.jports[i].mode + workprefs.jports[i].submode;
                TCHAR *p1, *p2;
 
                if (idm > 0)
@@ -16631,6 +16634,7 @@ static void values_from_gameportsdlg (HWND hDlg, int d, int changedport)
                int idx = 0;
                int *port = &workprefs.jports[i].id;
                int *portm = &workprefs.jports[i].mode;
+               int *portsm = &workprefs.jports[i].submode;
                int prevport = *port;
                int id = joys[i];
                int idm = joysm[i];
@@ -16657,7 +16661,22 @@ static void values_from_gameportsdlg (HWND hDlg, int d, int changedport)
                if (idm >= 0) {
                        v = SendDlgItemMessage (hDlg, idm, CB_GETCURSEL, 0, 0L);
                        if (v != CB_ERR) {
-                               *portm = v;
+                               int vcnt = 0;
+                               *portsm = 0;
+                               for (int j = 0; j < MAX_PORTSUBMODES; j++) {
+                                       if (v <= 0)
+                                               break;
+                                       if (portsubmodes[j] > 0) {
+                                               if (v <= portsubmodes[j]) {
+                                                       *portsm = v;
+                                               }
+                                               v -= portsubmodes[j];
+                                       } else {
+                                               v--;
+                                               vcnt++;
+                                       }
+                               }
+                               *portm = vcnt;
                        }
                                
                }
@@ -17115,28 +17134,34 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
                        }
                        SendDlgItemMessage(hDlg, IDC_PORT_TABLET_MODE, CB_SETCURSEL, workprefs.input_tablet == TABLET_REAL ? 1 : 0, 0);
 
+                       const int joys[] = { IDS_JOYMODE_DEFAULT, IDS_JOYMODE_WHEELMOUSE, IDS_JOYMODE_MOUSE,
+                               IDS_JOYMODE_JOYSTICK, IDS_JOYMODE_GAMEPAD, IDS_JOYMODE_JOYSTICKANALOG,
+                               IDS_JOYMODE_MOUSE_CDTV, IDS_JOYMODE_JOYSTICK_CD32,
+                               IDS_JOYMODE_LIGHTPEN,
+                               0 };
+
                        for (i = 0; i < 2; i++) {
                                int id = i == 0 ? IDC_PORT0_JOYSMODE : IDC_PORT1_JOYSMODE;
-                               SendDlgItemMessage (hDlg, id, CB_RESETCONTENT, 0, 0L);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_DEFAULT, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_WHEELMOUSE, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_MOUSE, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_JOYSTICK, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_GAMEPAD, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_JOYSTICKANALOG, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_MOUSE_CDTV, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_JOYSTICK_CD32, tmp, MAX_DPATH);
-                               SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
-                               WIN32GUI_LoadUIString (IDS_JOYMODE_LIGHTPEN, tmp, MAX_DPATH);
-                               SendDlgItemMessage(hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp);
+                               SendDlgItemMessage(hDlg, id, CB_RESETCONTENT, 0, 0L);
+                               for (int j = 0; joys[j]; j++) {
+                                       WIN32GUI_LoadUIString(joys[j], tmp, MAX_DPATH);
+                                       p1 = tmp;
+                                       _tcscat(p1, _T("\n"));
+                                       for (;;) {
+                                               TCHAR *p2 = _tcschr(p1, '\n');
+                                               if (!p2)
+                                                       break;
+                                               *p2++ = 0;
+                                               SendDlgItemMessage(hDlg, id, CB_ADDSTRING, 0, (LPARAM)p1);
+                                               p1 = p2;
+                                       }
+                               }
+                       }
+                       for (int i = 0; i < MAX_PORTSUBMODES; i++) {
+                               portsubmodes[i] = 0;
                        }
+                       portsubmodes[8] = 2;
+                       portsubmodes[9] = -1;
 
                        inputdevice_updateconfig (NULL, &workprefs);
                        enable_for_gameportsdlg (hDlg);