STM32-X360-xinput icon indicating copy to clipboard operation
STM32-X360-xinput copied to clipboard

digital triggers

Open hachirokumiku opened this issue 2 years ago • 1 comments

could you please add digital triggers?

hachirokumiku avatar Oct 11 '22 11:10 hachirokumiku

I don't understand what you mean by digital triggers, do you mean something that reads the ADC value and then outputs a trigger value that is either 100% or 0% pressed? You could modify the trigger update function based on a threshold you determine..

xinput.c

#define TRIGGER_THRESHOLD 50 // Corresponds to 50/255 = 19.6% of the maximum trigger value.

/*	Update the trigger values in the packet		
*		0x00 to 0xFF
*/
void XINPUT_triggerUpdate(uint8_t triggerLeftValue, uint8_t triggerRightValue)
{
	TXData[LEFT_TRIGGER_PACKET] = triggerLeftValue > TRIGGER_THRESHOLD ? 255 : 0;
	TXData[RIGHT_TRIGGER_PACKET] = triggerRightValue> TRIGGER_THRESHOLD ? 255 : 0;
}

TannerHollis avatar Jan 08 '24 22:01 TannerHollis