Sign in to follow this  

A question about direct input.

This topic is 4679 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
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

This topic is 4679 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this