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

Some fixes for VRS wheelbase #59

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions effect-test.ffb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
00000000 # Constant force left
00000000 > UPLOAD id:-1 dir:16384 type:CONSTANT level:8000
00000000 < 0 id:0
00000000 > PLAY 0 1
00000000 # Set gain to the max
00000000 > GAIN -1

00000001 # Constant force left
00000001 > UPLOAD id:-1 dir:16384 type:CONSTANT level:8000
00000001 < 0 id:0
00000001 > PLAY 0 1

03000000 # Constant force right
03000000 > UPLOAD id:0 dir:16384 type:CONSTANT level:-8000
Expand Down
36 changes: 31 additions & 5 deletions hid-pidff.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ static const u8 pidff_pool[] = { 0x80, 0x83, 0xa9 };
#define PID_DISABLE_ACTUATORS 1
#define PID_STOP_ALL_EFFECTS 2
#define PID_RESET 3
static const u8 pidff_device_control[] = { 0x97, 0x98, 0x99, 0x9a };
#define PID_DEVICE_CONTINUE 4
static const u8 pidff_device_control[] = { 0x97, 0x98, 0x99, 0x9a, 0x9c };

#define PID_CONSTANT 0
#define PID_RAMP 1
Expand Down Expand Up @@ -436,8 +437,12 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,
pidff_set_signed(&pidff->set_periodic[PID_OFFSET],
effect->u.periodic.offset);
pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase);
pidff_set_time(&pidff->set_periodic[PID_PERIOD],
effect->u.periodic.period);
// Actually we just can use clamp macro
// from include/linux/kernel.h#L59
// But for the debug purposes we're leaving it as is
pidff->set_periodic[PID_PERIOD].value[0] =
pidff_clamp(effect->u.periodic.period,
pidff->set_periodic[PID_PERIOD].field);

hid_hw_request(pidff->hid, pidff->reports[PID_SET_PERIODIC],
HID_REQ_SET_REPORT);
Expand Down Expand Up @@ -748,6 +753,12 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)
pidff_playback_pid(pidff, pid_id, 0);
pidff_erase_pid(pidff, pid_id);

if (pidff->effect_count > 0)
pidff->effect_count--;

hid_dbg(pidff->hid, "Effects count: %d/%d\n", pidff->effect_count,
pidff->pool[PID_SIMULTANEOUS_MAX].value?pidff->pool[PID_SIMULTANEOUS_MAX].value[0]:PID_EFFECTS_MAX);

return 0;
}

Expand All @@ -761,6 +772,18 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
int type_id;
int error;


// Try to wake device
//set_device_continue(pidff, 1);
// Always enable actuators when effect is uploaded.
//set_actuators(pidff, 1);

// Go nuclear
/*if (pidff->effect_count == 0) {
hid_dbg(pidff->hid, "Effect count appears to be 0. Let's reset the device.\n");
pidff_device_reset(pidff);
}*/

pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0;
if (old) {
pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] =
Expand Down Expand Up @@ -879,8 +902,10 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
pidff->pid_id[effect->id] =
pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0];

hid_dbg(pidff->hid, "uploaded\n");

pidff->effect_count++;
hid_dbg(pidff->hid, "Effects count: %d/%d\n", pidff->effect_count,
pidff->pool[PID_SIMULTANEOUS_MAX].value?pidff->pool[PID_SIMULTANEOUS_MAX].value[0]:PID_EFFECTS_MAX);

return 0;
}

Expand Down Expand Up @@ -1350,6 +1375,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
return 0;
}


/*
* Test if autocenter modification is using the supported method
*/
Expand Down