Mouse/keyboard movement without DirectX?
NeHe uses dinput.h in lesson23 to enable camera rotation with the mouse. Surely there must be a way to do this without using DirectX?
You could always use Windows to do that type of thing.
For the keyboard, you can use WM_KEYDOWN/WM_KEYUP and for the mouse you can use WM_MOUSEMOVE. WM_KEYDOWN/WM_KEYUP supply you with the key that is currently down/up, whereas WM_MOUSEMOVE tells you the x/y coordinates of the mouse, as well as some additional information such as which mouse keys are pressed, etc.
Hope this helps!
-------------------------------
"Mind your own damn business!!!" - Gladiator
..-=gLaDiAtOr=-..
For the keyboard, you can use WM_KEYDOWN/WM_KEYUP and for the mouse you can use WM_MOUSEMOVE. WM_KEYDOWN/WM_KEYUP supply you with the key that is currently down/up, whereas WM_MOUSEMOVE tells you the x/y coordinates of the mouse, as well as some additional information such as which mouse keys are pressed, etc.
Hope this helps!
-------------------------------
"Mind your own damn business!!!" - Gladiator
..-=gLaDiAtOr=-..
November 25, 2000 09:08 AM
Blagodarya, Gladiator. Do you know of any working code examples using WM_MOUSEMOVE in a 3d game? That would be very helpful. Thanks again.
I used that once, pretty easy but its just a hack![](smile.gif)
void c_world::mmove(int dx, int dy)
{
yrot-=(100-dx)*0.05f;
xrot+=(100-dy)*0.05f;
SetCursorPos(100,100);
while (yrot > 360) yrot -= 360;
while (yrot < 0) yrot += 360;
}
void c_world::Update()
{
POINT p;
GetCursorPos(&p);
mmove(p.x, p.y);
...
this updates the globals yrot and xrot
I know its a complete hack but it works like a charm:p
![](smile.gif)
void c_world::mmove(int dx, int dy)
{
yrot-=(100-dx)*0.05f;
xrot+=(100-dy)*0.05f;
SetCursorPos(100,100);
while (yrot > 360) yrot -= 360;
while (yrot < 0) yrot += 360;
}
void c_world::Update()
{
POINT p;
GetCursorPos(&p);
mmove(p.x, p.y);
...
this updates the globals yrot and xrot
I know its a complete hack but it works like a charm:p
One thing to keep in mind is that there is nothing wrong with using DirectX; the DX API is specifically designed with input, sound, graphics, and networking acceleration in mind, so it''s ideal for designing games or other multimedia software. In fact, a combination of DX and OpenGL (OpenGL for 3D rendering, obviously, and DX for the networking, input, and sound components) would make for a very efficient and speedy game. ![](smile.gif)
The only drawback to DX, of course, is its inherent non-portability. heh But any serious game company will tell you that it is important to know and use DX because over 90% of the world uses Windows 9x, 2k, Me, or NT Operating Systems.
Just my two cents on the topic... That hack that fenrir provided does work quite well, though....![](wink.gif)
--David
![](smile.gif)
The only drawback to DX, of course, is its inherent non-portability. heh But any serious game company will tell you that it is important to know and use DX because over 90% of the world uses Windows 9x, 2k, Me, or NT Operating Systems.
Just my two cents on the topic... That hack that fenrir provided does work quite well, though....
![](wink.gif)
--David
try someit like this once every frame
left_mouseButton = UNPRESSED;
right_mouseButton = UNPRESSED;
GetCursorPos(&mousePOS);
result = GetAsyncKeyState(VK_LBUTTON);
if (result&0x10000000) left_mouseButton = PUSHED;
result = GetAsyncKeyState(VK_RBUTTON);
if (result&0x10000000) right_mouseButton = PUSHED;
http://members.xoom.com/myBollux
left_mouseButton = UNPRESSED;
right_mouseButton = UNPRESSED;
GetCursorPos(&mousePOS);
result = GetAsyncKeyState(VK_LBUTTON);
if (result&0x10000000) left_mouseButton = PUSHED;
result = GetAsyncKeyState(VK_RBUTTON);
if (result&0x10000000) right_mouseButton = PUSHED;
http://members.xoom.com/myBollux
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement