Skip to main content
GameDev.net gamedev.net
🔒 Locked

directx input question

Started by kevlur Feb 2, 2004 at 5:13 PM 1 replies 200+ views
Original Post
kevlur
kevlur
Hi, could someone tell me why the mouse_state change the lookatX and lookatY variables and the buffer keyboard data dont change camXpos camYpos ans camZpos variables?

char buffer[256];
DIMOUSESTATE mouse_state;	

void UpdateKeys(void)	
{
	
	HRESULT hr = g_KDIDev->GetDeviceState(256, &buffer);
}

void UpdateMouse(void)
{
	HRESULT hr = g_MDIDev->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mouse_state);

}

void Read_Input(void)
{
	  UpdateMouse();
	  UpdateKeys();

	  lookatX += mouse_state.lX * 0.005;
	  lookatY -= mouse_state.lY * 0.005;

	  if(buffer[DIK_W] & 0x80)
		  posZcam += 0.5;
	  if(buffer[DIK_S] & 0x80)
		  posZcam -= 0.5;
	  if(buffer[DIK_R] & 0x80)
		  posYcam += 0.5;
	  if(buffer[DIK_F] & 0x80)
		  posYcam -= 0.5;
	  if(buffer[DIK_A] & 0x80)
		  posXcam -= 0.5;
	  if(buffer[DIK_D] & 0x80)
		  posXcam += 0.5;
	  if(buffer[DIK_ESCAPE] & 0x80)
		  g_app_done = 1;
}
Thanks Kev
hScott
hScott
Hi!
I haven''t used DirectInput in C++ in a long while (I''ve been playing with C#), but I have a couple quick questions that may help:
1. if lookAtX and lookAtY are integral the increments will be too small to effect them.
2. What amount of change do you need to lookAtX and lookAtY to perceive a difference in your program? I ask because as I recall mouse X and Y are delta''s, not X-Y coords, so a reasonable mouse movement of around 500 pixels/sec will result in lookAtX and Y being changed by 2.5 units/sec.

When all else fails, put a text file dumper in this code and output your values as the program runs.

hScott.
hScott
hScott
hScott
Geez, I just looked at your message and code again...Are the devices acquired? Why does your question ask about camXPos etc. but the code contains posXcam etc.?
hScott.
hScott

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.