c/c++: why do i do not have input?

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
ben0bi
Posts: 11
Joined: Tue Oct 23, 2007 2:15 am

c/c++: why do i do not have input?

Post by ben0bi »

hello,

i wrote an interface in c/c++ for the "small" spacemouse

i used the code from the pollcube example in VS C/C++ 2005 Environment.

all works but it does not work. it initializes and de-initializes but there is no input from the mouse. :(

i am in a programming course and even my tutors cannot tell me whats wrong, it seems all to be done fine.

the poll-example works, its not the mouse or the driver...

can you please look at my code and tell me EXACTLY what to do to bring this to work? and send me the code back if possible, per email to benjaeggi@gmail.com

i made a thread in the german forum, too

you can download my project here:
http://dashandelsimperium.de/3DMouseTest.rar

regards,
benedict jaeggi
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Topic moved

Post by UtaSH »

Moved this to the Developer's Forum for Windows as it is a developer specific question.
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi ben0bi,

I believe you're developing a C/C++ application using the 3DxInput interface to receive data from 3D mice.

A couple of points to check: your applications needs to have a message pump (it cannot be a console application). Also make sure you register a call-back to receive events from the device.

Compare your code to the samples. Trace it and try to understand why the information is not being received.

Just telling you exactly what is wrong would be no fun, right? :wink:
Nuno Gomes
ben0bi
Posts: 11
Joined: Tue Oct 23, 2007 2:15 am

Post by ben0bi »

whats that for an answer "would be just no fun"

if you cannot give away some good api documentation, you do not have to wonder why no one codes some plugins for your hardware.

i am very angry about this, i just want a fuckin interface and all you say is "..would be just no fun"...

you call that "help"?

you want the mouse used in games, so help us game developers to use it.
or make an interface yourself, i am bored to search your shit sample code for the relevant code.

and if you noticed, not every game has this fuckin message bump, there are other, faster loops we prefer...

i can say you, even if i use a message bump, it will not work. i can see it. and what then? will you then say: "find out yourself, its fun"

ITS NO FUN AT ALL.

sorry but i cannot understand why you do not help in a normal way like programmers should help each other....
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi ben0bi,

We're here to help but we cannot review an application. My remark was just a way of telling you that expecting someone to review your code and provide an exact answer is not reasonable. It was done in good spirits. It was certainly not meant to offend and 3Dconnexion is very much appreciative of any work that is done to support 3D mice. I think you'll find plenty of examples of just that if you look elsewhere on this Forum.

Going back to the real problem, have you considered my suggestion to check if your application has a message pump?

Developing applications is all about following a systematic process. You say the demo work. Have you used that sample as a base for your application?

If your application has no message pump, then you need to use an alternative API. If you're developing games and understand DirectX well enough, I suggest you look there since 3D mice are natively supported in DirectInput.

Other interfaces are Raw Input (Microsoft Win32 API but requires a message pump) and direct access to the HID data on the USB stack, very powerful and complex interface but it does not require a message pump.
ben0bi
Posts: 11
Joined: Tue Oct 23, 2007 2:15 am

sorry

Post by ben0bi »

i am sorry about this angry post.

look, i wanted to do this with the demo source code. but there are so much not-relevant things, where should i know what i need and what not?

i had to find out myself how to setup this atl or com things to use this comptr and so on.

i only want to do a simple interface class, wich initializes itself on a global instance where i can get all properties of the mouse over an update function.

this update function should be useable with or without this windows msg bump....

this interface should be as global as possible to use it in whatever application i want. i wanted to do a zbrush plugin and i wanted to use it in several games...

you telled anything about DirectInput for 3d mice. i think this will be the best solution, no msg bump and directly for games...can you possibly link me to a post where i can find further information? we are in directx now, gfx stuff, but i think input stuff will be handled not so much other than other things in DX...

do i have to use then the directx api without the 3dconnex api or both?

thanks for your help.
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: sorry

Post by ngomes »

Hi ben0bi,
i am sorry about this angry post.
No worries. I've been in your shoes many times (tight schedule, not enough time to complete all my assignments, exams).
Like I wrote before, we are here to help as much as we can.
look, i wanted to do this with the demo source code. but there are so much not-relevant things, where should i know what i need and what not?
The demos are pretty straight forward. If you're into C# and .Net development, the C#/XNA is really very small.
i only want to do a simple interface class, wich initializes itself on a global instance where i can get all properties of the mouse over an update function.
That's fine. Sounds like the sort of stuff I would do.
this update function should be useable with or without this windows msg bump....
That's a limitation that we would like to remove but let's face it: how much of problem is that, really? All applications using 3D mice are graphic. Plenty of windows and message loops all around.
Currently, it is not possible to use the 3DxInput interface in console applications.
My suggestion is for you to create a test app using a skeleton "windows" application. That's easy enough to do with the VS2005 app wizard.
you telled anything about DirectInput for 3d mice. i think this will be the best solution, no msg bump and directly for games...can you possibly link me to a post where i can find further information? we are in directx now, gfx stuff, but i think input stuff will be handled not so much other than other things in DX...
We do not have a DirectInput sample (yet) but the Microsoft doc should be easy enough to follow. Also, if you search on this Forum, you'll find references to other interfaces (hint: for a HID sample look no further and check this post).
do i have to use then the directx api without the 3dconnex api or both?
Normally, you should use only one. All the interfaces can happily coexist on the same system. It is better to choose one for you application and stick with it (3DxInput, Raw Input, DirectInput, HID and even old, legacy interfaces from 3Dconnexion).
thanks for your help.
I think is it us that should be thanking those who try to expand the support for 3D mice. This is great technology. If you want, I'm sure you can go a long with it, specially in an academic environment. Keep us posted.
ben0bi
Posts: 11
Joined: Tue Oct 23, 2007 2:15 am

Post by ben0bi »

really thanx. i will try to use it in a windows app than a console app. i think then it will run.

i know 3d mice are used for max and maya and stuff, but i want to use it in games....("why not use a msg bump?") and on the other side i want to share the interface - the end-user-programmer should only use the .Initialize (not even, right now !!) and .Update functions, in a loop of HIS decision (and the .GetTx- etc. Functions of course ;) )

ok i'll try it tomorrow with windows stuff and see what happens. ;)
(i changed the subsystem to console in the pollcube demo and it runs....so i thought, it will run in an "only" console app)

ah this one for the end: i am using c/c++, no clue about c# and .NET...

regards,
ben0bi
ben0bi
Posts: 11
Joined: Tue Oct 23, 2007 2:15 am

YOU DO NOT NEED A WINDOWS APP

Post by ben0bi »

a friend of mine found the solution:

you do not need a windows app. you do not even need a standard message loop. my friend has a console app with a console main function !

all you need is this (in the loop where the mouse is updated):

(#include <windows>) ;)

MSG msg;

if(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

THATS ALL!!!. you can call now your updatemouse ANYWHERE !!!!

regards,
benedict jäggi
Last edited by ben0bi on Fri Oct 26, 2007 1:19 am, edited 3 times in total.
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi ben0bi,

Glad to see that you've found a solution that works for your needs.

Don't forget to keep us posted on your projects. Froi will be following all of you closely but it will still be nice if you can drop in the Forum and share your experiences.
ben0bi
Posts: 11
Joined: Tue Oct 23, 2007 2:15 am

CRITICAL UPDATE

Post by ben0bi »

i found a better way.

ok, GetMessage will STOP and WAIT for a message. i found this out because i have a GetAsyncKeyState(VK_SPACE) to end the program. if i press space with GetMessage, i have to touch the mouse so a message will be produced.

the better way is:

if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}

overwrite GetMessage with PeekMessage, then it won't stop...i can now press SPACE without touching the mouse after. ;)

if its in the update loop of the mouse and you will handle the message outside, simply use PM_NOREMOVE and call GetMessage again outside...;) ;)
Post Reply