Skip to content

Commit

Permalink
use adjacent axes and reduce deadzone on ppsspp
Browse files Browse the repository at this point in the history
Assume hrydgard/ppsspp#18404 is fixed, it
would improve car control. Note that it is not an issue on non
windows build.
  • Loading branch information
Kethen committed Nov 11, 2023
1 parent c3d05bf commit 6e5f99e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
### Usage

- load prx with game, see https://www.ppsspp.org/docs/reference/plugins/ for ppsspp
- be sure to map right analog stick directions in ppsspp settings, note that it is possible to map analog triggers to them
- the hooking code may or may not work with a vita, don't have one to test, refer to how one can load psp prx plugins over there

### Keybinds

- on ppsspp, throttle is bound to right stick left, brake is bound to right stick down, remap right stick left and down in ppsspp accordingly to your desired throttle and brake control
- a patched windows ppsspp is provided at the moment to remove hardcoded xinput trigger deadzones, https://github.com/hrydgard/ppsspp/issues/18404
- on vita (when supported), throttle is bound to right stick up, brake is bound to right stick down
- camera rotation can additionally be enabled by creating `ms0:/PSP/GTRemastered_camera_controls.txt`, binds to right analog left and right
- when enabled on ppsspp, it will rebind throttle to right stick up and brake to down


### Compability
- EU v2.00 (UCES01245 2.00)
Expand Down
20 changes: 9 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int override_camera = 0;
static float camera_override = 0;

static unsigned char outer_deadzone = 100;
static unsigned char inner_deadzone = 10;
static unsigned char inner_deadzone = 25;

static int camera_controls = 0;
static int adjacent_axes = 0;
Expand Down Expand Up @@ -545,7 +545,7 @@ void populate_car_analog_control_patched(u32 param_1, int *param_2, unsigned cha
param_3[0] = param_3[0] | 2;
param_3[1] = param_3[1] | 2;
// wtf is this curve for the throttle
short base = 4096 * 0.8;
short base = 4096 * 0.77;
short offset_throttle = 4096 - base;
*throttle = base + accel_override * offset_throttle / 127;
LOG_VERBOSE("applying accel override, val is %d\n", accel_override);
Expand Down Expand Up @@ -588,24 +588,22 @@ int main_thread(SceSize args, void *argp){
log_modules();
}

if(is_emulator){
adjacent_axes = 1;
outer_deadzone = 117;
inner_deadzone = 5;
}

int fd = sceIoOpen("ms0:/PSP/"MODULE_NAME"_camera_controls.txt", PSP_O_RDONLY, 0);
if(fd > 0){
camera_controls = 1;
adjacent_axes = 0;
LOG("enabling camera controls, note that ppsspp right analog axes leak sometimes\n");
sceIoClose(fd);
}else{
LOG("not enabling camera controls\n");
}

fd = sceIoOpen("ms0:/PSP/"MODULE_NAME"_adjacent_axes.txt", PSP_O_RDONLY, 0);
if(fd > 0){
adjacent_axes = 1;
LOG("enabling adjacent controls, rebinding throttle to left\n");
sceIoClose(fd);
}else{
LOG("not enabling adjacent controls\n");
}

//HIJACK_FUNCTION(offset_digital_to_analog, digital_to_analog_patched, digital_to_analog_orig);
//HIJACK_FUNCTION(offset_populate_car_digital_control, populate_car_digital_control_patched, populate_car_digital_control_orig);
HIJACK_FUNCTION(offset_populate_car_analog_control, populate_car_analog_control_patched, populate_car_analog_control_orig);
Expand Down

0 comments on commit 6e5f99e

Please sign in to comment.