0

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?

  • Do you plan on creating your own game or do you want your joystick to work with existing games? – Jonathan S. Nov 3 '17 at 16:02
  • existing games, like dirt 4 or F1 2017 – Andrea Mancini Nov 4 '17 at 18:27
0

That library has no support for vibration.

The HID report descriptor has to include the correct OUTPUT items for the PC to send the vibration instructions to the Arduino - and of course the library has to be able to handle that incoming data - none of which is implemented.

So you can't unless you massively expand that library. And that takes intimate knowledge of USB and HID protocols.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.