Explorar o código

change testg29_win. api load ok.

yuchuli %!s(int64=2) %!d(string=hai) anos
pai
achega
1798b366ca
Modificáronse 2 ficheiros con 46 adicións e 1 borrados
  1. 30 1
      src/test/testg29_win/mainwindow.cpp
  2. 16 0
      src/test/testg29_win/mainwindow.h

+ 30 - 1
src/test/testg29_win/mainwindow.cpp

@@ -7,7 +7,7 @@
 
 void MainWindow::LoadAPI()
 {
-    std::cout<<"Load Excel API"<<std::endl;
+    std::cout<<"Load Logi g29 API"<<std::endl;
     QLibrary xlib("./LogitechSteeringWheelEnginesWrapper.dll");
     if(!xlib.load())
     {
@@ -25,6 +25,33 @@ void MainWindow::LoadAPI()
     {
         std::cout<<" Load API Successfully. "<<std::endl;
     }
+
+    LogiSteeringInitialize =(LogiSteeringInitializeFunction)xlib.resolve("LogiSteeringInitialize");
+    LogiIsConnected =(LogiIsConnectedFunction)xlib.resolve("LogiIsConnected");
+    LogiGetState =(LogiGetStateFunction)xlib.resolve("LogiGetState");
+    LogiSteeringShutdown =(LogiSteeringShutdownFunction)xlib.resolve("LogiSteeringShutdown");
+
+    if((LogiSteeringInitialize == NULL)||(LogiIsConnected == NULL)||(LogiGetState == NULL)||(LogiSteeringShutdown == NULL))
+    {
+        std::cout<<" no this apiS."<<std::endl;
+    }
+    else
+    {
+        std::cout<<" Load All API Successfully. "<<std::endl;
+    }
+}
+
+int MainWindow::GetWheelAccBrake(double & angle,double & acc, double & brake)
+{
+    if((LogiUpdate())&&(LogiIsConnected(1)))
+    {
+        DIJOYSTATE2* wheel = LogiGetState(1);
+        angle = wheel->lX;
+        acc = wheel->lY;
+        brake = wheel->lRz;
+        return 0;
+    }
+    return -1;
 }
 
 MainWindow::MainWindow(QWidget *parent)
@@ -34,6 +61,8 @@ MainWindow::MainWindow(QWidget *parent)
     ui->setupUi(this);
 
     LoadAPI();
+
+    LogiSteeringInitialize(true);
 }
 
 MainWindow::~MainWindow()

+ 16 - 0
src/test/testg29_win/mainwindow.h

@@ -3,12 +3,23 @@
 
 #include <QMainWindow>
 
+#include <dinput.h>
+
 QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow; }
 QT_END_NAMESPACE
 
 
+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)();
 
 
 class MainWindow : public QMainWindow
@@ -25,9 +36,14 @@ private:
 private:
 
     LogiUpdateFunction LogiUpdate;
+    LogiSteeringInitializeFunction LogiSteeringInitialize;
+    LogiIsConnectedFunction LogiIsConnected;
+    LogiGetStateFunction LogiGetState;
+    LogiSteeringShutdownFunction LogiSteeringShutdown;
 
 
 private:
     void LoadAPI();
+    int GetWheelAccBrake(double & whell,double & acc, double & brake);
 };
 #endif // MAINWINDOW_H