STM32-X360-xinput
STM32-X360-xinput copied to clipboard
digital triggers
could you please add digital triggers?
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;
}