I'm building a driving simulator in VS2017 using the G29. The offcial demo can run correctly. But my code can only make LogiSteeringInitializeWithWindow() and LogiUpdate() return "TRUE". LogiGetState() and LogiGetStateENGINES() can't return any data.
I've read the code of SteeringWheelSDKDemo, but nothing I've find. Googling is so poor for the g29 wheel.
#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";
}
}
I expect there will the data of wheel, but it's 0.