Jump to content
  • Advertisement

Archived

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

The Lion King

Direct Input Problems

This topic is 5286 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 have been facing a few problems reagrding Direct Input lately, but I was able to solve them on my own accord (GOOD for me ) ... but I still want to know what I was doing wrong there, here are the problems: 1. When I try to Initialize KeyBoard (in Direct Input) it can either be for a FOREGROUND Window or a BACKGROUND Window ... the problem is that it doesn''t initialize through FOREGROUND, however, BACKGROUND works for me. Have anyone faced this sort of problem yet? But the app I am building is Windowed ... so if exiting the app is through ESC Key and it is pressed in another window, then the app will quit. I used the Active status of the Window to acquire and unacquire the Input Device to prevent the application from recieving Input if it is not Active. That solved my problem ... but why cant I initialize the Device by setting it to a FOREGROUND Window? Is there any extra stuff required? 2. When getting coordinates of the Mouse through Direct Input, it gives the movement of the Mouse Device ... not the movement or position of the cursor on the screen! Why is that? Is that useful? (I think in FPS Games) I used the Window Function GetCursorPos() to get the the current cursor position on the screen and that solved the problem. But isnt there anything for that in Direct Input? 3. I will be using Direct3D to set a cursor image for the Cursor of the app (Windowed) (in two or three days), will that effect the GetCursorPos() function for the Window or not? Thanks! Hope I explained my problems right :!

Share this post


Link to post
Share on other sites
Advertisement
1. Hmmm, normally FOREGROUND access should always be possible for the keyboard. However, i think if your app doesn''t have the focus (window in background), you wont be able to acquire the device if you set the cooperative level to foreground access. Also, you have to reacquire the device every time your window goes from backgroud to foreground (does SetCooperativeLevel fail if you try foreground access?).

2. DirectX won''t report you absolute mouse coordinates. You could keep track of them yourself by setting the pos to some known screen position at startup and then adding up all relative movements or use GetCursorPos() like you did (may be a performance hit but i don''t know).

3. Don''t know for sure, but changing the cursor image with a DX-function should not affect GetCursorPos().

Share this post


Link to post
Share on other sites
quote:
Original post by michaweyel
1. Hmmm, normally FOREGROUND access should always be possible for the keyboard. However, i think if your app doesn't have the focus (window in background), you wont be able to acquire the device if you set the cooperative level to foreground access. Also, you have to reacquire the device every time your window goes from backgroud to foreground (does SetCooperativeLevel fail if you try foreground access?).

2. DirectX won't report you absolute mouse coordinates. You could keep track of them yourself by setting the pos to some known screen position at startup and then adding up all relative movements or use GetCursorPos() like you did (may be a performance hit but i don't know).

3. Don't know for sure, but changing the cursor image with a DX-function should not affect GetCursorPos().

Thanks ... but for the first part (1) ... I am doing the samething for BACKGROUND ... I mean when the Window is not active, I have to UnAcquire the Device and when it goes back active, then I Acquire it again. Just wanna know why can't I initialize by setting it to FOREGROUND?

quote:
Original post by michaweyel
does SetCooperativeLevel fail if you try foreground access?

And YES! it fails when I set to FOREGROUND access!


[edited by - The Lion King on June 1, 2004 4:06:01 AM]

Share this post


Link to post
Share on other sites
Sorry, no clue on that...however i got it working in an app of mine, i can check it out when i get home an post my code then.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!