I'm projecting a gamepad with Arduino Micro. I'm using the Arduino Joystick Library.
I'm building this gamepad for racing games so I need to catch signal like hit_the_wall
, hit_another_car
.
I wonder how the PC game output the signal of the vibration/force feedback and send throw USB to the gamepad.
I already know that the gamepad drivers and the game have to support this function, but I'm completely lost about how I can catch the input to trigger the vibration engine with Arduino.
I was thinking something about (pseudocode):
input = Serial.read();
if(input == hit_something_signal){
digitalWrite(engine, HIGH);
}
Now my question is which is this magic hit_something_signal
?
UPDATE
I'm reading the PID document and I notice on page number 24 the register addresses to implement the force feedback.
;Start Force Feedback command definitions
USAGE_PAGE (Physical Interface) 05 0F
;Effect Report Definition
USAGE (Set Effect Report) 09 21
COLLECTION (Logical) A1 02
USAGE (Effect Block Index) 09 22
LOGICAL_MAXIMUM (127) 25 7F
REPORT_SIZE (7) 75 07
REPORT_COUNT (1) 95 01
OUTPUT (Data,Var,Abs)
.......
In the Joystick.cpp file I notice the HID implementation:
// USAGE_PAGE (Generic Desktop)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x05;
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01;
// USAGE (Joystick - 0x04; Gamepad - 0x05; Multi-axis Controller - 0x08)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x09;
tempHidReportDescriptor[hidReportDescriptorSize++] = joystickType;
// COLLECTION (Application)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0xa1;
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01;
// REPORT_ID (Default: 3)
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x85;
tempHidReportDescriptor[hidReportDescriptorSize++] = _hidReportId;
.......
......
Do you think should be possible to implement the force feedback part? I do not need to catch all the forces, but run the vibrator engine every time the game sends and input of every kind of force.
The problem is that I'm not an expert about low-level programming and drivers. Do you have any idea?