X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=620cd172cd036a133e9ed611350b56f26264025d;hb=f1fcf5ee6b340b4945242c7ee2933e764edc90ad;hp=20e233a14fb6de76e6c4058a18780b52c1b16146;hpb=3d3bda68ad4f24314f43bf9de85cad3735d9050c;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 20e233a1..620cd172 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -571,6 +571,8 @@ static void update_controller_port_variable(unsigned port) in_type[port] = PSE_PAD_TYPE_ANALOGPAD; else if (strcmp(var.value, "negcon") == 0) in_type[port] = PSE_PAD_TYPE_NEGCON; + else if (strcmp(var.value, "guncon") == 0) + in_type[port] = PSE_PAD_TYPE_GUNCON; else if (strcmp(var.value, "none") == 0) in_type[port] = PSE_PAD_TYPE_NONE; // else 'default' case, do nothing @@ -1333,7 +1335,7 @@ size_t retro_get_memory_size(unsigned id) if (id == RETRO_MEMORY_SAVE_RAM) return MCD_SIZE; else if (id == RETRO_MEMORY_SYSTEM_RAM) - return 0x210000; + return 0x200000; else return 0; } @@ -1907,6 +1909,94 @@ void retro_run(void) } } + if (in_type[i] == PSE_PAD_TYPE_GUNCON) + { + //ToDo move across to: + //RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X + //RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y + //RETRO_DEVICE_ID_LIGHTGUN_TRIGGER + //RETRO_DEVICE_ID_LIGHTGUN_RELOAD + //RETRO_DEVICE_ID_LIGHTGUN_AUX_A + //RETRO_DEVICE_ID_LIGHTGUN_AUX_B + //Though not sure these are hooked up properly on the Pi + + //ToDo + //Put the controller index back to i instead of hardcoding to 1 when the libretro overlay crash bug is fixed + //This is required for 2 player + + //GUNCON has 3 controls, Trigger,A,B which equal Circle,Start,Cross + + // Trigger + //input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_O) + //The 1 is hardcoded instead of i to prevent the overlay mouse button libretro crash bug + if (input_state_cb(1, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT)){ + in_keystate[i] |= (1 << DKEY_CIRCLE); + } + + // A + if (input_state_cb(1, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT)){ + in_keystate[i] |= (1 << DKEY_START); + } + + // B + if (input_state_cb(1, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE)){ + in_keystate[i] |= (1 << DKEY_CROSS); + } + + //The 1 is hardcoded instead of i to prevent the overlay mouse button libretro crash bug + int gunx = input_state_cb(1, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); + int guny = input_state_cb(1, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); + + //This adjustment process gives the user the ability to manually align the mouse up better + //with where the shots are in the emulator. + + //Percentage distance of screen to adjust + int GunconAdjustX = 0; + int GunconAdjustY = 0; + + //Used when out by a percentage + float GunconAdjustRatioX = 1; + float GunconAdjustRatioY = 1; + + struct retro_variable var; + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjustx"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustX = atoi(var.value); + } + + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjusty"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustY = atoi(var.value); + } + + + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjustratiox"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustRatioX = atof(var.value); + } + + + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjustratioy"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustRatioY = atof(var.value); + } + + //Mouse range is -32767 -> 32767 + //1% is about 655 + //Use the left analog stick field to store the absolute coordinates + in_analog_left[0][0] = (gunx*GunconAdjustRatioX) + (GunconAdjustX * 655); + in_analog_left[0][1] = (guny*GunconAdjustRatioY) + (GunconAdjustY * 655); + + + } if (in_type[i] == PSE_PAD_TYPE_NEGCON) { // Query digital inputs @@ -2011,7 +2101,7 @@ void retro_run(void) // > NeGcon L in_analog_left[i][1] = get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_L); } - else + if (in_type[i] != PSE_PAD_TYPE_NEGCON && in_type[i] != PSE_PAD_TYPE_GUNCON) { // Query digital inputs for (j = 0; j < RETRO_PSX_MAP_LEN; j++) @@ -2078,7 +2168,7 @@ static bool find_any_bios(const char *dirpath, char *path, size_t path_size) return false; while ((ent = readdir(dir))) { - if (strncasecmp(ent->d_name, "scph", 4) != 0) + if ((strncasecmp(ent->d_name, "scph", 4) != 0) && (strncasecmp(ent->d_name, "psx", 3) != 0)) continue; snprintf(path, path_size, "%s%c%s", dirpath, SLASH, ent->d_name); @@ -2144,6 +2234,7 @@ static void loadPSXBios(void) unsigned useHLE = 0; const char *bios[] = { + "PSXONPSP660", "psxonpsp660", "SCPH101", "scph101", "SCPH5501", "scph5501", "SCPH7001", "scph7001",