Skip to main content
gamedev.net
🔒 Locked

DInput8 woes

Started by Promit Sep 19, 2005 at 12:24 AM 2 replies 1.4k views
Original Post
Promit
Promit
Ok, so I'm trying to attach DInput8 to an SDL window. I have the HWND already, no problems there. I run through all the normal steps. All the HRESULTS come back fine. Even GetDeviceState returns a good old S_OK. But, nothing happens when I press a key. The key array always comes back as straight 0s. I don't really understand what the problem is -- it's a bare minimum keyboard based DI app, with the code following the SDK tutorial pretty much to the letter. Debug runtime output:

DINPUT8: DIHid_BuildHidList(0)
DINPUT8: DIHid_CheckList(00000000)
DINPUT8: DIHid_CheckList(00000000) -> 
DINPUT8: DIHid_BuildHidListEntry(00154190, 0012F5A0)
DINPUT8: DIHid_GetDevicePath(00154190, 0012F5A0)
DINPUT8: DIHid_GetDevicePath(00154190, 0012F5A0) -> 00000001 OK 
DINPUT8: DIHid_GetDevInfo(00154190, 0012F5A0, 0012F4F4)
DINPUT8: DIHid_GetDevicePath(00154190, 0012F5A0)
DINPUT8: DIHid_GetDevicePath(00154190, 0012F5A0) -> 00000001 OK 
DINPUT8: DIHid_CreateDeviceInstanceKeys(0012F4F4)
DINPUT8: DIHid_CreateDeviceInstanceKeys: RegQueryValueEx failed (2) to get state for instance 6&28A357F1&0&0000
DINPUT8: DIHid_CreateDeviceInstanceKeys(0012F4F4) -> 00000000
DINPUT8: DIHid_GetDevInfo: CreateFile(\\?\hid#vid_047d&pid_102d#6&28a357f1&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}) failed? le=5
DINPUT8: DIHid_GetDevInfo(00154190, 0012F5A0, 0012F4F4) -> 00000000 le=[5]
DINPUT8: DIHid_BuildHidListEntry: DIHid_GetDevInfo failed, ignoring device
DINPUT8: DIHid_BuildHidListEntry(00154190, 0012F5A0) -> 00000000 le=[5]
DINPUT8: DIHid_BuildHidListEntry failed?
DINPUT8: DIHid_BuildHidList(0) -> 
DINPUT8: DIHid_GetDevicePath(00154190, 0012F61C)
DINPUT8: DIHid_GetDevicePath(00154190, 0012F61C) -> 00000001 OK 
DINPUT8: DIHid_GetDevicePath(00154190, 0012F61C)
DINPUT8: DIHid_GetDevicePath(00154190, 0012F61C) -> 00000001 OK 
DINPUT8: DIHid_BuildHidList(0)
DINPUT8: DIHid_BuildHidList(0) -> 

One line seems to suggest a problem: DINPUT8: DIHid_BuildHidListEntry: DIHid_GetDevInfo failed, ignoring device Don't know what that means, but ignoring device sounds bad. I'm not posting code, because my code literally follows the SDK tutorial completely. Create DI, create device, set format, set coop level, acquire. Loop on get device state. Unacquire, release device, release DI. Is SDL potentially interacting with DI in a bad way? (Is SDL attempting to use DI?) Anyway, I dunno. Never really spent too long with DI, since it usually 'just works'. Would really appreciate help.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Armadon
Armadon
Howsit Promit,
How are you doing?

The Problem
Problems with SDL and DirectInput

The Solution
Are you sure that SDL isn't messing with directinput in a way that might change the key mappings?

I read a post that it might potentially be causing problems.

Here is the post
"Ok, it's a well known problem that SDL using DirectInput doesn't always
give the correct key codes for the actual keys being pressed when using a
non US keyboard.

After examining the problem, I have to ask why can't MapVirtualKey() be
used to convert the scancode from DirectInput for the key pressed into a
Virtual Key code that is correct for the keyboard being used.

In the a fairly limited test, using MapVirtualKey to translate the scancode
to a virtual key worked fine.

Just as a note, MapVirtualKey() is already being used by the DirectInput
code when TranslateUNICODE is set, so I don't see that there would be a
problem always using it."


I don't know much about SDL but I might look into that.

I hope this gives you somewhat of a guideline to solve your problem.
Take care buddy.
pdriggett
pdriggett
Could you please post your initialization code, I need to see this before I can give an answer
Promit
Promit
Further research reveals that an SDL conflict is, in fact, the problem. Specifically, SDL always attaches a DI 5 device to the window it creates. As a result, my device never gets any key inputs because they're captured by SDL's DI device.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

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

Sign in to reply to this topic.