From 61c4962abc49e430aabea5e565d93436a57cfa0a Mon Sep 17 00:00:00 2001 From: alexis-puska Date: Mon, 9 May 2016 10:33:05 +0100 Subject: Initial multitap support --- frontend/libretro.c | 229 ++++++++++++++++++++++++++++++------------------- frontend/main.c | 9 +- frontend/plugin.c | 37 ++++---- frontend/plugin_lib.c | 14 +-- frontend/plugin_lib.h | 10 ++- libpcsxcore/plugins.c | 125 ++++++++++++++++++++++++--- libpcsxcore/plugins.h | 2 +- maemo/hildon.c | 4 +- plugins/dfinput/main.c | 2 + 9 files changed, 298 insertions(+), 134 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index ec06527..d6922cb 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -25,7 +25,6 @@ #include "main.h" #include "plugin.h" #include "plugin_lib.h" -#include "arm_features.h" #include "revision.h" #include "libretro.h" @@ -54,10 +53,19 @@ extern char Mcd1Data[MCD_SIZE]; extern char McdDisable[2]; /* PCSX ReARMed core calls and stuff */ -int in_type1, in_type2; -int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; -int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 }; -int in_keystate; +//int in_type1, in_type2; +//int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; +//int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 }; +//int in_keystate; + +int in_type[8]; +int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; +int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; +unsigned short in_keystate[8]; + + + + int in_enable_vibration = 1; /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ @@ -329,7 +337,13 @@ void retro_set_environment(retro_environment_t cb) { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" }, { "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" }, { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad3type", "Pad 3 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad4type", "Pad 4 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad5type", "Pad 5 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad6type", "Pad 6 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad7type", "Pad 7 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad8type", "Pad 8 Type; standard|analog|negcon" }, #ifndef DRC_DISABLE { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, #endif @@ -364,6 +378,7 @@ unsigned retro_api_version(void) void retro_set_controller_port_device(unsigned port, unsigned device) { + printf("port %u device %u",port,device); } void retro_get_system_info(struct retro_system_info *info) @@ -1046,7 +1061,6 @@ static void update_variables(bool in_flight) var.value = NULL; var.key = "pcsx_rearmed_region"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { Config.PsxAuto = 0; @@ -1060,29 +1074,100 @@ static void update_variables(bool in_flight) var.value = NULL; var.key = "pcsx_rearmed_pad1type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { - in_type1 = PSE_PAD_TYPE_STANDARD; + in_type[0] = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) - in_type1 = PSE_PAD_TYPE_ANALOGPAD; + in_type[0] = PSE_PAD_TYPE_ANALOGPAD; if (strcmp(var.value, "negcon") == 0) - in_type1 = PSE_PAD_TYPE_NEGCON; + in_type[0] = PSE_PAD_TYPE_NEGCON; } var.value = NULL; var.key = "pcsx_rearmed_pad2type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { - in_type2 = PSE_PAD_TYPE_STANDARD; + in_type[1] = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) - in_type2 = PSE_PAD_TYPE_ANALOGPAD; + in_type[1] = PSE_PAD_TYPE_ANALOGPAD; if (strcmp(var.value, "negcon") == 0) - in_type2 = PSE_PAD_TYPE_NEGCON; - + in_type[1] = PSE_PAD_TYPE_NEGCON; } + var.value = NULL; + var.key = "pcsx_rearmed_pad3type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[2] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[2] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[2] = PSE_PAD_TYPE_NEGCON; + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad4type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[3] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[3] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[3] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad5type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[4] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[4] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[4] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad6type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[5] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[5] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[5] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad7type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[6] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[6] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[6] = PSE_PAD_TYPE_NEGCON; + } + } + + var.value = NULL; + var.key = "pcsx_rearmed_pad8type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ + in_type[7] = PSE_PAD_TYPE_STANDARD; + if (var.value != NULL){ + if (strcmp(var.value, "analog") == 0) + in_type[7] = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type[7] = PSE_PAD_TYPE_NEGCON; + } + } + + + #ifdef __ARM_NEON__ var.value = "NULL"; var.key = "pcsx_rearmed_neon_interlace_enable"; @@ -1219,7 +1304,8 @@ static void update_variables(bool in_flight) void retro_run(void) { - int i, val; + + int i; input_poll_cb(); @@ -1227,85 +1313,47 @@ void retro_run(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(true); - in_keystate = 0; - for (i = 0; i < RETRO_PSX_MAP_LEN; i++) - if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) - in_keystate |= retro_psx_map[i]; - in_keystate <<= 16; - for (i = 0; i < RETRO_PSX_MAP_LEN; i++) - if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) - in_keystate |= retro_psx_map[i]; - if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) - { - in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a1[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a2[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + // récupération de l'état des boutons par libretro + +// in_keystate = 0; +// for (i = 0; i < RETRO_PSX_MAP_LEN; i++){ +// if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) +// in_keystate |= retro_psx_map[i]; +// +// } +// in_keystate <<= 16; +// for (i = 0; i < RETRO_PSX_MAP_LEN; i++) +// if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) +// in_keystate |= retro_psx_map[i]; + + //reset all keystate, query from libretro for keystate + int j; + for(i=0;i<8;i++){ + in_keystate[i] = 0; + //query from libretro for keystate + for (j = 0; j < RETRO_PSX_MAP_LEN; j++){ + if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j)) + in_keystate[i] |= retro_psx_map[j]; + } } - if (in_type2 == PSE_PAD_TYPE_ANALOGPAD) + if (in_type[0] == PSE_PAD_TYPE_ANALOGPAD) { - in_a3[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a3[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_a4[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_left[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_left[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_right[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_right[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; } - - if (in_type1 == PSE_PAD_TYPE_NEGCON) - { - /* left brake */ - if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) - in_a1[1] = 255; - else - in_a1[1] = 0; - - /* steer */ - in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - - /* thrust and fire */ - val = ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127)); - if(val < -2) { - in_a1[0] = 256 - val; - } - if (val > 2) { - in_a2[1] = val; - } - if(val >= -2 && val <= 2) - { - in_a2[1] = 0; - in_a1[0] = 0; - } - } - - if (in_type2 == PSE_PAD_TYPE_NEGCON) - { - /* left brake */ - if(input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, 12)) - in_a3[1] = 255; - else - in_a3[1] = 0; - - /* steer */ - in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - - /* thrust and fire */ - val = ((input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127)); - if(val < -2) { - in_a3[0] = 256 - val; - } - if (val > 2) { - in_a4[1] = val; - } - if(val >= -2 && val <= 2) - { - in_a4[1] = 0; - in_a3[0] = 0; - } - } - + if (in_type[1] == PSE_PAD_TYPE_ANALOGPAD) + { + in_analog_left[1][0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_left[1][1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_right[1][0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_right[1][1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + } stop = 0; psxCpu->Execute(); @@ -1442,8 +1490,9 @@ void retro_init(void) /* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times) * we have to do this because cache misses and some IO penalties * are not emulated. Warning: changing this may break compatibility. */ +#if !defined(__arm__) || defined(__ARM_ARCH_7A__) cycle_multiplier = 175; -#ifdef HAVE_PRE_ARMV7 +#else cycle_multiplier = 200; #endif pl_rearmed_cbs.gpu_peops.iUseDither = 1; diff --git a/frontend/main.c b/frontend/main.c index f048584..4d43549 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -26,7 +26,6 @@ #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../plugins/cdrcimg/cdrcimg.h" #include "../plugins/dfsound/spu_config.h" -#include "arm_features.h" #include "revision.h" #ifndef NO_FRONTEND @@ -143,7 +142,7 @@ void emu_set_default_config(void) spu_config.iVolume = 768; spu_config.iTempo = 0; spu_config.iUseThread = 1; // no effect if only 1 core is detected -#ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */ +#if defined(__arm__) && !defined(__ARM_ARCH_7A__) /* XXX GPH hack */ spu_config.iUseReverb = 0; spu_config.iUseInterpolation = 0; spu_config.iTempo = 1; @@ -151,8 +150,8 @@ void emu_set_default_config(void) new_dynarec_hacks = 0; cycle_multiplier = 200; - in_type1 = PSE_PAD_TYPE_STANDARD; - in_type2 = PSE_PAD_TYPE_STANDARD; + in_type[0] = PSE_PAD_TYPE_STANDARD; + in_type[1] = PSE_PAD_TYPE_STANDARD; } void do_emu_action(void) @@ -772,7 +771,7 @@ int emu_save_state(int slot) return ret; ret = SaveState(fname); -#ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */ +#if defined(__arm__) && !defined(__ARM_ARCH_7A__) && !defined(_3DS) /* XXX GPH hack */ sync(); #endif SysPrintf("* %s \"%s\" [%d]\n", diff --git a/frontend/plugin.c b/frontend/plugin.c index 03fd47b..acc5601 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -49,28 +49,35 @@ extern void CALLBACK SPUasync(unsigned int, unsigned int); extern int CALLBACK SPUplayCDDAchannel(short *, int); /* PAD */ -static long PADreadPort1(PadDataS *pad) + + +// Lecture du port de la playstation, etat des boutons lu à cette endroit ! +// Distribution des manettes en fonction du port. Si 2, une sur chacun des ports. +// Si supérieur a deux on en connecte 4 sur port 1 et le reste sur port 2 +static long PADreadPort1(PadDataS *pad, int pad_index) { - pad->controllerType = in_type1; - pad->buttonStatus = ~in_keystate; - if (in_type1 == PSE_PAD_TYPE_ANALOGPAD || in_type1 == PSE_PAD_TYPE_NEGCON) { - pad->leftJoyX = in_a1[0]; - pad->leftJoyY = in_a1[1]; - pad->rightJoyX = in_a2[0]; - pad->rightJoyY = in_a2[1]; + pad->controllerType = in_type[pad_index]; + pad->buttonStatus = ~in_keystate[pad_index]; + //pad->buttonStatus = ~in_keystate; + if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_analog_left[pad_index][0]; + pad->leftJoyY = in_analog_left[pad_index][1]; + pad->rightJoyX = in_analog_right[pad_index][0]; + pad->rightJoyY = in_analog_right[pad_index][1]; } return 0; } static long PADreadPort2(PadDataS *pad) { - pad->controllerType = in_type2; - pad->buttonStatus = ~in_keystate >> 16; - if (in_type2 == PSE_PAD_TYPE_ANALOGPAD || in_type2 == PSE_PAD_TYPE_NEGCON) { - pad->leftJoyX = in_a3[0]; - pad->leftJoyY = in_a3[1]; - pad->rightJoyX = in_a4[0]; - pad->rightJoyY = in_a4[1]; + pad->controllerType = in_type[4]; + pad->buttonStatus = ~in_keystate[4]; + //pad->buttonStatus = ~in_keystate >> 16; + if (in_type[4] == PSE_PAD_TYPE_ANALOGPAD || in_type[4] == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_analog_left[4][0]; + pad->leftJoyY = in_analog_left[4][1]; + pad->rightJoyX = in_analog_right[4][0]; + pad->rightJoyY = in_analog_right[4][1]; } return 0; } diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 237a5eb..89803ce 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -36,9 +36,10 @@ #define HUD_HEIGHT 10 -int in_type1, in_type2; -int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; -int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 }; +int in_type[8]; +int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; +int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; +//int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }}; int in_adev_is_nublike[2]; int in_keystate, in_state_gun; @@ -561,7 +562,7 @@ static void update_analog_nub_adjust(int *x_, int *y_) static void update_analogs(void) { - int *nubp[2] = { in_a1, in_a2 }; + int *nubp[2] = { in_analog_left[0], in_analog_right[0] }; int vals[2]; int i, a, v, ret; @@ -598,7 +599,7 @@ static void update_input(void) unsigned int emu_act; in_update(actions); - if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) + if (in_type[0] == PSE_PAD_TYPE_ANALOGPAD) update_analogs(); emu_act = actions[IN_BINDTYPE_EMU]; in_state_gun = (emu_act & SACTION_GUN_MASK) >> SACTION_GUN_TRIGGER; @@ -612,7 +613,8 @@ static void update_input(void) } emu_set_action(emu_act); - in_keystate = actions[IN_BINDTYPE_PLAYER12]; + in_keystate[0] = actions[IN_BINDTYPE_PLAYER12]; + } #else /* MAEMO */ extern void update_input(void); diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 00547fc..eb8d00f 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -17,8 +17,14 @@ enum { DKEY_CROSS, DKEY_SQUARE, }; -extern int in_type1, in_type2; -extern int in_keystate, in_state_gun, in_a1[2], in_a2[2], in_a3[2], in_a4[2]; +//extern int in_type1, in_type2; +//extern int in_keystate, in_state_gun, in_a1[2], in_a2[2], in_a3[2], in_a4[2]; +extern int in_state_gun; +extern int in_type[8]; +extern int in_analog_left[8][2]; +extern int in_analog_right[8][2]; +unsigned short in_keystate[8]; + extern int in_adev[2], in_adev_axis[2][2]; extern int in_adev_is_nublike[2]; extern int in_enable_vibration; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index e6d8a11..3f8a09c 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -372,12 +372,86 @@ static unsigned char buf[256]; unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff }; unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static int bufcount, bufc; -PadDataS padd1, padd2; +//PadDataS padd1, padd2; + +unsigned char _PADstartPollPort1(PadDataS padd[4]) { + int i=0; + int decallage=2; + bufc = 0; + PadDataS pad; + for(i=0;i<4;i++){ + decallage = 2 + (i*8); + pad = padd[i]; + switch (pad.controllerType) { + case PSE_PAD_TYPE_MOUSE: + multitappar[decallage+1] = 0x12; + multitappar[decallage+2] = 0x5a; + multitappar[decallage+3] = pad.buttonStatus & 0xff; + multitappar[decallage+4] = pad.buttonStatus >> 8; + multitappar[decallage+5] = pad.moveX; + multitappar[decallage+6] = pad.moveY; + + break; + case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069) + multitappar[decallage+1] = 0x23; + multitappar[decallage+2] = 0x5a; + multitappar[decallage+3] = pad.buttonStatus & 0xff; + multitappar[decallage+4] = pad.buttonStatus >> 8; + multitappar[decallage+5] = pad.rightJoyX; + multitappar[decallage+6] = pad.rightJoyY; + multitappar[decallage+7] = pad.leftJoyX; + multitappar[decallage+8] = pad.leftJoyY; + + break; + case PSE_PAD_TYPE_ANALOGPAD: // scph1150 + multitappar[decallage+1] = 0x73; + multitappar[decallage+2] = 0x5a; + multitappar[decallage+3] = pad.buttonStatus & 0xff; + multitappar[decallage+4] = pad.buttonStatus >> 8; + multitappar[decallage+5] = pad.rightJoyX; + multitappar[decallage+6] = pad.rightJoyY; + multitappar[decallage+7] = pad.leftJoyX; + multitappar[decallage+8] = pad.leftJoyY; + + break; + case PSE_PAD_TYPE_ANALOGJOY: // scph1110 + multitappar[decallage+1] = 0x53; + multitappar[decallage+2] = 0x5a; + multitappar[decallage+3] = pad.buttonStatus & 0xff; + multitappar[decallage+4] = pad.buttonStatus >> 8; + multitappar[decallage+5] = pad.rightJoyX; + multitappar[decallage+6] = pad.rightJoyY; + multitappar[decallage+7] = pad.leftJoyX; + multitappar[decallage+8] = pad.leftJoyY; + + break; + case PSE_PAD_TYPE_STANDARD: + default: + multitappar[decallage+1] = 0x41; + multitappar[decallage+2] = 0x5a; + multitappar[decallage+3] = pad.buttonStatus & 0xff; + multitappar[decallage+4] = pad.buttonStatus >> 8; + } + } + + memcpy(buf, multitappar, 35); + bufcount = 34; + + return buf[bufc++]; +} + + + unsigned char _PADstartPoll(PadDataS *pad) { + bufc = 0; switch (pad->controllerType) { @@ -430,35 +504,60 @@ unsigned char _PADstartPoll(PadDataS *pad) { default: stdpar[3] = pad->buttonStatus & 0xff; stdpar[4] = pad->buttonStatus >> 8; - - memcpy(buf, stdpar, 5); - bufcount = 4; + memcpy(buf, stdpar, 5); + bufcount = 4; } + return buf[bufc++]; } + + + unsigned char _PADpoll(unsigned char value) { - if (bufc > bufcount) return 0; + if (bufc > bufcount) return 0; return buf[bufc++]; } +// rafraichissement de l'état des boutons sur port 1, +// int pad dans le code d'origine ne sert a rien... unsigned char CALLBACK PAD1__startPoll(int pad) { - PadDataS padd; - - PAD1_readPort1(&padd); - - return _PADstartPoll(&padd); + int i=0; + PadDataS padd[4]; + for(i=0;i<4;i++){ + PAD1_readPort1(&padd[i],i); + } + return _PADstartPollPort1(padd); } unsigned char CALLBACK PAD1__poll(unsigned char value) { - return _PADpoll(value); + +// if(value !=0){ +// int i; +// printf("%2x %c\n", value, value); +// for (i = 0; i < 35; i++) { +// printf("%2x", buf[i]); +// } +// printf("\n"); +// } + + if(value==42){ + unsigned char bufmultitap[256]; + memcpy(bufmultitap, multitappar, 3); + bufcount = 2; + return bufmultitap[bufc++]; + }else{ + return _PADpoll(value); + } } long CALLBACK PAD1__configure(void) { return 0; } void CALLBACK PAD1__about(void) {} long CALLBACK PAD1__test(void) { return 0; } -long CALLBACK PAD1__query(void) { return 3; } +long CALLBACK PAD1__query(void) { + printf("PAD1__query"); + return 3; } long CALLBACK PAD1__keypressed() { return 0; } #define LoadPad1Sym1(dest, name) \ @@ -500,7 +599,7 @@ static int LoadPAD1plugin(const char *PAD1dll) { unsigned char CALLBACK PAD2__startPoll(int pad) { PadDataS padd; - PAD2_readPort2(&padd); + PAD2_readPort2(&padd); return _PADstartPoll(&padd); } diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index 132df90..4f0c4fa 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -234,7 +234,7 @@ typedef long (CALLBACK* PADshutdown)(void); typedef long (CALLBACK* PADtest)(void); typedef long (CALLBACK* PADclose)(void); typedef long (CALLBACK* PADquery)(void); -typedef long (CALLBACK* PADreadPort1)(PadDataS*); +typedef long (CALLBACK* PADreadPort1)(PadDataS*, int pad_index); typedef long (CALLBACK* PADreadPort2)(PadDataS*); typedef long (CALLBACK* PADkeypressed)(void); typedef unsigned char (CALLBACK* PADstartPoll)(int); diff --git a/maemo/hildon.c b/maemo/hildon.c index 7e9cd9f..9b6f787 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -533,7 +533,7 @@ inline void key_press_event(int key2,int type) in_a1[1] = 255; break; } - } + } } else if (type == 2) { if (psxkey1 >= 0) @@ -554,7 +554,7 @@ inline void key_press_event(int key2,int type) } } emu_set_action(SACTION_NONE); - } + } } } diff --git a/plugins/dfinput/main.c b/plugins/dfinput/main.c index c3adedd..15ea07c 100644 --- a/plugins/dfinput/main.c +++ b/plugins/dfinput/main.c @@ -58,6 +58,8 @@ void dfinput_activate(void) { PadDataS pad; + + PAD1_readPort1(&pad); select_pad(1); -- cgit v1.2.3 From ace14ab3172ad90809a3cc5e8fe67d5cac9e294b Mon Sep 17 00:00:00 2001 From: cbransden Date: Mon, 9 May 2016 10:39:45 +0100 Subject: Added multitap core option & style nits --- frontend/libretro.c | 227 ++++++++++++++++++++++++-------------------------- frontend/main.c | 6 +- frontend/plugin.c | 43 ++++------ frontend/plugin_lib.c | 2 - frontend/plugin_lib.h | 2 - libpcsxcore/plugins.c | 10 +-- maemo/hildon.c | 22 ++--- 7 files changed, 141 insertions(+), 171 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index d6922cb..4486b95 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -25,6 +25,7 @@ #include "main.h" #include "plugin.h" #include "plugin_lib.h" +#include "arm_features.h" #include "revision.h" #include "libretro.h" @@ -53,19 +54,12 @@ extern char Mcd1Data[MCD_SIZE]; extern char McdDisable[2]; /* PCSX ReARMed core calls and stuff */ -//int in_type1, in_type2; -//int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; -//int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 }; -//int in_keystate; - int in_type[8]; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; unsigned short in_keystate[8]; - - - - +int multitap1; +int multitap2; int in_enable_vibration = 1; /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ @@ -258,7 +252,7 @@ void pl_3ds_munmap(void *ptr, size_t size, enum psxMapTag tag) #endif static void *pl_mmap(unsigned int size) -{ +{ return psxMap(0, size, 0, MAP_TAG_VRAM); } @@ -337,13 +331,15 @@ void retro_set_environment(retro_environment_t cb) { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" }, { "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" }, { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad3type", "Pad 3 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad4type", "Pad 4 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad5type", "Pad 5 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad6type", "Pad 6 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad7type", "Pad 7 Type; standard|analog|negcon" }, - { "pcsx_rearmed_pad8type", "Pad 8 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad3type", "Pad 3 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad4type", "Pad 4 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad5type", "Pad 5 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad6type", "Pad 6 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad7type", "Pad 7 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad8type", "Pad 8 Type; standard|analog|negcon" }, + { "pcsx_rearmed_multitap1", "Multitap 1; disabled|enabled" }, + { "pcsx_rearmed_multitap2", "Multitap 2; disabled|enabled" }, #ifndef DRC_DISABLE { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, #endif @@ -378,7 +374,7 @@ unsigned retro_api_version(void) void retro_set_controller_port_device(unsigned port, unsigned device) { - printf("port %u device %u",port,device); + SysPrintf("port %u device %u",port,device); } void retro_get_system_info(struct retro_system_info *info) @@ -403,8 +399,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info) } /* savestates */ -size_t retro_serialize_size(void) -{ +size_t retro_serialize_size(void) +{ // it's currently 4380651-4397047 bytes, // but have some reserved for future return 0x440000; @@ -490,7 +486,7 @@ static void save_close(void *file) } bool retro_serialize(void *data, size_t size) -{ +{ int ret = SaveState(data); return ret == 0 ? true : false; } @@ -858,7 +854,7 @@ bool retro_load_game(const struct retro_game_info *info) { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, - { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, { 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, @@ -879,7 +875,7 @@ bool retro_load_game(const struct retro_game_info *info) { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, - { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, { 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, @@ -900,7 +896,7 @@ bool retro_load_game(const struct retro_game_info *info) { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" }, { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" }, { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" }, - { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, + { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" }, { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" }, { 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" }, @@ -999,7 +995,7 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i return false; } -void retro_unload_game(void) +void retro_unload_game(void) { } @@ -1052,10 +1048,9 @@ static const unsigned short retro_psx_map[] = { static void update_variables(bool in_flight) { struct retro_variable var; - + var.value = NULL; var.key = "pcsx_rearmed_frameskip"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) pl_rearmed_cbs.frameskip = atoi(var.value); @@ -1079,7 +1074,7 @@ static void update_variables(bool in_flight) in_type[0] = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) in_type[0] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) + else if (strcmp(var.value, "negcon") == 0) in_type[0] = PSE_PAD_TYPE_NEGCON; } @@ -1090,83 +1085,93 @@ static void update_variables(bool in_flight) in_type[1] = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) in_type[1] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) + else if (strcmp(var.value, "negcon") == 0) in_type[1] = PSE_PAD_TYPE_NEGCON; } - var.value = NULL; - var.key = "pcsx_rearmed_pad3type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) - { - in_type[2] = PSE_PAD_TYPE_STANDARD; - if (strcmp(var.value, "analog") == 0) - in_type[2] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) - in_type[2] = PSE_PAD_TYPE_NEGCON; - } - - var.value = NULL; - var.key = "pcsx_rearmed_pad4type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ - in_type[3] = PSE_PAD_TYPE_STANDARD; - if (var.value != NULL){ - if (strcmp(var.value, "analog") == 0) - in_type[3] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) - in_type[3] = PSE_PAD_TYPE_NEGCON; - } - } + var.value = NULL; + var.key = "pcsx_rearmed_pad3type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[2] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[2] = PSE_PAD_TYPE_ANALOGPAD; + else if (strcmp(var.value, "negcon") == 0) + in_type[2] = PSE_PAD_TYPE_NEGCON; + } - var.value = NULL; - var.key = "pcsx_rearmed_pad5type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) - { - in_type[4] = PSE_PAD_TYPE_STANDARD; - if (var.value != NULL){ - if (strcmp(var.value, "analog") == 0) - in_type[4] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) - in_type[4] = PSE_PAD_TYPE_NEGCON; - } - } + var.value = NULL; + var.key = "pcsx_rearmed_pad4type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[3] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[3] = PSE_PAD_TYPE_ANALOGPAD; + else if (strcmp(var.value, "negcon") == 0) + in_type[3] = PSE_PAD_TYPE_NEGCON; + } - var.value = NULL; - var.key = "pcsx_rearmed_pad6type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ - in_type[5] = PSE_PAD_TYPE_STANDARD; - if (var.value != NULL){ - if (strcmp(var.value, "analog") == 0) - in_type[5] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) - in_type[5] = PSE_PAD_TYPE_NEGCON; - } - } + var.value = NULL; + var.key = "pcsx_rearmed_pad5type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[4] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[4] = PSE_PAD_TYPE_ANALOGPAD; + else if (strcmp(var.value, "negcon") == 0) + in_type[4] = PSE_PAD_TYPE_NEGCON; + } - var.value = NULL; - var.key = "pcsx_rearmed_pad7type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ - in_type[6] = PSE_PAD_TYPE_STANDARD; - if (var.value != NULL){ - if (strcmp(var.value, "analog") == 0) - in_type[6] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) - in_type[6] = PSE_PAD_TYPE_NEGCON; - } - } + var.value = NULL; + var.key = "pcsx_rearmed_pad6type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[5] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[5] = PSE_PAD_TYPE_ANALOGPAD; + else if (strcmp(var.value, "negcon") == 0) + in_type[5] = PSE_PAD_TYPE_NEGCON; + } - var.value = NULL; - var.key = "pcsx_rearmed_pad8type"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value){ - in_type[7] = PSE_PAD_TYPE_STANDARD; - if (var.value != NULL){ - if (strcmp(var.value, "analog") == 0) - in_type[7] = PSE_PAD_TYPE_ANALOGPAD; - if (strcmp(var.value, "negcon") == 0) - in_type[7] = PSE_PAD_TYPE_NEGCON; - } - } + var.value = NULL; + var.key = "pcsx_rearmed_pad7type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[6] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[6] = PSE_PAD_TYPE_ANALOGPAD; + else if (strcmp(var.value, "negcon") == 0) + in_type[6] = PSE_PAD_TYPE_NEGCON; + } + var.value = NULL; + var.key = "pcsx_rearmed_pad8type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type[7] = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type[7] = PSE_PAD_TYPE_ANALOGPAD; + else if (strcmp(var.value, "negcon") == 0) + in_type[7] = PSE_PAD_TYPE_NEGCON; + } + var.value = NULL; + var.key = "pcsx_rearmed_multitap1"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "enabled") == 0) + multitap1 = 1; + else multitap1 = 0; + } + + var.value = NULL; + var.key = "pcsx_rearmed_multitap2"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "enabled") == 0) + multitap2 = 1; + else multitap2 = 0; + } #ifdef __ARM_NEON__ var.value = "NULL"; @@ -1277,7 +1282,7 @@ static void update_variables(bool in_flight) else if (strcmp(var.value, "enabled") == 0) Config.RCntFix = 1; } - + var.value = "NULL"; var.key = "pcsx_rearmed_inuyasha_fix"; @@ -1302,10 +1307,10 @@ static void update_variables(bool in_flight) } } -void retro_run(void) +void retro_run(void) { - int i; + int i; input_poll_cb(); @@ -1313,26 +1318,11 @@ void retro_run(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(true); - - - // récupération de l'état des boutons par libretro - -// in_keystate = 0; -// for (i = 0; i < RETRO_PSX_MAP_LEN; i++){ -// if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i)) -// in_keystate |= retro_psx_map[i]; -// -// } -// in_keystate <<= 16; -// for (i = 0; i < RETRO_PSX_MAP_LEN; i++) -// if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) -// in_keystate |= retro_psx_map[i]; - - //reset all keystate, query from libretro for keystate + // reset all keystate, query from libretro for keystate int j; for(i=0;i<8;i++){ in_keystate[i] = 0; - //query from libretro for keystate + // query from libretro for keystate for (j = 0; j < RETRO_PSX_MAP_LEN; j++){ if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j)) in_keystate[i] |= retro_psx_map[j]; @@ -1475,7 +1465,7 @@ void retro_init(void) else { SysPrintf("no BIOS files found.\n"); - struct retro_message msg = + struct retro_message msg = { "no BIOS found, expect bugs!", 180 @@ -1490,9 +1480,8 @@ void retro_init(void) /* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times) * we have to do this because cache misses and some IO penalties * are not emulated. Warning: changing this may break compatibility. */ -#if !defined(__arm__) || defined(__ARM_ARCH_7A__) cycle_multiplier = 175; -#else +#ifdef HAVE_PRE_ARMV7 cycle_multiplier = 200; #endif pl_rearmed_cbs.gpu_peops.iUseDither = 1; diff --git a/frontend/main.c b/frontend/main.c index 4d43549..89e96e4 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -26,6 +26,7 @@ #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../plugins/cdrcimg/cdrcimg.h" #include "../plugins/dfsound/spu_config.h" +#include "arm_features.h" #include "revision.h" #ifndef NO_FRONTEND @@ -142,7 +143,7 @@ void emu_set_default_config(void) spu_config.iVolume = 768; spu_config.iTempo = 0; spu_config.iUseThread = 1; // no effect if only 1 core is detected -#if defined(__arm__) && !defined(__ARM_ARCH_7A__) /* XXX GPH hack */ +#ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */ spu_config.iUseReverb = 0; spu_config.iUseInterpolation = 0; spu_config.iTempo = 1; @@ -771,7 +772,7 @@ int emu_save_state(int slot) return ret; ret = SaveState(fname); -#if defined(__arm__) && !defined(__ARM_ARCH_7A__) && !defined(_3DS) /* XXX GPH hack */ +#ifdef HAVE_PRE_ARMV7 /* XXX GPH hack */ sync(); #endif SysPrintf("* %s \"%s\" [%d]\n", @@ -1029,4 +1030,3 @@ void SysCloseLibrary(void *lib) { dlclose(lib); #endif } - diff --git a/frontend/plugin.c b/frontend/plugin.c index acc5601..d713452 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -49,37 +49,30 @@ extern void CALLBACK SPUasync(unsigned int, unsigned int); extern int CALLBACK SPUplayCDDAchannel(short *, int); /* PAD */ - - -// Lecture du port de la playstation, etat des boutons lu à cette endroit ! -// Distribution des manettes en fonction du port. Si 2, une sur chacun des ports. -// Si supérieur a deux on en connecte 4 sur port 1 et le reste sur port 2 static long PADreadPort1(PadDataS *pad, int pad_index) { - pad->controllerType = in_type[pad_index]; - pad->buttonStatus = ~in_keystate[pad_index]; - //pad->buttonStatus = ~in_keystate; - if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { - pad->leftJoyX = in_analog_left[pad_index][0]; - pad->leftJoyY = in_analog_left[pad_index][1]; - pad->rightJoyX = in_analog_right[pad_index][0]; - pad->rightJoyY = in_analog_right[pad_index][1]; - } - return 0; + pad->controllerType = in_type[pad_index]; + pad->buttonStatus = ~in_keystate[pad_index]; + if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_analog_left[pad_index][0]; + pad->leftJoyY = in_analog_left[pad_index][1]; + pad->rightJoyX = in_analog_right[pad_index][0]; + pad->rightJoyY = in_analog_right[pad_index][1]; + } + return 0; } static long PADreadPort2(PadDataS *pad) { - pad->controllerType = in_type[4]; - pad->buttonStatus = ~in_keystate[4]; - //pad->buttonStatus = ~in_keystate >> 16; - if (in_type[4] == PSE_PAD_TYPE_ANALOGPAD || in_type[4] == PSE_PAD_TYPE_NEGCON) { - pad->leftJoyX = in_analog_left[4][0]; - pad->leftJoyY = in_analog_left[4][1]; - pad->rightJoyX = in_analog_right[4][0]; - pad->rightJoyY = in_analog_right[4][1]; - } - return 0; + pad->controllerType = in_type[4]; + pad->buttonStatus = ~in_keystate[4]; + if (in_type[4] == PSE_PAD_TYPE_ANALOGPAD || in_type[4] == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_analog_left[4][0]; + pad->leftJoyY = in_analog_left[4][1]; + pad->rightJoyX = in_analog_right[4][0]; + pad->rightJoyY = in_analog_right[4][1]; + } + return 0; } /* GPU */ diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 89803ce..ff3518e 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -39,7 +39,6 @@ int in_type[8]; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; -//int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }}; int in_adev_is_nublike[2]; int in_keystate, in_state_gun; @@ -614,7 +613,6 @@ static void update_input(void) emu_set_action(emu_act); in_keystate[0] = actions[IN_BINDTYPE_PLAYER12]; - } #else /* MAEMO */ extern void update_input(void); diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index eb8d00f..50fcf9e 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -17,8 +17,6 @@ enum { DKEY_CROSS, DKEY_SQUARE, }; -//extern int in_type1, in_type2; -//extern int in_keystate, in_state_gun, in_a1[2], in_a2[2], in_a3[2], in_a4[2]; extern int in_state_gun; extern int in_type[8]; extern int in_analog_left[8][2]; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 3f8a09c..372fdd0 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -380,7 +380,6 @@ unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff static int bufcount, bufc; //PadDataS padd1, padd2; - unsigned char _PADstartPollPort1(PadDataS padd[4]) { int i=0; int decallage=2; @@ -447,9 +446,6 @@ unsigned char _PADstartPollPort1(PadDataS padd[4]) { return buf[bufc++]; } - - - unsigned char _PADstartPoll(PadDataS *pad) { bufc = 0; @@ -508,13 +504,9 @@ unsigned char _PADstartPoll(PadDataS *pad) { bufcount = 4; } - return buf[bufc++]; } - - - unsigned char _PADpoll(unsigned char value) { if (bufc > bufcount) return 0; return buf[bufc++]; @@ -599,7 +591,7 @@ static int LoadPAD1plugin(const char *PAD1dll) { unsigned char CALLBACK PAD2__startPoll(int pad) { PadDataS padd; - PAD2_readPort2(&padd); + PAD2_readPort2(&padd); return _PADstartPoll(&padd); } diff --git a/maemo/hildon.c b/maemo/hildon.c index 9b6f787..6fbdcf5 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -484,31 +484,31 @@ inline void key_press_event(int key2,int type) switch (psxkey1){ case DKEY_CROSS: in_state_gun |= SACTION_GUN_A; - break; + break; case DKEY_CIRCLE: in_state_gun |= SACTION_GUN_B; - break; + break; case DKEY_TRIANGLE: in_state_gun |= SACTION_GUN_TRIGGER2; - break; + break; case DKEY_SQUARE: in_state_gun |= SACTION_GUN_TRIGGER; - break; + break; } }else if (type == 2) { switch (psxkey1){ case DKEY_CROSS: in_state_gun &= ~SACTION_GUN_A; - break; + break; case DKEY_CIRCLE: in_state_gun &= ~SACTION_GUN_B; - break; + break; case DKEY_TRIANGLE: in_state_gun &= ~SACTION_GUN_TRIGGER2; - break; + break; case DKEY_SQUARE: in_state_gun &= ~SACTION_GUN_TRIGGER; - break; + break; } } }else{ @@ -599,7 +599,7 @@ int maemo_init(int *argc, char ***argv) } fclose(pFile); } - + switch (in_type1){ case PSE_PAD_TYPE_GUNCON: memset(cornerActions, 0, sizeof(cornerActions)); @@ -610,7 +610,7 @@ int maemo_init(int *argc, char ***argv) break; case PSE_PAD_TYPE_ANALOGPAD: printf("Controller set to analog (SCPH-1150)\n"); - break; + break; } if (in_enable_vibration) @@ -664,7 +664,7 @@ int maemo_init(int *argc, char ***argv) if (bKeepDisplayOn){ if (pthread_create(&display_thread, NULL, displayThread, NULL)) - printf("Failed to create display thread.\n"); + printf("Failed to create display thread.\n"); } pl_rearmed_cbs.only_16bpp = 1; -- cgit v1.2.3 From 29f3675b9b2f24b8a16db73588b8b04d628eabd8 Mon Sep 17 00:00:00 2001 From: alexis-puska Date: Thu, 12 May 2016 01:45:26 +0200 Subject: second implementation of multitap add game/core option to enabled or disabled multitap. Test with micro machine V3 and 5 devices, 2 multitap enabled, all device react good i can’t test the 6 7 8 select player but i can select 8 gamer. The 2 multitap works fine. i detect a bug, when we change the game pad type to analog, the library crash, see it next time --- frontend/libretro.c | 4 +- frontend/plugin.c | 30 ++++++++----- frontend/plugin_lib.c | 2 + frontend/plugin_lib.h | 4 +- include/psemu_plugin_defs.h | 5 +++ libpcsxcore/plugins.c | 104 ++++++++++++++++++++++++++++++++++---------- libpcsxcore/plugins.h | 2 +- 7 files changed, 113 insertions(+), 38 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 4486b95..361695c 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -58,8 +58,8 @@ int in_type[8]; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; unsigned short in_keystate[8]; -int multitap1; -int multitap2; +int multitap1 = 0; +int multitap2 = 0; int in_enable_vibration = 1; /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ diff --git a/frontend/plugin.c b/frontend/plugin.c index d713452..cf93df8 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -49,10 +49,14 @@ extern void CALLBACK SPUasync(unsigned int, unsigned int); extern int CALLBACK SPUplayCDDAchannel(short *, int); /* PAD */ -static long PADreadPort1(PadDataS *pad, int pad_index) -{ +static long PADreadPort1(PadDataS *pad, int pad_index) { pad->controllerType = in_type[pad_index]; pad->buttonStatus = ~in_keystate[pad_index]; + if(multitap1==1){ + pad->portMultitap=1; + }else{ + pad->portMultitap=0; + } if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { pad->leftJoyX = in_analog_left[pad_index][0]; pad->leftJoyY = in_analog_left[pad_index][1]; @@ -62,15 +66,19 @@ static long PADreadPort1(PadDataS *pad, int pad_index) return 0; } -static long PADreadPort2(PadDataS *pad) -{ - pad->controllerType = in_type[4]; - pad->buttonStatus = ~in_keystate[4]; - if (in_type[4] == PSE_PAD_TYPE_ANALOGPAD || in_type[4] == PSE_PAD_TYPE_NEGCON) { - pad->leftJoyX = in_analog_left[4][0]; - pad->leftJoyY = in_analog_left[4][1]; - pad->rightJoyX = in_analog_right[4][0]; - pad->rightJoyY = in_analog_right[4][1]; +static long PADreadPort2(PadDataS *pad, int pad_index) { + pad->controllerType = in_type[pad_index]; + pad->buttonStatus = ~in_keystate[pad_index]; + if(multitap2==1){ + pad->portMultitap=2; + }else{ + pad->portMultitap=0; + } + if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_analog_left[pad_index][0]; + pad->leftJoyY = in_analog_left[pad_index][1]; + pad->rightJoyX = in_analog_right[pad_index][0]; + pad->rightJoyY = in_analog_right[pad_index][1]; } return 0; } diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index ff3518e..ad2f49b 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -37,6 +37,8 @@ #define HUD_HEIGHT 10 int in_type[8]; +int multitap1; +int multitap2; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }}; diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 50fcf9e..ad27fc2 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -17,8 +17,10 @@ enum { DKEY_CROSS, DKEY_SQUARE, }; -extern int in_state_gun; +extern int in_state_gun; extern int in_type[8]; +extern int multitap1; +extern int multitap2; extern int in_analog_left[8][2]; extern int in_analog_right[8][2]; unsigned short in_keystate[8]; diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index 9986654..7232d03 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -194,6 +194,11 @@ typedef struct // controler type - fill it withe predefined values above unsigned char controllerType; + //0 : No multitap between psx and pad + //1 : multitap between psx and pad on port 1 + //2 : multitap between psx and pad on port 2 + int portMultitap; + // status of buttons - every controller fills this field unsigned short buttonStatus; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 372fdd0..3d0ed3c 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -368,7 +368,10 @@ static int LoadSPUplugin(const char *SPUdll) { void *hPAD1Driver = NULL; void *hPAD2Driver = NULL; -static unsigned char buf[256]; +static int multitap1 = -1; +static int multitap2 = -1; + +static unsigned char buf[512]; unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff }; unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -380,7 +383,7 @@ unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff static int bufcount, bufc; //PadDataS padd1, padd2; -unsigned char _PADstartPollPort1(PadDataS padd[4]) { +unsigned char _PADstartPollMultitap(PadDataS padd[4]) { int i=0; int decallage=2; bufc = 0; @@ -515,16 +518,29 @@ unsigned char _PADpoll(unsigned char value) { // rafraichissement de l'état des boutons sur port 1, // int pad dans le code d'origine ne sert a rien... unsigned char CALLBACK PAD1__startPoll(int pad) { - int i=0; - PadDataS padd[4]; - for(i=0;i<4;i++){ - PAD1_readPort1(&padd[i],i); + //first call the pad provide if a multitap is connected between the psx and himself + if(multitap1 == -1){ + PadDataS padd; + PAD1_readPort1(&padd,0); + multitap1 = padd.portMultitap; + } + // just one pad is on port 1 : NO MULTITAP + if (multitap1 == 0){ + PadDataS padd; + PAD1_readPort1(&padd,0); + return _PADstartPoll(&padd); + }else{ + //a multitap is plugged : refresh all pad. + int i=0; + PadDataS padd[4]; + for(i=0;i<4;i++){ + PAD1_readPort1(&padd[i],i); + } + return _PADstartPollMultitap(padd); } - return _PADstartPollPort1(padd); } unsigned char CALLBACK PAD1__poll(unsigned char value) { - // if(value !=0){ // int i; // printf("%2x %c\n", value, value); @@ -533,23 +549,24 @@ unsigned char CALLBACK PAD1__poll(unsigned char value) { // } // printf("\n"); // } - - if(value==42){ - unsigned char bufmultitap[256]; - memcpy(bufmultitap, multitappar, 3); - bufcount = 2; - return bufmultitap[bufc++]; - }else{ + if(multitap1==0){ return _PADpoll(value); + }else{ + if(value==42){ + unsigned char bufmultitap[256]; + memcpy(bufmultitap, multitappar, 3); + bufcount = 2; + return bufmultitap[bufc++]; + }else{ + return _PADpoll(value); + } } } long CALLBACK PAD1__configure(void) { return 0; } void CALLBACK PAD1__about(void) {} long CALLBACK PAD1__test(void) { return 0; } -long CALLBACK PAD1__query(void) { - printf("PAD1__query"); - return 3; } +long CALLBACK PAD1__query(void) { return 3; } long CALLBACK PAD1__keypressed() { return 0; } #define LoadPad1Sym1(dest, name) \ @@ -589,15 +606,56 @@ static int LoadPAD1plugin(const char *PAD1dll) { } unsigned char CALLBACK PAD2__startPoll(int pad) { - PadDataS padd; + int pad_index = 0; + if(multitap1 == 1){ + pad_index+=4; + }else{ + pad_index=1; + } + //first call the pad provide if a multitap is connected between the psx and himself + if(multitap2 == -1){ + PadDataS padd; + PAD2_readPort2(&padd,pad_index); + multitap2 = padd.portMultitap; + } - PAD2_readPort2(&padd); - - return _PADstartPoll(&padd); + // just one pad is on port 2 : NO MULTITAP + if (multitap2 == 0){ + PadDataS padd; + PAD2_readPort2(&padd,pad_index); + return _PADstartPoll(&padd); + }else{ + //a multitap is plugged : refresh all pad. + int i=pad_index; + PadDataS padd[4]; + for(i=0;i<4;i++){ + PAD2_readPort2(&padd[i],i+pad_index); + } + return _PADstartPollMultitap(padd); + } } unsigned char CALLBACK PAD2__poll(unsigned char value) { - return _PADpoll(value); +// if(value !=0){ +// int i; +// printf("%2x %c\n", value, value); +// for (i = 0; i < 35; i++) { +// printf("%2x", buf[i]); +// } +// printf("\n"); +// } + if(multitap2==0){ + return _PADpoll(value); + }else { + if(value==42){ + unsigned char bufmultitap[256]; + memcpy(bufmultitap, multitappar, 3); + bufcount = 2; + return bufmultitap[bufc++]; + }else{ + return _PADpoll(value); + } + } } long CALLBACK PAD2__configure(void) { return 0; } diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index 4f0c4fa..626939b 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -235,7 +235,7 @@ typedef long (CALLBACK* PADtest)(void); typedef long (CALLBACK* PADclose)(void); typedef long (CALLBACK* PADquery)(void); typedef long (CALLBACK* PADreadPort1)(PadDataS*, int pad_index); -typedef long (CALLBACK* PADreadPort2)(PadDataS*); +typedef long (CALLBACK* PADreadPort2)(PadDataS*, int pad_index); typedef long (CALLBACK* PADkeypressed)(void); typedef unsigned char (CALLBACK* PADstartPoll)(int); typedef unsigned char (CALLBACK* PADpoll)(unsigned char); -- cgit v1.2.3 From c663ec74b85ca464d4aecf5697505ebc79ec0f93 Mon Sep 17 00:00:00 2001 From: cbransden Date: Thu, 12 May 2016 12:31:41 +0100 Subject: Init in_type fully --- frontend/libretro.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 361695c..5bcbb1b 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -54,7 +54,10 @@ extern char Mcd1Data[MCD_SIZE]; extern char McdDisable[2]; /* PCSX ReARMed core calls and stuff */ -int in_type[8]; +int in_type[8] = { PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD, + PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD, + PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD, + PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD }; int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }}; unsigned short in_keystate[8]; -- cgit v1.2.3 From 56abf6140ec44820247d574b30b6a62221e86b0c Mon Sep 17 00:00:00 2001 From: alexis-puska Date: Thu, 12 May 2016 20:33:06 +0200 Subject: fix analog value fix analog value --- frontend/libretro.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 5bcbb1b..0cd724e 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1330,22 +1330,17 @@ void retro_run(void) if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j)) in_keystate[i] |= retro_psx_map[j]; } - } - if (in_type[0] == PSE_PAD_TYPE_ANALOGPAD) - { - in_analog_left[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_analog_left[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_analog_right[0][0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_analog_right[0][1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - } - if (in_type[1] == PSE_PAD_TYPE_ANALOGPAD) - { - in_analog_left[1][0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_analog_left[1][1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_analog_right[1][0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_analog_right[1][1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + printf("%i : %i\n",i , input_state_cb(i, RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X)); + + if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD) + { + in_analog_left[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_left[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_right[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_analog_right[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + } } stop = 0; -- cgit v1.2.3 From 6f1d3c7a18600c59227b3373a5205841174f8e44 Mon Sep 17 00:00:00 2001 From: alexis-puska Date: Thu, 12 May 2016 21:18:17 +0200 Subject: comment debugging printf --- frontend/libretro.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 0cd724e..6e859c7 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1331,8 +1331,7 @@ void retro_run(void) in_keystate[i] |= retro_psx_map[j]; } - - printf("%i : %i\n",i , input_state_cb(i, RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X)); + //printf("%i : %i\n",i , input_state_cb(i, RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X)); if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD) { -- cgit v1.2.3 From bebaef4be9a87d92b11bc29a002a531a9d1fa5d7 Mon Sep 17 00:00:00 2001 From: dankcushions Date: Fri, 13 May 2016 16:21:37 +0100 Subject: Defensive code to avoid SEGFAULT --- frontend/plugin.c | 7 ++++++- libpcsxcore/plugins.c | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/plugin.c b/frontend/plugin.c index cf93df8..53ecac9 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -67,7 +67,12 @@ static long PADreadPort1(PadDataS *pad, int pad_index) { } static long PADreadPort2(PadDataS *pad, int pad_index) { - pad->controllerType = in_type[pad_index]; + /* Temporary hack to avoid segfault when pad_index is a crazy number */ + if (pad_index <= 1 || pad_index > 8) { + pad_index = 1; + } + + pad->controllerType = in_type[pad_index]; pad->buttonStatus = ~in_keystate[pad_index]; if(multitap2==1){ pad->portMultitap=2; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 3d0ed3c..1369b1c 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -384,8 +384,8 @@ static int bufcount, bufc; //PadDataS padd1, padd2; unsigned char _PADstartPollMultitap(PadDataS padd[4]) { - int i=0; - int decallage=2; + int i=0; + int decallage=2; bufc = 0; PadDataS pad; for(i=0;i<4;i++){ @@ -626,7 +626,7 @@ unsigned char CALLBACK PAD2__startPoll(int pad) { return _PADstartPoll(&padd); }else{ //a multitap is plugged : refresh all pad. - int i=pad_index; + int i=0; PadDataS padd[4]; for(i=0;i<4;i++){ PAD2_readPort2(&padd[i],i+pad_index); -- cgit v1.2.3 From 3b1a5e21b399fcb38c5d8ead3c16603f566d7ffa Mon Sep 17 00:00:00 2001 From: cbransden Date: Fri, 13 May 2016 17:50:34 +0100 Subject: Style nits --- frontend/libretro.c | 14 ++---- frontend/plugin.c | 26 +++++----- include/psemu_plugin_defs.h | 4 +- libpcsxcore/plugins.c | 117 +++++++++++++++++++++----------------------- maemo/hildon.c | 26 +++++----- plugins/dfinput/main.c | 2 - 6 files changed, 90 insertions(+), 99 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 6e859c7..bdce90e 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1312,8 +1312,7 @@ static void update_variables(bool in_flight) void retro_run(void) { - - int i; + int i; input_poll_cb(); @@ -1321,17 +1320,14 @@ void retro_run(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(true); - // reset all keystate, query from libretro for keystate + // reset all keystate, query libretro for keystate int j; - for(i=0;i<8;i++){ + for(i = 0; i < 8; i++) { in_keystate[i] = 0; - // query from libretro for keystate - for (j = 0; j < RETRO_PSX_MAP_LEN; j++){ + // query libretro for keystate + for (j = 0; j < RETRO_PSX_MAP_LEN; j++) if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j)) in_keystate[i] |= retro_psx_map[j]; - } - - //printf("%i : %i\n",i , input_state_cb(i, RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X)); if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD) { diff --git a/frontend/plugin.c b/frontend/plugin.c index 53ecac9..5663e6d 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -52,12 +52,13 @@ extern int CALLBACK SPUplayCDDAchannel(short *, int); static long PADreadPort1(PadDataS *pad, int pad_index) { pad->controllerType = in_type[pad_index]; pad->buttonStatus = ~in_keystate[pad_index]; - if(multitap1==1){ - pad->portMultitap=1; - }else{ - pad->portMultitap=0; - } - if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { + if (multitap1 == 1) + pad->portMultitap = 1; + else + pad->portMultitap = 0; + + if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) + { pad->leftJoyX = in_analog_left[pad_index][0]; pad->leftJoyY = in_analog_left[pad_index][1]; pad->rightJoyX = in_analog_right[pad_index][0]; @@ -74,12 +75,13 @@ static long PADreadPort2(PadDataS *pad, int pad_index) { pad->controllerType = in_type[pad_index]; pad->buttonStatus = ~in_keystate[pad_index]; - if(multitap2==1){ - pad->portMultitap=2; - }else{ - pad->portMultitap=0; - } - if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) { + if (multitap2 ==1 ) + pad->portMultitap = 2; + else + pad->portMultitap = 0; + + if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON) + { pad->leftJoyX = in_analog_left[pad_index][0]; pad->leftJoyY = in_analog_left[pad_index][1]; pad->rightJoyX = in_analog_right[pad_index][0]; diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index 7232d03..034f21b 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -191,10 +191,10 @@ typedef struct typedef struct { - // controler type - fill it withe predefined values above + // controller type - fill it withe predefined values above unsigned char controllerType; - //0 : No multitap between psx and pad + //0 : no multitap between psx and pad //1 : multitap between psx and pad on port 1 //2 : multitap between psx and pad on port 2 int portMultitap; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 1369b1c..8d3a00e 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -384,62 +384,62 @@ static int bufcount, bufc; //PadDataS padd1, padd2; unsigned char _PADstartPollMultitap(PadDataS padd[4]) { - int i=0; - int decallage=2; + int i = 0; + int offset = 2; bufc = 0; PadDataS pad; - for(i=0;i<4;i++){ - decallage = 2 + (i*8); + for(i = 0; i < 4; i++) { + offset = 2 + (i * 8); pad = padd[i]; switch (pad.controllerType) { case PSE_PAD_TYPE_MOUSE: - multitappar[decallage+1] = 0x12; - multitappar[decallage+2] = 0x5a; - multitappar[decallage+3] = pad.buttonStatus & 0xff; - multitappar[decallage+4] = pad.buttonStatus >> 8; - multitappar[decallage+5] = pad.moveX; - multitappar[decallage+6] = pad.moveY; + multitappar[offset + 1] = 0x12; + multitappar[offset + 2] = 0x5a; + multitappar[offset + 3] = pad.buttonStatus & 0xff; + multitappar[offset + 4] = pad.buttonStatus >> 8; + multitappar[offset + 5] = pad.moveX; + multitappar[offset + 6] = pad.moveY; break; case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069) - multitappar[decallage+1] = 0x23; - multitappar[decallage+2] = 0x5a; - multitappar[decallage+3] = pad.buttonStatus & 0xff; - multitappar[decallage+4] = pad.buttonStatus >> 8; - multitappar[decallage+5] = pad.rightJoyX; - multitappar[decallage+6] = pad.rightJoyY; - multitappar[decallage+7] = pad.leftJoyX; - multitappar[decallage+8] = pad.leftJoyY; + multitappar[offset + 1] = 0x23; + multitappar[offset + 2] = 0x5a; + multitappar[offset + 3] = pad.buttonStatus & 0xff; + multitappar[offset + 4] = pad.buttonStatus >> 8; + multitappar[offset + 5] = pad.rightJoyX; + multitappar[offset + 6] = pad.rightJoyY; + multitappar[offset + 7] = pad.leftJoyX; + multitappar[offset + 8] = pad.leftJoyY; break; case PSE_PAD_TYPE_ANALOGPAD: // scph1150 - multitappar[decallage+1] = 0x73; - multitappar[decallage+2] = 0x5a; - multitappar[decallage+3] = pad.buttonStatus & 0xff; - multitappar[decallage+4] = pad.buttonStatus >> 8; - multitappar[decallage+5] = pad.rightJoyX; - multitappar[decallage+6] = pad.rightJoyY; - multitappar[decallage+7] = pad.leftJoyX; - multitappar[decallage+8] = pad.leftJoyY; + multitappar[offset + 1] = 0x73; + multitappar[offset + 2] = 0x5a; + multitappar[offset + 3] = pad.buttonStatus & 0xff; + multitappar[offset + 4] = pad.buttonStatus >> 8; + multitappar[offset + 5] = pad.rightJoyX; + multitappar[offset + 6] = pad.rightJoyY; + multitappar[offset + 7] = pad.leftJoyX; + multitappar[offset + 8] = pad.leftJoyY; break; case PSE_PAD_TYPE_ANALOGJOY: // scph1110 - multitappar[decallage+1] = 0x53; - multitappar[decallage+2] = 0x5a; - multitappar[decallage+3] = pad.buttonStatus & 0xff; - multitappar[decallage+4] = pad.buttonStatus >> 8; - multitappar[decallage+5] = pad.rightJoyX; - multitappar[decallage+6] = pad.rightJoyY; - multitappar[decallage+7] = pad.leftJoyX; - multitappar[decallage+8] = pad.leftJoyY; + multitappar[offset + 1] = 0x53; + multitappar[offset + 2] = 0x5a; + multitappar[offset + 3] = pad.buttonStatus & 0xff; + multitappar[offset + 4] = pad.buttonStatus >> 8; + multitappar[offset + 5] = pad.rightJoyX; + multitappar[offset + 6] = pad.rightJoyY; + multitappar[offset + 7] = pad.leftJoyX; + multitappar[offset + 8] = pad.leftJoyY; break; case PSE_PAD_TYPE_STANDARD: default: - multitappar[decallage+1] = 0x41; - multitappar[decallage+2] = 0x5a; - multitappar[decallage+3] = pad.buttonStatus & 0xff; - multitappar[decallage+4] = pad.buttonStatus >> 8; + multitappar[offset + 1] = 0x41; + multitappar[offset + 2] = 0x5a; + multitappar[offset + 3] = pad.buttonStatus & 0xff; + multitappar[offset + 4] = pad.buttonStatus >> 8; } } @@ -515,49 +515,44 @@ unsigned char _PADpoll(unsigned char value) { return buf[bufc++]; } -// rafraichissement de l'état des boutons sur port 1, -// int pad dans le code d'origine ne sert a rien... +// refresh the button state on port 1. +// int pad is not needed. unsigned char CALLBACK PAD1__startPoll(int pad) { - //first call the pad provide if a multitap is connected between the psx and himself - if(multitap1 == -1){ + // first call the pad provide if a multitap is connected between the psx and himself + if(multitap1 == -1) + { PadDataS padd; - PAD1_readPort1(&padd,0); + PAD1_readPort1(&padd, 0); multitap1 = padd.portMultitap; } // just one pad is on port 1 : NO MULTITAP - if (multitap1 == 0){ + if (multitap1 == 0) + { PadDataS padd; - PAD1_readPort1(&padd,0); + PAD1_readPort1(&padd, 0); return _PADstartPoll(&padd); - }else{ - //a multitap is plugged : refresh all pad. + } else { + // a multitap is plugged : refresh all pad. int i=0; PadDataS padd[4]; - for(i=0;i<4;i++){ - PAD1_readPort1(&padd[i],i); + for(i = 0; i < 4; i++) { + PAD1_readPort1(&padd[i], i); } return _PADstartPollMultitap(padd); } } unsigned char CALLBACK PAD1__poll(unsigned char value) { -// if(value !=0){ -// int i; -// printf("%2x %c\n", value, value); -// for (i = 0; i < 35; i++) { -// printf("%2x", buf[i]); -// } -// printf("\n"); -// } - if(multitap1==0){ + if (multitap1 == 0) + { return _PADpoll(value); - }else{ - if(value==42){ + } else { + if(value == 42) { unsigned char bufmultitap[256]; memcpy(bufmultitap, multitappar, 3); bufcount = 2; return bufmultitap[bufc++]; - }else{ + } else { return _PADpoll(value); } } diff --git a/maemo/hildon.c b/maemo/hildon.c index 6fbdcf5..7e9cd9f 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -484,31 +484,31 @@ inline void key_press_event(int key2,int type) switch (psxkey1){ case DKEY_CROSS: in_state_gun |= SACTION_GUN_A; - break; + break; case DKEY_CIRCLE: in_state_gun |= SACTION_GUN_B; - break; + break; case DKEY_TRIANGLE: in_state_gun |= SACTION_GUN_TRIGGER2; - break; + break; case DKEY_SQUARE: in_state_gun |= SACTION_GUN_TRIGGER; - break; + break; } }else if (type == 2) { switch (psxkey1){ case DKEY_CROSS: in_state_gun &= ~SACTION_GUN_A; - break; + break; case DKEY_CIRCLE: in_state_gun &= ~SACTION_GUN_B; - break; + break; case DKEY_TRIANGLE: in_state_gun &= ~SACTION_GUN_TRIGGER2; - break; + break; case DKEY_SQUARE: in_state_gun &= ~SACTION_GUN_TRIGGER; - break; + break; } } }else{ @@ -533,7 +533,7 @@ inline void key_press_event(int key2,int type) in_a1[1] = 255; break; } - } + } } else if (type == 2) { if (psxkey1 >= 0) @@ -554,7 +554,7 @@ inline void key_press_event(int key2,int type) } } emu_set_action(SACTION_NONE); - } + } } } @@ -599,7 +599,7 @@ int maemo_init(int *argc, char ***argv) } fclose(pFile); } - + switch (in_type1){ case PSE_PAD_TYPE_GUNCON: memset(cornerActions, 0, sizeof(cornerActions)); @@ -610,7 +610,7 @@ int maemo_init(int *argc, char ***argv) break; case PSE_PAD_TYPE_ANALOGPAD: printf("Controller set to analog (SCPH-1150)\n"); - break; + break; } if (in_enable_vibration) @@ -664,7 +664,7 @@ int maemo_init(int *argc, char ***argv) if (bKeepDisplayOn){ if (pthread_create(&display_thread, NULL, displayThread, NULL)) - printf("Failed to create display thread.\n"); + printf("Failed to create display thread.\n"); } pl_rearmed_cbs.only_16bpp = 1; diff --git a/plugins/dfinput/main.c b/plugins/dfinput/main.c index 15ea07c..c3adedd 100644 --- a/plugins/dfinput/main.c +++ b/plugins/dfinput/main.c @@ -58,8 +58,6 @@ void dfinput_activate(void) { PadDataS pad; - - PAD1_readPort1(&pad); select_pad(1); -- cgit v1.2.3