add guncon support
[pcsx_rearmed.git] / frontend / menu.c
index 1bfac1d..8b51c06 100644 (file)
@@ -30,7 +30,7 @@
 #include "../libpcsxcore/cdrom.h"
 #include "../libpcsxcore/psemu_plugin_defs.h"
 #include "../libpcsxcore/new_dynarec/new_dynarec.h"
-#include "../plugins/dfinput/pad.h"
+#include "../plugins/dfinput/main.h"
 #include "revision.h"
 
 #define MENU_X2 1
@@ -70,10 +70,10 @@ enum {
 };
 
 static int last_psx_w, last_psx_h, last_psx_bpp;
-static int scaling, filter, cpu_clock, cpu_clock_st;
+static int scaling, filter, cpu_clock, cpu_clock_st, volume_boost;
 static char rom_fname_reload[MAXPATHLEN];
 static char last_selected_fname[MAXPATHLEN];
-static int warned_about_bios, region, in_type_sel;
+static int warned_about_bios, region, in_type_sel1, in_type_sel2;
 static int memcard1_sel, memcard2_sel;
 int g_opts;
 
@@ -83,6 +83,7 @@ extern int iUseInterpolation;
 extern int iXAPitch;
 extern int iSPUIRQWait;
 extern int iUseTimer;
+extern int iVolume;
 
 static const char *bioses[24];
 static const char *gpu_plugins[16];
@@ -142,7 +143,16 @@ static void menu_sync_config(void)
                Config.PsxAuto = 0;
                Config.PsxType = region - 1;
        }
-       in_type = in_type_sel ? PSE_PAD_TYPE_ANALOGPAD : PSE_PAD_TYPE_STANDARD;
+       switch (in_type_sel1) {
+       case 1:  in_type1 = PSE_PAD_TYPE_ANALOGPAD; break;
+       case 2:  in_type1 = PSE_PAD_TYPE_GUNCON;    break;
+       default: in_type1 = PSE_PAD_TYPE_STANDARD;
+       }
+       switch (in_type_sel2) {
+       case 1:  in_type2 = PSE_PAD_TYPE_ANALOGPAD; break;
+       case 2:  in_type2 = PSE_PAD_TYPE_GUNCON;    break;
+       default: in_type2 = PSE_PAD_TYPE_STANDARD;
+       }
        if (in_evdev_allow_abs_only != allow_abs_only_old) {
                pandora_rescan_inputs();
                allow_abs_only_old = in_evdev_allow_abs_only;
@@ -153,15 +163,18 @@ static void menu_sync_config(void)
        pl_rearmed_cbs.gpu_peops.fFrameRateHz = Config.PsxType ? 50.0f : 59.94f;
        pl_rearmed_cbs.gpu_peops.dwFrameRateTicks =
                (100000*100 / (unsigned long)(pl_rearmed_cbs.gpu_peops.fFrameRateHz*100));
+
+       iVolume = 768 + 128 * volume_boost;
 }
 
 static void menu_set_defconfig(void)
 {
        g_opts = 0;
        scaling = SCALE_4_3;
+       volume_boost = 0;
 
        region = 0;
-       in_type_sel = 0;
+       in_type_sel1 = in_type_sel2 = 0;
        in_evdev_allow_abs_only = 0;
        Config.Xa = Config.Cdda = Config.Sio =
        Config.SpuIrq = Config.RCntFix = Config.VSyncWA = 0;
@@ -229,7 +242,8 @@ static const struct {
        CE_INTVAL(state_slot),
        CE_INTVAL(cpu_clock),
        CE_INTVAL(g_opts),
-       CE_INTVAL(in_type_sel),
+       CE_INTVAL(in_type_sel1),
+       CE_INTVAL(in_type_sel2),
        CE_INTVAL_P(frameskip),
        CE_INTVAL_P(gpu_peops.iUseDither),
        CE_INTVAL_P(gpu_peops.dwActFixes),
@@ -240,6 +254,7 @@ static const struct {
        CE_INTVAL(iUseTimer),
        CE_INTVAL(warned_about_bios),
        CE_INTVAL(in_evdev_allow_abs_only),
+       CE_INTVAL(volume_boost),
 };
 
 static char *get_cd_label(void)
@@ -703,6 +718,10 @@ me_bind_action emuctrl_actions[] =
        { "Toggle Frameskip ", 1 << SACTION_TOGGLE_FSKIP },
        { "Take Screenshot  ", 1 << SACTION_SCREENSHOT },
        { "Enter Menu       ", 1 << SACTION_ENTER_MENU },
+       { "Gun Trigger      ", 1 << SACTION_GUN_TRIGGER },
+       { "Gun A button     ", 1 << SACTION_GUN_A },
+       { "Gun B button     ", 1 << SACTION_GUN_B },
+       { "Gun Offscreen Trigger", 1 << SACTION_GUN_TRIGGER2 },
        { NULL,                0 }
 };
 
@@ -938,17 +957,25 @@ static int mh_input_rescan(int id, int keys)
        return 0;
 }
 
-static const char *men_in_type_sel[] = { "Standard (SCPH-1080)", "Analog (SCPH-1150)", NULL };
+static const char *men_in_type_sel[] = {
+       "Standard (SCPH-1080)",
+       "Analog (SCPH-1150)",
+       "GunCon",
+       NULL
+};
 static const char h_nub_btns[] = "Experimental, keep this OFF if unsure. Select rescan after change.";
+static const char h_notsgun[] =  "Don't trigger (shoot) when touching screen in gun games.";
 
 static menu_entry e_menu_keyconfig[] =
 {
-       mee_handler_id("Player 1",          MA_CTRL_PLAYER1,    key_config_loop_wrap),
-       mee_handler_id("Player 2",          MA_CTRL_PLAYER2,    key_config_loop_wrap),
-       mee_handler_id("Emulator controls", MA_CTRL_EMU,        key_config_loop_wrap),
+       mee_handler_id("Player 1",              MA_CTRL_PLAYER1,    key_config_loop_wrap),
+       mee_handler_id("Player 2",              MA_CTRL_PLAYER2,    key_config_loop_wrap),
+       mee_handler_id("Emulator/Gun controls", MA_CTRL_EMU,        key_config_loop_wrap),
        mee_label     (""),
-       mee_enum      ("Controller",        0, in_type_sel,     men_in_type_sel),
+       mee_enum      ("Port 1 device",     0, in_type_sel1,    men_in_type_sel),
+       mee_enum      ("Port 2 device",     0, in_type_sel2,    men_in_type_sel),
        mee_onoff_h   ("Nubs as buttons",   0, in_evdev_allow_abs_only, 1, h_nub_btns),
+       mee_onoff_h   ("No TS Gun trigger", 0, g_opts, OPT_TSGUN_NOTRIGGER, h_notsgun),
        mee_cust_nosave("Save global config",       MA_OPT_SAVECFG,      mh_savecfg, mgn_saveloadcfg),
        mee_cust_nosave("Save cfg for loaded game", MA_OPT_SAVECFG_GAME, mh_savecfg, mgn_saveloadcfg),
        mee_handler   ("Rescan devices",  mh_input_rescan),
@@ -1084,11 +1111,13 @@ static int menu_loop_plugin_gpu(int id, int keys)
 }
 
 static const char *men_spu_interp[] = { "None", "Simple", "Gaussian", "Cubic", NULL };
+static const char h_spu_volboost[]  = "Large values cause distortion";
 static const char h_spu_irq_wait[]  = "Wait for CPU (recommended set to ON)";
 static const char h_spu_thread[]    = "Run sound emulation in main thread (recommended)";
 
 static menu_entry e_menu_plugin_spu[] =
 {
+       mee_range_h   ("Volume boost",              0, volume_boost, -5, 30, h_spu_volboost),
        mee_onoff     ("Reverb",                    0, iUseReverb, 2),
        mee_enum      ("Interpolation",             0, iUseInterpolation, men_spu_interp),
        mee_onoff     ("Adjust XA pitch",           0, iXAPitch, 1),
@@ -1993,7 +2022,7 @@ void menu_prepare_emu(void)
                        fprintf(stderr, "Warning: GPU_open returned %d\n", ret);
        }
 
-       dfinput_activate(in_type == PSE_PAD_TYPE_ANALOGPAD);
+       dfinput_activate();
 }
 
 void me_update_msg(const char *msg)