Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DualShock3 rumble intensity by removing overflow and adjusting motor set… #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions ios/ios_pad/source/controllers/dualshock3_controller.c
Original file line number Diff line number Diff line change
@@ -68,11 +68,24 @@ static void sendRumbleLedState(Controller* controller)

rep.report_id = DUALSHOCK3_OUTPUT_REPORT_ID;

rep.right_motor_duration = 1;
rep.right_motor_force = ds_data->rumble;
rep.left_motor_duration = 1;
rep.left_motor_force = ds_data->rumble * 64;
// Treat ds_data->rumble as a 0..255 scale for the big (left) motor.
// If ds_data->rumble is non-zero, we can also turn on the small (right) motor.
// Typically just consider a threshold for small motor or keep it always on if rumble > 0.

rep.right_motor_duration = 0xFF;
rep.left_motor_duration = 0xFF;

// Small motor: either on/off
if (ds_data->rumble > 0) {
rep.right_motor_force = 0x01; // turn small motor on
} else {
rep.right_motor_force = 0x00; // turn small motor off
}

// Big motor: 0..255 intensity
rep.left_motor_force = ds_data->rumble;

// LED setup as before
rep.led_mask = ds_data->led_mask << 1;
memcpy(&rep.leds[0], &led_config, sizeof(Dualshock3LedConfig));
memcpy(&rep.leds[1], &led_config, sizeof(Dualshock3LedConfig));
@@ -82,6 +95,7 @@ static void sendRumbleLedState(Controller* controller)
setReport(controller->handle, BTA_HH_RPTT_OUTPUT, &rep, sizeof(rep));
}


void controllerRumble_dualshock3(Controller* controller, uint8_t rumble)
{
Dualshock3Data* ds_data = (Dualshock3Data*) controller->additionalData;