Hi I've got the following code which initilises a keyboard for DirectInput:
The call to SetDataFormat fails with error :DIERR_INVALIDPARAM
An invalid parameter was passed to the returning function, or the object was not in a state that permitted the function to be called. This value is equal to the E_INVALIDARG standard COM return value.





;first create the direct input object
Invoke DirectInput8Create,hInstance,DIRECTINPUT_VERSION,offset IID_IDirectInput8A,offset lpDI,NULL
.if eax!=DI_OK
PT "DirectInputCreate Failed"
PH eax
jmp DI_init_error
.endif

;create a keyboard device
DXINVOKE (pIDIO[lpDI]).CreateDevice,offset GUID_SysKeyboard,offset lpDIDkboard,NULL
.if eax!=DI_OK
PT "(pIDIO[lpdi]).CreateDevice Failed"
PH eax
jmp DI_init_error
.endif

; ;set cooperation level
DXINVOKE (pIDID[lpDIDkboard]).SetCooperativeLevel,hMainWnd,DISCL_NONEXCLUSIVE or DISCL_BACKGROUND
.if eax!=DI_OK
PT "(pIDID[lpDIDkboard]).SetCooperativeLevel Failed"
PH eax
jmp DI_init_error
.endif

; ;set data format
[B][I] DXINVOKE (pIDID[lpDIDkboard]).SetDataFormat,offset c_dfDIKeyboard [/B][/I] ;:confused:
.if eax!=DI_OK
PT "DXINVOKE (pIDID[lpDIDkboard]).SetDataFormat Failed"
PH eax
jmp DI_init_error
.endif

I've got c_dfDIKeyboard declared as DIDATAFORMAT <?>
Any ideas why it should fail?

cheers
Posted on 2002-08-24 04:18:09 by MArtial_Code
Afternoon, MArtial_Code.

Dunno if it's important...

The M$ DXSDK shows the SetDataFormat before SetCooperativeLevel.

Cheers,
Scronty
Posted on 2002-08-24 08:21:11 by Scronty
Indeed Scronty is right here is the order of operations from HE (hehe and it works ok)



;***************************************
; Main DI Initializations
;****************************************
Direct_Input_Init:

Call Create_Direct_Input_Object

call Create_Direct_Input_Device_Mouse
call Set_Data_Format_Mouse
call Set_Cooperative_Level_Mouse
call Acquire_Mouse


call Create_Direct_Input_Device_Keyboard
call Set_Data_Format_Keyboard
call Set_Cooperative_Level_Keyboard
call Acquire_Keyboard


; call Release_Direct_Input_Object
ret

Posted on 2002-08-24 12:05:46 by BogdanOntanu
I swapped the order of the calls but the error is the same. I've checked against the SDK and the interface is defined correctly.
I've got some earlier directIput includes so I'll try those...
cheers
Posted on 2002-08-25 05:26:23 by MArtial_Code
I've traced the problem back to some hack includes which I was using.
I've modfied them bu tno whte linker complains of not finding som external variables. There are about 40 of theses variables but the linker can't find 11 of them. I'm using the latest lib file but still no luck. the externals which the linker can't find are:

WGPD_14_01.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A
WGPD_14_01.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
dinput8.lib(dilib4.obj) : error LNK2001: unresolved external symbol _GUID_ZAxis
dinput8.lib(dilib4.obj) : error LNK2001: unresolved external symbol _GUID_YAxis
dinput8.lib(dilib4.obj) : error LNK2001: unresolved external symbol _GUID_XAxis
dinput8.lib(dilib2.obj) : error LNK2001: unresolved external symbol _GUID_Key
dinput8.lib(dilib3.obj) : error LNK2001: unresolved external symbol _GUID_POV
dinput8.lib(dilib3.obj) : error LNK2001: unresolved external symbol _GUID_Slider
dinput8.lib(dilib3.obj) : error LNK2001: unresolved external symbol _GUID_RzAxis
dinput8.lib(dilib3.obj) : error LNK2001: unresolved external symbol _GUID_RyAxis
dinput8.lib(dilib4.obj) : error LNK2001: unresolved external symbol _GUID_RxAxis

It seems as if dinput8.lib is looking for variables defined outside itself, are there any orther libs which I should be including?
And I thought GUID_SysKeyboard and IID_IDirectInput8A were supposed to be in dinput8.lib?
any ideas?
Cheers


found the lib needed now I just need to figure out why I'm getting a memory access violation...
Posted on 2002-08-25 09:53:43 by MArtial_Code
I remember i also answered an old post here by posting the real values for GUID_Syskeyboard and Mouse here
so please do a search if not found i will resend/repost

I also guess you shoud/could link with dxguid.lib if you want dynamic linking, for static i whould just use the real values :)
or EQU's

Q: how did you got that far without including some GUIDS :P ?
Posted on 2002-08-30 18:12:31 by BogdanOntanu
I did have the keyboard and directx 8 guids defined in the source file because the includes I got from caleb's site were generating errors. Evenually I found the solution in an old set of includes. the predefined GUIDS found in dxguid.lib needed to be declared as: EXTERNDEF C GUID* in the include file.

I think dxguid.lib is a static library, at least I can't find a dxguid.dll. I think all it contains are the DX GUIDS:grin:

I need to use dxguid.lib because it contains the predefined keyboard format structure and I couldn't find any info on setting up my own.

I reformated calebs dinput.def so it follows the imo cleaner format of x-calibre's files.
Direct draw, sound and input, now work without problems and are as easy to use as the standard windows API. Once I've written a few 2d games I may try my luck with D3D
Thanks Caleb and x-calibre & co.:alright:
Posted on 2002-08-31 08:04:29 by MArtial_Code
Ahh poor much-maligned Caleb :tongue:

Say, now you've taken the time to sort out his DI includes, how about posting them ?? I haven't messed with DI yet but the hour draws closer...
Posted on 2002-08-31 20:39:06 by Homer
Ahh poor much-maligned Caleb

It's not as bad as that. Caleb did all the hard work there were just a few issues which needed to be sorted out

one of the most important was changing the predefined declarations so I could use the format for the keyboard which is in DXGUID.lib.

I've changed the interface definitions so they fall in line with x-calibres
I've also ripped out the unicode stuff, but if you need it, it's no problem to add back in, all you need to do is find the original caleb includes and reformat it in what ever way you like.

you'll need to include both dxguid.lib and dinput8.lib when linking.

Again thanks to caleb and x-calibre & co
Posted on 2002-09-01 05:16:36 by MArtial_Code