Hi,
when I scroll very fast, I have the problem that the interrupt handling is too slow. When I scroll in the opposite direction, it takes a long time (up to some seconds) until the camera moves in the opposite direction. Does anyone knows how to solve this issue?
LRESULT CALLBACK WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
{
switch(umessage)
{
// Check if the window is being destroyed.
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
// Check if the window is being closed.
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
}
// All other messages pass to the message handler in the system class.
default:
{
return ApplicationHandle->MessageHandler(hwnd, umessage, wparam, lparam);
}
}
}
LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
if(umsg == WM_MOUSEWHEEL)
{
//MessageBox(m_hwnd, L"Mouse wheel", L"Test", MB_OK);
short x = (short)HIWORD(wparam);
m_Application->HandleInterrupt(MOUSEWHEEL_ROTATED,x);
}
return DefWindowProc(hwnd, umsg, wparam, lparam);
}
void ApplicationClass::HandleInterrupt(int buttonID, int param1){
//WaitForSingleObject(InterruptMutex,INFINITE);
if(buttonID==MOUSEWHEEL_ROTATED){
if(param1<0){
targetCameraDistance+=0.5f;
if(targetCameraDistance>=m_settings->maxCameraDistance){
targetCameraDistance=m_settings->maxCameraDistance;
}
}
if(param1>0){
targetCameraDistance-=0.5f;
if(targetCameraDistance<=0){
targetCameraDistance=0;
}
}
}
//ReleaseMutex(InterruptMutex);
}
Do I need the Mutex when handling interrupts?
Greetings,
Magogan