I tried it and hresult equals to "Something Else"
void Activate()
{
if(g_pWheelHandler == NULL)
{
g_pWheelHandler = new bw::WheelHandler();
}
try
{
g_pWheelHandler->Init();
SetTimer(hWindow, 1, 5000, NULL);
hDebugWindow = CreateWindow(L"EDIT",ClassDebug,WS_DLGFRAME|ES_MULTILINE,CW_USEDEFAULT,CW_USEDEFAULT,300,300,hWindow,NULL,hInst, NULL);
SetWindowText(hDebugWindow,L"");
memset(strDebugBuf,0,1024);
ShowWindow(hDebugWindow,1);
}
catch(std::exception& ex)
{
MessageBox(hWindow, CA2CT(ex.what()), L"ERROR", MB_ICONSTOP);
}
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
/* .... */
case WM_TIMER :
{
if(rangeIdx == sizeof(ranges) / sizeof(ranges[0]))
{
rangeIdx = 0;
}
try {
g_pWheelHandler->SetRange(ranges[rangeIdx]);
}
catch(std::exception &ex)
{
MessageBox(hWindow, CA2CT(ex.what()), L"ERROR", MB_ICONSTOP);
}
rangeIdx++;
}
default: return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
WheelHandler::WheelHandler(void)
: m_pControllerInput(NULL),m_pWheel(NULL)
, m_iOldRange(0)
{
}
// get handle of LFS window
HWND WheelHandler::GetLFSWindow(void)
{
HWND hwnd = FindWindow(L"LFS", NULL);
if(hwnd == NULL)
{
throw std::exception("LFS window not found");
}
return hwnd;
}
// initialise wheel member
void WheelHandler::InitWheel(void)
{
HWND hLFSWindow = this->GetLFSWindow();
this->m_pControllerInput = new LogitechControllerInput::ControllerInput(hLFSWindow, TRUE);
this->m_pWheel = new LogitechSteeringWheel::Wheel(this->m_pControllerInput);
}
// initialise class
void WheelHandler::Init(void)
{
this->Close();
this->InitWheel();
this->m_iOldRange = this->GetRange();
}
// set the wheel range
void WheelHandler::SetRange(int _range)
{
if(_range < 40 || _range > 900)
{
throw std::exception("Argument out of Range");
}
LogitechSteeringWheel::ControllerPropertiesData propertiesData_;
ZeroMemory(&propertiesData_, sizeof(propertiesData_));
this->Update();
if (!this->m_pWheel->IsConnected(0))
{
throw std::exception("No wheel connected");
}
if(!this->m_pWheel->GetCurrentControllerProperties(0, propertiesData_))
{
// default properties
}
propertiesData_.wheelRange = _range;
this->m_pWheel->SetPreferredControllerProperties(propertiesData_);
this->Update();
HRESULT hRes = this->m_pWheel->PlayLeds(0, 2000.0, 1000.0, 2000.0);
switch(hRes)
{
case 0x80070005:
//MessageBox(NULL, NULL, L"E_ACCESSDENIED", NULL);
Debug(L"E_ACCESSDENIED");
break;
case 0x80004001:
//MessageBox(NULL, NULL, L"E_NOTIMPL", NULL);
Debug(L"E_NOTIMPL");
break;
default:
//MessageBox(NULL, NULL, L"Something else has happened", NULL);
Debug(L"Something else has happened");
}
}
for(int wheelIdx = 0; wheelIdx< LG_MAX_CONTROLLERS; wheelIdx++)
for(int wheelIdx = 0; wheelIdx< LG_MAX_CONTROLLERS; wheelIdx++)