Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

+AA_970+

direct input and the mouse

This topic is 6653 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, i just added support for the mouse in direct input for my game but i don''t know if what i''m doing is a good & efficient way of doing things. Ok, i''ll explain what i''m doing: first, i coded a way to get the coordinates of the mouse (since dinput only gives relative coordinates )and control the coordinates so they don''t go beyond the screen. After i did this i wanted a mouse cursor so within my game loop i drew a bitmap that i wanted for my cursor at the mouse coordinates. Now i want a way to adjust the sensitivity, i''m unsure about this but what i''m currently doing is multiplying the relative coordinates of the mouse by a value and then adding the resulting # to the current coordinates. Well that''s what i came up with, can someone tell me if this is a good way of handling mouse support or is one or more of my methods inefficient?

Share this post


Link to post
Share on other sites
Advertisement
That is how I do it. Just to let you know., I think it is almost impossible to imitate the Windows/Mac mouse with DInput. If someone knows how to imitate it(using DInput), I''d like to see how.

Share this post


Link to post
Share on other sites
It seems OK to me.

You may want to add acceleration to the mouse, so that the sensitivity is low when the user start moving and then grows as he continue to move the mouse.

Also if you have low frame rate on your game you will get very choppy movement of the mouse. If this ever happens you may consider moving the mouse handling routine to a separate thread. (Read this to learn how). Personally I wouldn't use multiple threads unless absolutely necessary.

Edited by - Spellbound on 3/9/00 6:20:50 AM

Share this post


Link to post
Share on other sites
A bit Delphi Code :-)

Get the Mouse-Parameters of windows
SystemParametersInfo(SPI_GETMOUSE, 0, @WinMouseParam, 0);

then read DInput
DirectInputDevice7_Mouse.GetDeviceState(SizeOf(DIMouseState), @DIMouseState);

later

with WinMouseParam,MousePos do
begin
case speed of
1 : with DIMouseState do
begin
if Abs(lX) > threshold1 then Inc(x, 2 * lX) else Inc(x, lX);
if Abs(lY) > threshold1 then Inc(y, 2 * lY) else Inc(y, lY);
end;
2 : with DIMouseState do
begin
if Abs(lX) > threshold2 then Inc(x, 4 * lX) else
if Abs(lX) > threshold1 then Inc(x, 2 * lX) else
Inc(x, lX);
if Abs(lY) > threshold2 then Inc(y, 4 * lY) else
if Abs(lY) > threshold1 then Inc(y, 2 * lY) else
Inc(y, lY);
end;
else with DIMouseState do
begin
Inc(x, lX);
Inc(y, ly);
end;
end;

Well thats it
-crent-

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!