Skip to main content
gamedev.net
🔒 Locked

Getting some kb input without dinput

Started by MichaelNolan 7 replies 450+ views
Original Post
MichaelNolan
MichaelNolan
Hey, I''m just trying to gain some keyboard input but i don''t know how to do this in Borland builder 4. Dinput8 will not work and when i use the vcl TControl or object (one of them) it gives me hundreds of keys being pressed and i don''t even want to use that. Is there any other API, source, something that can simply get some info from my keyboard? Michael
Mike
MichaelNolan
MichaelNolan
Hi,

i''ve heard of it, i thought it was just a graphics library.
Mike
blizzard999
blizzard999
If you need only Keyboard/mouse input the solutions are very easy...I never used Borland compiler but I think that if you can compile Win32 apps you have no problem.

1) First solution : (syncronous)

// NOTE: the code is based on Nehe Lesson01 !!!

// global
BYTE keys[256]

// Window Procedure
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)

{
switch (uMsg)
{
...
case WM_KEYDOWN:
{
keys[wParam] = TRUE;
return 0;
}

case WM_KEYUP:
{
keys[wParam] = FALSE;
return 0;
}
...

}

return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

In your rendering/idle function you simply check the key with something like this

if(keys[VK_LEFT] == TRUE)
GoLeft();




2) Asyncronous: it is based on GetKeyboardState()...but the first solution is very simple and easy to use...

And for mouse simply
POINT pt;
GetCursorPos(&pt);

Or you can use WM_MOUSEMOVE in the WndProc
For the buttons...WM_LBUTTONDOWN,WM_LBUTTONUP,...






MichaelNolan
MichaelNolan
1 prob,
in builder (not borland c), you do not have WinProc''s.

MICHAEL NOLAN
Mike

Topic Locked

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

Sign in to reply to this topic.