aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrés2016-05-15 17:29:01 -0500
committerAndrés2016-05-15 17:29:01 -0500
commit05311a18fb23799776f9552614ef4c5fb5d852fa (patch)
tree93dfb321a3aae5421fdb3aef533987e271211d06
parent93fed87bed7cc0bdc0f74e3f852282d938f7db4f (diff)
parent3b1a5e21b399fcb38c5d8ead3c16603f566d7ffa (diff)
downloadpcsx_rearmed-05311a18fb23799776f9552614ef4c5fb5d852fa.tar.gz
pcsx_rearmed-05311a18fb23799776f9552614ef4c5fb5d852fa.tar.bz2
pcsx_rearmed-05311a18fb23799776f9552614ef4c5fb5d852fa.zip
Merge pull request #39 from dankcushions/master
Added multitap 1 & 2 core options - adds 3-8 player support.
-rw-r--r--frontend/libretro.c241
-rw-r--r--frontend/main.c5
-rw-r--r--frontend/plugin.c59
-rw-r--r--frontend/plugin_lib.c14
-rw-r--r--frontend/plugin_lib.h10
-rw-r--r--include/psemu_plugin_defs.h7
-rw-r--r--libpcsxcore/plugins.c178
-rw-r--r--libpcsxcore/plugins.h4
8 files changed, 360 insertions, 158 deletions
diff --git a/frontend/libretro.c b/frontend/libretro.c
index ec06527..bdce90e 100644
--- a/frontend/libretro.c
+++ b/frontend/libretro.c
@@ -54,10 +54,15 @@ 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] = { 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];
+int multitap1 = 0;
+int multitap2 = 0;
int in_enable_vibration = 1;
/* PSX max resolution is 640x512, but with enhancement it's 1024x512 */
@@ -250,7 +255,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);
}
@@ -330,6 +335,14 @@ void retro_set_environment(retro_environment_t cb)
{ "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_multitap1", "Multitap 1; disabled|enabled" },
+ { "pcsx_rearmed_multitap2", "Multitap 2; disabled|enabled" },
#ifndef DRC_DISABLE
{ "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" },
#endif
@@ -364,6 +377,7 @@ unsigned retro_api_version(void)
void retro_set_controller_port_device(unsigned port, unsigned device)
{
+ SysPrintf("port %u device %u",port,device);
}
void retro_get_system_info(struct retro_system_info *info)
@@ -388,8 +402,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;
@@ -475,7 +489,7 @@ static void save_close(void *file)
}
bool retro_serialize(void *data, size_t size)
-{
+{
int ret = SaveState(data);
return ret == 0 ? true : false;
}
@@ -843,7 +857,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" },
@@ -864,7 +878,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" },
@@ -885,7 +899,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" },
@@ -984,7 +998,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)
{
}
@@ -1037,16 +1051,14 @@ 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);
var.value = NULL;
var.key = "pcsx_rearmed_region";
-
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
{
Config.PsxAuto = 0;
@@ -1060,27 +1072,108 @@ 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;
- if (strcmp(var.value, "negcon") == 0)
- in_type1 = PSE_PAD_TYPE_NEGCON;
+ in_type[0] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ 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_type[1] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[1] = PSE_PAD_TYPE_ANALOGPAD;
+ 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_type2 = PSE_PAD_TYPE_STANDARD;
+ in_type[2] = PSE_PAD_TYPE_STANDARD;
if (strcmp(var.value, "analog") == 0)
- in_type2 = PSE_PAD_TYPE_ANALOGPAD;
- if (strcmp(var.value, "negcon") == 0)
- in_type2 = PSE_PAD_TYPE_NEGCON;
+ 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_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_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_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_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__
@@ -1192,7 +1285,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";
@@ -1217,9 +1310,9 @@ static void update_variables(bool in_flight)
}
}
-void retro_run(void)
+void retro_run(void)
{
- int i, val;
+ int i;
input_poll_cb();
@@ -1227,86 +1320,24 @@ 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];
-
+ // reset all keystate, query libretro for keystate
+ int j;
+ for(i = 0; i < 8; i++) {
+ in_keystate[i] = 0;
+ // 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];
- 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;
- }
-
- if (in_type2 == 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;
+ 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;
+ }
}
-
- 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;
- }
- }
-
-
stop = 0;
psxCpu->Execute();
@@ -1427,7 +1458,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
diff --git a/frontend/main.c b/frontend/main.c
index f048584..89e96e4 100644
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -151,8 +151,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)
@@ -1030,4 +1030,3 @@ void SysCloseLibrary(void *lib) {
dlclose(lib);
#endif
}
-
diff --git a/frontend/plugin.c b/frontend/plugin.c
index 03fd47b..5663e6d 100644
--- a/frontend/plugin.c
+++ b/frontend/plugin.c
@@ -49,30 +49,45 @@ extern void CALLBACK SPUasync(unsigned int, unsigned int);
extern int CALLBACK SPUplayCDDAchannel(short *, int);
/* PAD */
-static long PADreadPort1(PadDataS *pad)
-{
- 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];
- }
- return 0;
+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];
+ 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];
- }
- return 0;
+static long PADreadPort2(PadDataS *pad, int 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;
+ 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;
}
/* GPU */
diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c
index 237a5eb..ad2f49b 100644
--- a/frontend/plugin_lib.c
+++ b/frontend/plugin_lib.c
@@ -36,9 +36,11 @@
#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 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 }};
int in_adev_is_nublike[2];
int in_keystate, in_state_gun;
@@ -561,7 +563,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 +600,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 +614,7 @@ 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..ad27fc2 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_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];
+
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/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h
index 9986654..034f21b 100644
--- a/include/psemu_plugin_defs.h
+++ b/include/psemu_plugin_defs.h
@@ -191,9 +191,14 @@ 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
+ //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 e6d8a11..8d3a00e 100644
--- a/libpcsxcore/plugins.c
+++ b/libpcsxcore/plugins.c
@@ -368,16 +368,89 @@ 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 };
+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 _PADstartPollMultitap(PadDataS padd[4]) {
+ int i = 0;
+ int offset = 2;
+ bufc = 0;
+ PadDataS pad;
+ for(i = 0; i < 4; i++) {
+ offset = 2 + (i * 8);
+ pad = padd[i];
+ switch (pad.controllerType) {
+ case PSE_PAD_TYPE_MOUSE:
+ 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[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[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[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[offset + 1] = 0x41;
+ multitappar[offset + 2] = 0x5a;
+ multitappar[offset + 3] = pad.buttonStatus & 0xff;
+ multitappar[offset + 4] = pad.buttonStatus >> 8;
+ }
+ }
+
+ memcpy(buf, multitappar, 35);
+ bufcount = 34;
+
+ return buf[bufc++];
+}
unsigned char _PADstartPoll(PadDataS *pad) {
+
bufc = 0;
switch (pad->controllerType) {
@@ -430,29 +503,59 @@ 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++];
}
+// refresh the button state on port 1.
+// int pad is not needed.
unsigned char CALLBACK PAD1__startPoll(int pad) {
- PadDataS padd;
-
- PAD1_readPort1(&padd);
-
- return _PADstartPoll(&padd);
+ // 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);
+ }
}
unsigned char CALLBACK PAD1__poll(unsigned char value) {
- return _PADpoll(value);
+ 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; }
@@ -498,15 +601,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=0;
+ 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 132df90..626939b 100644
--- a/libpcsxcore/plugins.h
+++ b/libpcsxcore/plugins.h
@@ -234,8 +234,8 @@ 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* PADreadPort2)(PadDataS*);
+typedef long (CALLBACK* PADreadPort1)(PadDataS*, int pad_index);
+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);