Skip to main content
gamedev.net
🔒 Locked

Acquiring DirectInput with a Console Application

Started by haro May 26, 2003 at 8:24 PM 6 replies 2.3k views
Original Post
haro
haro
Is it possible to associate DirectInput with a console application? I am using GetConsoleWindow() and GetModuleHandle() to get the window''s handle and the app''s instance, which should be enough to acquire a Direct Input device for the console window. However, when I attemp to acquire the device for the first time I am unable to access it. This doesn''t seem to make much sense. Is there any specific reason MS prevents you from using DirectInput with console windows, or am I blundering somewhere? Thanks alot.
haro
haro
Anybody have an idea?
haro
haro
Hoping at least one other person has tried this
Pipo DeClown
Pipo DeClown
Are there some parameters you need to specify, or you CAN''t specify creating the object?

.lick
haro
haro
Everything works fine, I get the handle to the window from GetConsoleWindow() and I get instance from GetModuleHandle(NULL). The only problem is that the call to Acquire() fails and always fails.
Pipo DeClown
Pipo DeClown
I mean that maybe the consolewindow cant handle for instance, background & exclusive?

.lick
chase_encode
chase_encode
Did you try background non-exclusive?
When are you trying to acquire? The only time I acquire is when an update fails. This way, I know I have an active window.

haro
haro
WOOHOOOOOOOO!!!!!!!! =)

It was as trivial as changing the mode from FOREGROUND to BACKGROUND!!!! This makes my console programming about 10billion times easier since I can now treat it exactly as I treat window apps with my engine...

I was dreading having to rewrite an entire input subsystem using the nasty peek/constant buffered standard crap. Thanks a whole lot for the help.

As it goes, its always the little things that kill.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.