Recommended Posts

Ok I have already set up my system to use DirectInput. But why do all the examples use a Char to get the state instead of just a bool? There must be an extended functionalty other then...

#define KEYDOWN(name, key) (name[key] & 0x80)

so what else can I do with the Keyboard and DirectInput? If it matters I'm using the buffered input and also using a proprietary "Stuttered" input system (so if you hold down it only changes the state of the menu every 15 frames currently)?
And I'm planning on using Mouse and Joystick So I have two more questions
With the mouse, how do I get it to use absolute? (or tell me where it'se clicking) I know I can control it by reading in the relative device (and it meantions an absolute option) but I didn't see a way to set it up that way in the tutorial. (Also that's absolute of the window I'm using, not the desk top right?) I have a feeling that the realtive might cause more problems then just getting absolute coordanates if I can do that reasonably, especially if there's a problem with the buffer? or at least a way I can get the absolute once in a while.
Finally It appears to have a way for multiple joysticks to be enumerated so I'll have to use my SetWindowLong trick, Assuming i've used it once before is the correct getwindowlong as follows

I'm quite confused about what happens here? (isn't it a constant check if a joystick is plugged in?) If the constant check is set off by a joystick added to the system (or is in the system) then It's passed on, what happens if I don't create a device (because I'm pretty sure I want to only have X amount of joysticks applicable) will the DirectInput know that I already "saw" the joystick or will it try to force itself on me again?
so basically to sum up the questions were.
1.) Where else other then KEYDOWN can I do with a keyboard input?
2.) How does one get the absolute coordinates of a Mouse in the game window to base the realtivistic cooridenates on, or how does one get DirectX to only use absolutes (it's said to be able to but the tutorials don't meantion how to set htat)
3.) that whole odd thing about the Joysticks, and how many should I allow myself to use? (I assume if I try to create a device over an old device I'd only get the new device and the old joystick would become "lost")

2.) How does one get the absolute coordinates of a Mouse in the game window to base the realtivistic cooridenates on, or how does one get DirectX to only use absolutes (it's said to be able to but the tutorials don't meantion how to set htat)

1) If you're using buffered input, then the 0x80 value indicates a keydown, but it will also send a 0x00 value when the key is raised. Can be very useful.

2) I'm not sure about setting up DInput to handle absolutes for you, but I always had a "mouse_x" and "mouse_y" coordinate stored internally that I added the relative offset to each time a mouse event occured. You can use the normal Win32 calls to determine what your inital values are when the game loads up.

Not sure about Q3, I don't tend to deal with joysticks with my engine [smile].

hthJack

0

Share this post

Link to post

Share on other sites

1. so 0x00 is good for Buffered, That'll help. (I actually was using immediate accidently, time to try the other)

2. It appears that I don't need DirectInput technically for this (especially because you can scroll off the screen, and it'll get confused easily I think) (of course Directinput documentation meantions absolute coords so maybe there's a way) So I might use a mixture of the Directinput for tests, and the windows API for the location (at least for the menu). At least until I'm ready to make me own cursors, and have the a better handle on the GUI. (which at first is a huge task but actually seems almost simple, though I have to get the pixel numbers correct)

3. I still need a little advice here, I want to allow the MOST amount of people to play, We're looking at up to four players, but I would like to know a little more about exactly how this should work (and how I can make it so the joysticks gets added but not need a large array of Joystick devices.

I must say, the graphics system seems almost simple compared to the audio and direct input setup. Though it's somewhat straight forward after you understand it. I am loving learning by doing, it's a great feeling for coding.

0

Share this post

Link to post

Share on other sites

Original post by kinglink2. It appears that I don't need DirectInput technically for this (especially because you can scroll off the screen, and it'll get confused easily I think) (of course Directinput documentation meantions absolute coords so maybe there's a way) So I might use a mixture of the Directinput for tests, and the windows API for the location (at least for the menu). At least until I'm ready to make me own cursors, and have the a better handle on the GUI. (which at first is a huge task but actually seems almost simple, though I have to get the pixel numbers correct)

Your strategy of mixing the two won't necessarily work. By all means try it, but there are certain combinations of cooperative level flags that will stop Windows from knowing anything about the location/state of the mouse and keyboard. In this instance, you'll either want a different configuration or use one or the other (not both).

hthJack

0

Share this post

Link to post

Share on other sites

I'm likely going to use Non Exclusive, (as I'm wanting the mouse to show up) and Foreground. from what I understand this should allow all applications to use the cursor and this program to only use the cursor when this program is in the scope of the os? or would that interfer with the the Windows API and I should investigate making my own cursor?