Hello,
Does anyone know about the Xinput Library.
[GitHub - dmadison/ArduinoXInput: XInput library for USB capable Arduino boards]GitHub - dmadison/ArduinoXInput: XInput library for USB capable Arduino boards)
I have a rotary encoder but want to do the Dpad assignment for left and right with this encoder. So one click around to the left or one click around to the right.
The encoder software works in the monitor without problems,
only the X360 controller as Dpad does not always recognize the steps. Can this be a time problem? But I've already taken pause and tried the whole thing with XInput.release (DPAD_LEFT).
I've tried this a lot but somehow can't get any further.
Can me Help? Sorry for my english. ![]()
#include <XInput.h>
#include <ClickEncoder.h>
#include <TimerOne.h>
#include <MD_REncoder.h>
#include <JC_Button.h>
const boolean UseTriggerButtons = true; // set to false if using analog triggers
unsigned long previousMillis = 0;
const long interval = 1000;
ClickEncoder *encoder;
int16_t last, value;
void timerIsr() {
encoder->service();
}
void setup() {
//Serial.begin(9600);
encoder = new ClickEncoder(0, 1, 4, 4);
Timer1.initialize(100);
Timer1.attachInterrupt(timerIsr);
last = -1;
XInput.setAutoSend(true); // Wait for all controls before sending
XInput.begin();
}
void loop() {
unsigned long currentMillis = millis();
value += encoder->getValue();
if (value > last)
{
encoderLEFT();
Pause_encoderLEFT();
}
if (value < last)
{
encoderRIGHT();
Pause_encoderRIGHT();
}
last = value;
}
void encoderLEFT(){
XInput.setButton(DPAD_LEFT, 1);
}
void encoderRIGHT(){
XInput.setButton(DPAD_RIGHT, 1);
}
void Pause_encoderLEFT(){
XInput.setButton(DPAD_LEFT, 0);
}
void Pause_encoderRIGHT(){
XInput.setButton(DPAD_RIGHT, 0);
}