Jump to content
  • Advertisement
Sign in to follow this  
soarsky

A question about direct input.

This topic is 4860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,now I have a trouble to get mouse state: When I move the mouse slowly, it can get position well. But when I move it too quickly, it will lose some offset. What is my wrong and how to correct it? Please look at the following codes: LRESULT WINAPI MsgProc(HWND hWnd,UINT msg,WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd,msg,wParam,lParam); } INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, INT) { ... if (GameInit()) { ShowWindow(hWnd,SW_SHOWDEFAULT); UpdateWindow(hWnd); MSG msg; ZeroMemory(&msg,sizeof(msg)); while( msg.message != WM_QUIT ) { if (PeekMessage(&msg,NULL,0U,0U,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (!GameMain()) break; } GameCleanup(); } ... } bool GameMain() { ... //get device input if (pdi) { DIMOUSESTATE mouseState; if (!ReadInput(keyboardState,&mouseState)) return false; ... } //render if (GetTickCount()-iStartTime > 33) { iStartTime = GetTickCount(); if (!Render()) return false; } ... } bool ReadInput(byte *keyboardState,DIMOUSESTATE *mouseState) { ZeroMemory( keyboardState, sizeof(keyboardState) ); ZeroMemory( mouseState, sizeof(DIMOUSESTATE) ); if (FAILED(m_pMouse->GetDeviceState(sizeof(DIMOUSESTATE),mouseState))) { m_pMouse->Acquire(); return false; } ... }

Share this post


Link to post
Share on other sites
Advertisement
the reason is because there is something called the 'dead zone' (or something similar) which basically is an amount of input directinput will intentionally ignore/ for ps2 I know the default is 2% of input will be ignored because otherwise the game gets very jumpy due to any slight movement of the analog sticks. I think most people actually set the dead zone value to around 7 - 10%. there is a DirectInput function for doing this but i don't remember it off the top of my head...anyone else know it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!