Sign in to follow this  
phil67rpg

mouse input

Recommended Posts

Manill66    261
Use SFML! It's great and you can use it for commercial use if you want to! It also includes sounds and I forget if it includes anything else. It is also free. I also found a pong tutorial with SFML!

Website: http://www.sfml-dev.org/
Licensing: http://www.sfml-dev.org/license.php
Pong Tutorial: http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx

Share this post


Link to post
Share on other sites
superman3275    2061
[quote name='phil67rpg' timestamp='1351128446' post='4993617']
I am using dx9
[/quote]
Yes, however normally people who use DirectX or OpenGL use SFML, Allegro, or SDL for input because it's easier. It's really your choice however. I'd recommend either using Allegro or SDL, because with SFML you have to do a lot of extra stuff to capture input with it. You can either use Direct Input or an Input Library, with the latter being easier. If you're main goal is to learn all about DirectX however, you can use Direct Input.

Share this post


Link to post
Share on other sites
superman3275    2061
Well if you want to learn DirectX strictly then using Direct Input would be your best bet. Later on if it gets too difficult you can progress to an Input Library, but you seem smart enough to be able to handle Direct Input :)!

Share this post


Link to post
Share on other sites
phil67rpg    443
I am getitng the following error.
1> c:\program files\microsoft directx sdk (june 2010)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
do I need to include an older sdk for dx.

Share this post


Link to post
Share on other sites
superman3275    2061
[url="http://www.directxtutorial.com/Tutorial9/E-GameInput/dx9E.aspx"]This[/url] is a great tutorial. It talks about how to get all types of input and how to apply them to game development.
About the error, you need:
[CODE]
#define DIRECTINPUT_VERSION 0x0900
[/CODE]
When it says it's defaulting to 0x0800, it means it's defaulting to DirectX 8 input (Notice the 800 instead of 900).
if the above code doesn't work, then just use this:
[CODE]
#define DIRECTINPUT_VERSION 0x0800
[/CODE] Edited by superman3275

Share this post


Link to post
Share on other sites
phil67rpg    443
I have an error using dx8 and dx9.
c:\program files\microsoft sdks\windows\v7.0a\include\objidl.h(11280): error C2061: syntax error : identifier '__RPC__out_xcount_part'
1>c:\program files\microsoft sdks\windows\v7.0a\include\objidl.h(11281): error C2059: syntax error : ')'
1>c:\program files\microsoft sdks\windows\v7.0a\include\objidl.h(11281): fatal error C1903: unable to recover from previous error(s); stopping compilation
1>
I am really lost on this one.

Share this post


Link to post
Share on other sites
superman3275    2061
Did you install the DirectX SDK? If the DirectX SDK was installed after the Windows SDK, the DirectX \include directory will come before the Windows SDK \include directory in your PATH. This means that Visual Studio will be build with the version of objidl.h that ships in the DirectX SDK. You must build with the version of objidl.h that ships in the Windows 7 SDK.

Look at your VC++ Directory Settings in VS and see if the Windows SDK include path (C:\Program Files\Microsoft SDKs\Windows\v7.0\Include) is at the top of the list. This will make Visual Studio use the SDK resources first. You should also change the settings for the Executable and Library directories, so that the Windows SDK directories are at the top.

To change the directories, in Visual Studio IDE, go to Tools, Options, Projects and Solutions, VC++ Directories. Edited by superman3275

Share this post


Link to post
Share on other sites
Khatharr    8812
You can take a look at something I posted a while back. The Input namespace is implemented using DirectInput. It's a bit of a mess since it does some stuff like key-mapping and abstraction, but you should be able to just look over the "initialize" and "update" functions and the mouse related functions and see how to set it up and read mouse input.

Here's a link to the project:

[url="http://www.gamedev.net/index.php?app=core&module=attach&section=attach&attach_id=10098"]http://www.gamedev.n...attach_id=10098[/url]

Please note that I wrote this a while back and I've learned a lot of important stuff since then, so don't think that this is actually good code. It's not horrible, but it's not designed at a professional level either. It's just an example of the basic underlying procedure. The files you want in the archive are "Bricks/Bricks/ns_Input.h" and "Bricks/Bricks/ns_Input.cpp".

Hope that helps. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Khatharr

Share this post


Link to post
Share on other sites
Evil Steve    2017
Nooooooooooooo! Never use DirectInput for keyboard or mouse input. Just use WM_MOUSEMOVE, WM_LBUTTONDOWN and so on.

Using DirectInput will remove pointer ballistics, which will make your mouse pointer feel extremely sluggish. It's also hundreds of lines of code to set up and use, where as window messages are "free". And finally, it's actually slower than using window messages - DirectInput spawns another thread to process raw input messages, meaning it has a higher overhead.

If you're just doing this to learn DirectInput, then go ahead - but never use DirectInput for keyboard or mouse input in a shipping product.



EDIT: From here: http://msdn.microsoft.com/en-us/library/ee418864.aspx:


Summary

Overall, the best method to receive high-definition mouse movement data is WM_INPUT. If your users are just moving a mouse pointer, then consider using WM_MOUSEMOVE to avoid needing to perform pointer ballistics. Both of these window messages will work well even if the mouse isn't a high-definition mouse. By supporting high definition, Windows games can offer more precise control to users.
Edited by Evil Steve

Share this post


Link to post
Share on other sites
Debunez    160
Why use direct input??? Wouldnt it be better to just get the mouse location and button state from wParam and lParam from the Windows message function??? I dont see why you'd ever want to use direct input for something that doesn't require it at all. Edited by Debunez

Share this post


Link to post
Share on other sites
Manill66    261
[quote name='phil67rpg' timestamp='1351286798' post='4994265']
how do I start to use windows message to interact with my mouse
[/quote]

http://bit.ly/TL3Zd3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this