ArduinoXInput icon indicating copy to clipboard operation
ArduinoXInput copied to clipboard

Rumble/ Forcefeedack

Open NafisAhnnaf opened this issue 1 year ago • 1 comments

No Rumble data or forcefeedback data is being received by the callback function. Is anyone facing a similar issue? Using Arduino Micro.

xbox.setReceiveCallback(rumbleCallback);

Is this line of code enough to receive callback data. I mean in my pc the controller is working fine but there is no forcefeedback feature being shown. I am assuming more initialization codes need to be written in setup() to actually innitiate rumble feature. Also Is there any necessity of a receive() function in void loop() to look for async callbackks or rumble data.?

#The callback function.

int rumble;
void rumbleCallback(uint8_t packetType) {
	// If we have an LED packet (0x01), do nothing
	if (packetType == (uint8_t) XInputReceiveType::LEDs) {
		return;
	}
	// If we have a rumble packet (0x00), see our rumble data on the LED
	else if (packetType == (uint8_t) XInputReceiveType::Rumble) {
		uint8_t rumbleValue = xbox.getRumbleRight();
		rumble = rumbleValue; 
	}
}

NafisAhnnaf avatar Aug 15 '24 01:08 NafisAhnnaf

What is xbox?

The library is meant to be used with the global XInput object. The callback from the USB handler calls XInput.receive(), other class instances will not receive data. If you want to use your own object for whatever reason, you will need to set the callback for the USB API (XInputUSB::setRecvCallback()) to a function that then calls XInputController::receive() in order to parse the data. If you want you can also bypass the library entirely and parse the data yourself, again using the lower level USB API.

It is not necessary to do anything in loop() to handle the data if you are using the callbacks.

dmadison avatar Aug 15 '24 06:08 dmadison