我正在使用G29在VS2017中构建驾驶模拟器。官方演示可以正常运行。但是我的代码只能使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";
}
}
我希望会有wheel的数据,但是它是0。