12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef JOYREADTHREAD_H
- #define JOYREADTHREAD_H
- #include <QThread>
- #include <QFile>
- #ifdef Q_OS_WIN
- #include "dinput.h"
- typedef bool (*LogiSteeringInitializeFunction)(bool ignoreXInputControllers);
- typedef bool (*LogiUpdateFunction)();
- //Check if a generic device at index is connected
- typedef bool (*LogiIsConnectedFunction)(const int index);
- //Get the state of the controller in the standard way.
- typedef DIJOYSTATE2* (*LogiGetStateFunction)(const int index);
- //Call this function to shutdown the SDK and destroy the controller and wheel objects
- typedef void (*LogiSteeringShutdownFunction)();
- //Play the constant force on the controller at index with the specified parameter
- typedef bool (*LogiPlayConstantForceFunction)(const int index, const int magnitudePercentage);
- //Stop the constant force on the controller at index
- typedef bool (*LogiStopConstantForceFunction)(const int index);
- #endif
- class JoyReadThread : public QThread
- {
- public:
- JoyReadThread();
- public:
- bool isOK();
- double GetWheel();
- double GetAcc();
- double GetBrake();
- int GetShift();
- private:
- void run();
- private:
- int fd;
- int axis_count;
- int button_count;
- std::string orig_name;
- QFile mxFile;
- QFile * mpFile;
- bool mbJoyOK = true;
- double mfWheel = 0;
- double mfAcc = 32767;
- double mfBrake = 32767;
- int mnShift = 0; //0 N >0 D -1 R
- private:
- #ifdef Q_OS_WIN
- LogiUpdateFunction LogiUpdate;
- LogiSteeringInitializeFunction LogiSteeringInitialize;
- LogiIsConnectedFunction LogiIsConnected;
- LogiGetStateFunction LogiGetState;
- LogiSteeringShutdownFunction LogiSteeringShutdown;
- LogiPlayConstantForceFunction LogiPlayConstantForce;
- LogiStopConstantForceFunction LogiStopConstantForce;
- void LoadAPI();
- #endif
- };
- #endif // JOYREADTHREAD_H
|