Initial multitap support
authoralexis-puska <a.puska@ile-noire.com>
Mon, 9 May 2016 09:33:05 +0000 (10:33 +0100)
committercbransden <chris.bransden@objectway.com>
Fri, 13 May 2016 16:55:51 +0000 (17:55 +0100)
frontend/libretro.c
frontend/main.c
frontend/plugin.c
frontend/plugin_lib.c
frontend/plugin_lib.h
libpcsxcore/plugins.c
libpcsxcore/plugins.h
maemo/hildon.c
plugins/dfinput/main.c

index ec06527..d6922cb 100644 (file)
@@ -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;
index f048584..4d43549 100644 (file)
@@ -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",
index 03fd47b..acc5601 100644 (file)
@@ -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;
 }
index 237a5eb..89803ce 100644 (file)
 
 #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);
index 00547fc..eb8d00f 100644 (file)
@@ -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;
index e6d8a11..3f8a09c 100644 (file)
@@ -372,12 +372,86 @@ static unsigned char buf[256];
 unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
 unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff };\r
 unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
+unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+                                                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+                                                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+                                                                                                       0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
 \r
 static int bufcount, bufc;\r
 \r
-PadDataS padd1, padd2;\r
+//PadDataS padd1, padd2;\r
+\r
+unsigned char _PADstartPollPort1(PadDataS padd[4]) {\r
+       int i=0;\r
+       int decallage=2;\r
+    bufc = 0;\r
+    PadDataS pad;\r
+    for(i=0;i<4;i++){\r
+       decallage = 2 + (i*8);\r
+       pad = padd[i];\r
+               switch (pad.controllerType) {\r
+                       case PSE_PAD_TYPE_MOUSE:\r
+                               multitappar[decallage+1] = 0x12;\r
+                               multitappar[decallage+2] = 0x5a;\r
+                               multitappar[decallage+3] = pad.buttonStatus & 0xff;\r
+                               multitappar[decallage+4] = pad.buttonStatus >> 8;\r
+                               multitappar[decallage+5] = pad.moveX;\r
+                               multitappar[decallage+6] = pad.moveY;\r
+\r
+                               break;\r
+                       case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069)\r
+                               multitappar[decallage+1] = 0x23;\r
+                               multitappar[decallage+2] = 0x5a;\r
+                               multitappar[decallage+3] = pad.buttonStatus & 0xff;\r
+                               multitappar[decallage+4] = pad.buttonStatus >> 8;\r
+                               multitappar[decallage+5] = pad.rightJoyX;\r
+                               multitappar[decallage+6] = pad.rightJoyY;\r
+                               multitappar[decallage+7] = pad.leftJoyX;\r
+                               multitappar[decallage+8] = pad.leftJoyY;\r
+\r
+                               break;\r
+                       case PSE_PAD_TYPE_ANALOGPAD: // scph1150\r
+                               multitappar[decallage+1] = 0x73;\r
+                               multitappar[decallage+2] = 0x5a;\r
+                               multitappar[decallage+3] = pad.buttonStatus & 0xff;\r
+                               multitappar[decallage+4] = pad.buttonStatus >> 8;\r
+                               multitappar[decallage+5] = pad.rightJoyX;\r
+                               multitappar[decallage+6] = pad.rightJoyY;\r
+                               multitappar[decallage+7] = pad.leftJoyX;\r
+                               multitappar[decallage+8] = pad.leftJoyY;\r
+\r
+                               break;\r
+                       case PSE_PAD_TYPE_ANALOGJOY: // scph1110\r
+                               multitappar[decallage+1] = 0x53;\r
+                               multitappar[decallage+2] = 0x5a;\r
+                               multitappar[decallage+3] = pad.buttonStatus & 0xff;\r
+                               multitappar[decallage+4] = pad.buttonStatus >> 8;\r
+                               multitappar[decallage+5] = pad.rightJoyX;\r
+                               multitappar[decallage+6] = pad.rightJoyY;\r
+                               multitappar[decallage+7] = pad.leftJoyX;\r
+                               multitappar[decallage+8] = pad.leftJoyY;\r
+\r
+                               break;\r
+                       case PSE_PAD_TYPE_STANDARD:\r
+                       default:\r
+                               multitappar[decallage+1] = 0x41;\r
+                               multitappar[decallage+2] = 0x5a;\r
+                               multitappar[decallage+3] = pad.buttonStatus & 0xff;\r
+                               multitappar[decallage+4] = pad.buttonStatus >> 8;\r
+               }\r
+    }\r
+\r
+    memcpy(buf, multitappar, 35);\r
+    bufcount = 34;\r
+\r
+    return buf[bufc++];\r
+}\r
+\r
+\r
+\r
 \r
 unsigned char _PADstartPoll(PadDataS *pad) {\r
+\r
     bufc = 0;\r
 \r
     switch (pad->controllerType) {\r
@@ -430,35 +504,60 @@ unsigned char _PADstartPoll(PadDataS *pad) {
         default:\r
             stdpar[3] = pad->buttonStatus & 0xff;\r
             stdpar[4] = pad->buttonStatus >> 8;\r
-\r
-            memcpy(buf, stdpar, 5);\r
-            bufcount = 4;\r
+               memcpy(buf, stdpar, 5);\r
+               bufcount = 4;\r
     }\r
 \r
+\r
     return buf[bufc++];\r
 }\r
 \r
+\r
+\r
+\r
 unsigned char _PADpoll(unsigned char value) {\r
-    if (bufc > bufcount) return 0;\r
+       if (bufc > bufcount) return 0;\r
     return buf[bufc++];\r
 }\r
 \r
+// rafraichissement de l'état des boutons sur port 1,\r
+// int pad dans le code d'origine ne sert a rien...\r
 unsigned char CALLBACK PAD1__startPoll(int pad) {\r
-    PadDataS padd;\r
-\r
-    PAD1_readPort1(&padd);\r
-\r
-    return _PADstartPoll(&padd);\r
+       int i=0;\r
+       PadDataS padd[4];\r
+       for(i=0;i<4;i++){\r
+               PAD1_readPort1(&padd[i],i);\r
+       }\r
+       return _PADstartPollPort1(padd);\r
 }\r
 \r
 unsigned char CALLBACK PAD1__poll(unsigned char value) {\r
-    return _PADpoll(value);\r
+\r
+//     if(value !=0){\r
+//             int i;\r
+//             printf("%2x  %c\n", value, value);\r
+//             for (i = 0; i < 35; i++) {\r
+//               printf("%2x", buf[i]);\r
+//             }\r
+//             printf("\n");\r
+//             }\r
+\r
+       if(value==42){\r
+               unsigned char bufmultitap[256];\r
+           memcpy(bufmultitap, multitappar, 3);\r
+           bufcount = 2;\r
+           return bufmultitap[bufc++];\r
+       }else{\r
+               return _PADpoll(value);\r
+       }\r
 }\r
 \r
 long CALLBACK PAD1__configure(void) { return 0; }\r
 void CALLBACK PAD1__about(void) {}\r
 long CALLBACK PAD1__test(void) { return 0; }\r
-long CALLBACK PAD1__query(void) { return 3; }\r
+long CALLBACK PAD1__query(void) {\r
+       printf("PAD1__query");\r
+       return 3; }\r
 long CALLBACK PAD1__keypressed() { return 0; }\r
 \r
 #define LoadPad1Sym1(dest, name) \\r
@@ -500,7 +599,7 @@ static int LoadPAD1plugin(const char *PAD1dll) {
 unsigned char CALLBACK PAD2__startPoll(int pad) {\r
        PadDataS padd;\r
 \r
-       PAD2_readPort2(&padd);\r
+       PAD2_readPort2(&padd);
     \r
        return _PADstartPoll(&padd);\r
 }\r
index 132df90..4f0c4fa 100644 (file)
@@ -234,7 +234,7 @@ typedef long (CALLBACK* PADshutdown)(void);
 typedef long (CALLBACK* PADtest)(void);                \r
 typedef long (CALLBACK* PADclose)(void);\r
 typedef long (CALLBACK* PADquery)(void);\r
-typedef long (CALLBACK* PADreadPort1)(PadDataS*);\r
+typedef long (CALLBACK* PADreadPort1)(PadDataS*, int pad_index);\r
 typedef long (CALLBACK* PADreadPort2)(PadDataS*);\r
 typedef long (CALLBACK* PADkeypressed)(void);\r
 typedef unsigned char (CALLBACK* PADstartPoll)(int);\r
index 7e9cd9f..9b6f787 100644 (file)
@@ -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);
-       }
+               }
        }
 }
 
index c3adedd..15ea07c 100644 (file)
@@ -58,6 +58,8 @@ void dfinput_activate(void)
 {
        PadDataS pad;
 
+
+
        PAD1_readPort1(&pad);
        select_pad(1);