WM_KEYDOWN and WM_KEYUP message or GetAsyncKeyState() Function

closed account (z1CpDjzh)
Hi, i want to make this program which sends to a server A was key B held or just pressed so that Server A can determine whenever to do Function C or D.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	// sort through and find what code to run for the message given
	switch(message)
	{
	case WM_KEYDOWN:
                RECORDTIME();//GET TIME OF PRESS AND SAVE TO VAR
                SENDKEYPRESS();//SEND VAR
		return 0;
		break;

		//WINDOW CLOSED
	case WM_KEYUP:
                GETCURRENTTIME();//GET TIME OF RELEASE OF KEY
                SENDKEYLIFT();//SEND THAT VAR
		return 0;
		break;
	}

The code above me is going to have a issue... i am going to use the UDP protocol because i am going to send lots of these messages but what happens if Server a never got the Key Release Message or the key down Message.
1
2
3
4
5
while(GetAsyncKeyState(VK_SOMEKEY))
    {
     SENDKEYDOWN();//Sends key down message to server   
    }

but what happens if UDP drops a message... wont it be classified as 2 diff key presses.


...OH and this is going to be a game so if i use TCP the Latency will be enourmous
Last edited on
closed account (z1CpDjzh)
Hello?
Topic archived. No new replies allowed.