2

我正在使用 G29 在 VS2017 中构建一个驾驶模拟器。官方demo可以正常运行。但我的代码只能使 LogiSteeringInitializeWithWindow() 和 LogiUpdate() 返回“TRUE”。LogiGetState() 和 LogiGetStateENGINES() 不能返回任何数据。

我已经阅读了 SteeringWheelSDKDemo 的代码,但没有找到任何东西。对于 g29 车轮,谷歌搜索非常糟糕。

#include <iostream>
#include <stdio.h>
#include "map"
#include "string"
#pragma comment(lib, "LogitechSteeringWheelLib.lib")
#include "LogitechSteeringWheelLib.h"


int main()
{
    DIJOYSTATE2 *controller_state = NULL;
    DIJOYSTATE2ENGINES  *last_state = NULL;
    std::map<std::string, int> current_state_map;
    int controller_idx = 0;
    HWND h_wnd = FindWindow(_T("ConsoleWindowClass"), NULL);
    while (!LogiSteeringInitializeWithWindow(true, h_wnd)) {
        printf("try again.\n");
    }
    while (true) {
        if (!LogiUpdate()) {
            continue;
        }

        while (LogiIsConnected(controller_idx)) {
            std::cout << LOGI_MAX_CONTROLLERS << std::endl;
            wchar_t deviceName[128];
            LogiGetFriendlyProductName(controller_idx, deviceName, 128);
            std::cout << deviceName << std::endl;
            std::cout << "wheel " << LogiIsDeviceConnected(controller_idx, LOGI_DEVICE_TYPE_WHEEL) << std::endl;
            std::cout << "Joystick " << LogiIsDeviceConnected(controller_idx, LOGI_DEVICE_TYPE_JOYSTICK) << std::endl;

            controller_state = LogiGetState(controller_idx);
            last_state = LogiGetStateENGINES(controller_idx);
            std::cout << "-------------" << std::endl;
            std::cout << controller_state->lX << std::endl;
            std::cout << controller_state->lY << std::endl;
            std::cout << controller_state->lRz << std::endl;
            std::cout << "-------------" << std::endl;
            std::cout << last_state->lX << std::endl;
            std::cout << last_state->lY << std::endl;
            std::cout << last_state->lRz << std::endl;
            std::cout << "-------------" << std::endl;
            system("cls");

        }
        std::cout << "unconnected\n";
    }

}

我希望会有轮子的数据,但它是0。

4

0 回答 0