Page 1 of 1

Direct Input problem

Posted: Sat Nov 26, 2005 10:42 am
by Dreglor
i was converting the dinput.h file and writing the the tutorial for it when i was stopped by this nasty problem that i can't seam to fix

there are four constants (there structures so there going to be varibles in the include) that are defined in the dinput8.lib problem is i can't find the values for those constants and im not sure how you would get them

Code: Select all

c_dfDIKeyboard
c_dfDIMouse
c_dfDIMouse2
c_dfDIJoystick
c_dfDIJoystick2
now the constants are a structured type and the structure is defined by these 2 structures ugh

Code: Select all

Structure DIOBJECTDATAFORMAT
 *pguid.GUID
  dwOfs.l
  dwType.l
  dwFlags.l
EndStructure

Structure DIDATAFORMAT
  dwSize.l
  dwObjSize.l
  dwFlags.l
  dwDataSize.l
  dwNumObjs.l
 *rgodf.DIOBJECTDATAFORMAT
EndStructure
those were easy
in the header file these "constants"
are defined as

Code: Select all

extern const DIDATAFORMAT c_dfDIMouse;
extern const DIDATAFORMAT c_dfDIMouse2;
extern const DIDATAFORMAT c_dfDIKeyboard;
extern const DIDATAFORMAT c_dfDIJoystick;
extern const DIDATAFORMAT c_dfDIJoystick2;
now i tried doing

Code: Select all

!extrn c_dfDIKeyboard
!extrn c_dfDIMouse
!extrn c_dfDIMouse2
!extrn c_dfDIJoystick
!extrn c_dfDIJoystick2
that doesn't work... i getting unresolved symbol error
so does any one have a idea on how to retrieve the values of these structures
so i can define them in the include
disassemble the lib?
Create a C++ program that outputs them?
somthing
its very frustrating trying to get this to work

Posted: Sat Nov 26, 2005 11:15 am
by Trond
Create a C++ program that outputs them.

Posted: Sat Nov 26, 2005 5:43 pm
by srod

Posted: Sat Nov 26, 2005 7:22 pm
by Dreglor
those are for the keyboard, mouse, and joystick as of version DI 5
which is nice that i have 3 of the 5 structures


Trond: C++ isn't a lanaguage i know very well. if you know c++ please write such a program :)

Posted: Sat Nov 26, 2005 7:57 pm
by Deeem2031
Mouse2:

Code: Select all

;{ DIDFT-Constants
#DIDFT_ALL = $00000000
#DIDFT_RELAXIS = $00000001
#DIDFT_ABSAXIS = $00000002
#DIDFT_AXIS = $00000003
#DIDFT_PSHBUTTON = $00000004
#DIDFT_TGLBUTTON = $00000008
#DIDFT_BUTTON = $0000000C
#DIDFT_POV = $00000010
#DIDFT_COLLECTION = $00000040
#DIDFT_NODATA = $00000080
#DIDFT_ANYINSTANCE = $00FFFF00
#DIDFT_INSTANCEMASK = #DIDFT_ANYINSTANCE
;#DIDFT_MAKEINSTANCE(n) = ((WORD)(n) << 8)
;#DIDFT_GETTYPE(n) = LOBYTE(n)
;#DIDFT_GETINSTANCE(n) = LOWORD((n) >> 8)
#DIDFT_FFACTUATOR = $01000000
#DIDFT_FFEFFECTTRIGGER = $02000000
#DIDFT_OUTPUT = $10000000
;#DIDFT_ENUMCOLLECTION(n) = ((WORD)(n) << 8)
#DIDFT_NOCOLLECTION = $00FFFF00
#DIDFT_OPTIONAL = $80000000 ;}

#DIDF_ABSAXIS = $00000001
#DIDF_RELAXIS = $00000002

#DIGDD_PEEK = $00000001

Procedure DEFINE_GUID(*p.GUID, Data1.l, Data2.w, Data3.w, Data4_1.b, Data4_2.b, Data4_3.b, Data4_4.b, Data4_5.b, Data4_6.b, Data4_7.b, Data4_8.b)
  *p\Data1 = Data1
  *p\Data2 = Data2
  *p\Data3 = Data3
  *p\Data4[0] = Data4_1
  *p\Data4[1] = Data4_2
  *p\Data4[2] = Data4_3
  *p\Data4[3] = Data4_4
  *p\Data4[4] = Data4_5
  *p\Data4[5] = Data4_6
  *p\Data4[6] = Data4_7
  *p\Data4[7] = Data4_8
EndProcedure

DefType.GUID ;{
DEFINE_GUID(CLSID_DirectInput,$25E609E0,$B259,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(CLSID_DirectInputDevice,$25E609E1,$B259,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);

DEFINE_GUID(CLSID_DirectInput8,$25E609E4,$B259,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(CLSID_DirectInputDevice8,$25E609E5,$B259,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);

; Interfaces
DEFINE_GUID(IID_IDirectInputA,$89521360,$AA8A,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInputW,$89521361,$AA8A,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInput2A,$5944E662,$AA8A,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInput2W,$5944E663,$AA8A,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInput7A,$9A4CB684,$236D,$11D3,$8E,$9D,$00,$C0,$4F,$68,$44,$AE);
DEFINE_GUID(IID_IDirectInput7W,$9A4CB685,$236D,$11D3,$8E,$9D,$00,$C0,$4F,$68,$44,$AE);
DEFINE_GUID(IID_IDirectInput8A,$BF798030,$483A,$4DA2,$AA,$99,$5D,$64,$ED,$36,$97,$00);
DEFINE_GUID(IID_IDirectInput8W,$BF798031,$483A,$4DA2,$AA,$99,$5D,$64,$ED,$36,$97,$00);
DEFINE_GUID(IID_IDirectInputDeviceA,$5944E680,$C92E,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInputDeviceW,$5944E681,$C92E,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInputDevice2A,$5944E682,$C92E,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInputDevice2W,$5944E683,$C92E,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(IID_IDirectInputDevice7A,$57D7C6BC,$2356,$11D3,$8E,$9D,$00,$C0,$4F,$68,$44,$AE);
DEFINE_GUID(IID_IDirectInputDevice7W,$57D7C6BD,$2356,$11D3,$8E,$9D,$00,$C0,$4F,$68,$44,$AE);
DEFINE_GUID(IID_IDirectInputDevice8A,$54D41080,$DC15,$4833,$A4,$1B,$74,$8F,$73,$A3,$81,$79);
DEFINE_GUID(IID_IDirectInputDevice8W,$54D41081,$DC15,$4833,$A4,$1B,$74,$8F,$73,$A3,$81,$79);
DEFINE_GUID(IID_IDirectInputEffect,$E7E1F7C0,$88D2,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);

; Predefined object types
DEFINE_GUID(GUID_XAxis,$A36D02E0,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_YAxis,$A36D02E1,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_ZAxis,$A36D02E2,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_RxAxis,$A36D02F4,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_RyAxis,$A36D02F5,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_RzAxis,$A36D02E3,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_Slider,$A36D02E4,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_Button,$A36D02F0,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_Key,$55728220,$D33C,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_POV,$A36D02F2,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_Unknown,$A36D02F3,$C9F3,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);

; Predefined product GUIDs
DEFINE_GUID(GUID_SysMouse,$6F1D2B60,$D5A0,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_SysKeyboard,$6F1D2B61,$D5A0,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);
DEFINE_GUID(GUID_Joystick,$6F1D2B70,$D5A0,$11CF,$BF,$C7,$44,$45,$53,$54,$00,$00);

; Predefined forcefeedback effects
DEFINE_GUID(GUID_ConstantForce,$13541C20,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_RampForce,$13541C21,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Square,$13541C22,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Sine,$13541C23,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Triangle,$13541C24,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_SawtoothUp,$13541C25,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_SawtoothDown,$13541C26,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Spring,$13541C27,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Damper,$13541C28,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Inertia,$13541C29,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_Friction,$13541C2A,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DEFINE_GUID(GUID_CustomForce,$13541C2B,$8E33,$11D0,$9A,$D0,$00,$A0,$C9,$A0,$6E,$35);
DefType.l ;}

Structure DIOBJECTDATAFORMAT
  *pguid.GUID
  dwOfs.l
  dwType.l
  dwFlags.l
EndStructure

Structure DIDATAFORMAT
  dwSize.l
  dwObjSize.l
  dwFlags.l
  dwDataSize.l
  dwNumObjs.l
  *rgodf.DIOBJECTDATAFORMAT
EndStructure

;Mouse

Structure DIMOUSESTATE
  lx.l
  ly.l
  lZ.l
  rgbButtons.b[4]
EndStructure

Structure DIMOUSESTATE2
  lx.l
  ly.l
  lZ.l
  rgbButtons.b[8]
EndStructure

;{ DIMOFS-Constants
#DIMOFS_X        = OffsetOf(DIMOUSESTATE2\lx)
#DIMOFS_Y        = OffsetOf(DIMOUSESTATE2\ly)
#DIMOFS_Z        = OffsetOf(DIMOUSESTATE2\lZ)
#DIMOFS_BUTTON0  = OffsetOf(DIMOUSESTATE2\rgbButtons)+0
#DIMOFS_BUTTON1  = OffsetOf(DIMOUSESTATE2\rgbButtons)+1
#DIMOFS_BUTTON2  = OffsetOf(DIMOUSESTATE2\rgbButtons)+2
#DIMOFS_BUTTON3  = OffsetOf(DIMOUSESTATE2\rgbButtons)+3
#DIMOFS_BUTTON4  = OffsetOf(DIMOUSESTATE2\rgbButtons)+4
#DIMOFS_BUTTON5  = OffsetOf(DIMOUSESTATE2\rgbButtons)+5
#DIMOFS_BUTTON6  = OffsetOf(DIMOUSESTATE2\rgbButtons)+6
#DIMOFS_BUTTON7  = OffsetOf(DIMOUSESTATE2\rgbButtons)+7 ;}

Dim dfDIMouse2.DIOBJECTDATAFORMAT(10) ;{
dfDIMouse2(0)\pguid = GUID_XAxis :dfDIMouse2(0)\dwOfs = #DIMOFS_X :dfDIMouse2(0)\dwType = #DIDFT_ANYINSTANCE | #DIDFT_AXIS :dfDIMouse2(0)\dwFlags = 0
dfDIMouse2(1)\pguid = GUID_YAxis :dfDIMouse2(1)\dwOfs = #DIMOFS_Y :dfDIMouse2(1)\dwType = #DIDFT_ANYINSTANCE | #DIDFT_AXIS :dfDIMouse2(1)\dwFlags = 0
dfDIMouse2(2)\pguid = GUID_ZAxis :dfDIMouse2(2)\dwOfs = #DIMOFS_Z :dfDIMouse2(2)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_AXIS :dfDIMouse2(2)\dwFlags = 0
dfDIMouse2(3)\pguid = GUID_Button :dfDIMouse2(3)\dwOfs = #DIMOFS_BUTTON0 :dfDIMouse2(3)\dwType = #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(3)\dwFlags = 0
dfDIMouse2(4)\pguid = GUID_Button :dfDIMouse2(4)\dwOfs = #DIMOFS_BUTTON1 :dfDIMouse2(4)\dwType = #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(4)\dwFlags = 0
dfDIMouse2(5)\pguid = GUID_Button :dfDIMouse2(5)\dwOfs = #DIMOFS_BUTTON2 :dfDIMouse2(5)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(5)\dwFlags = 0
dfDIMouse2(6)\pguid = GUID_Button :dfDIMouse2(6)\dwOfs = #DIMOFS_BUTTON3 :dfDIMouse2(6)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(6)\dwFlags = 0
dfDIMouse2(7)\pguid = GUID_Button :dfDIMouse2(7)\dwOfs = #DIMOFS_BUTTON4 :dfDIMouse2(7)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(7)\dwFlags = 0
dfDIMouse2(8)\pguid = GUID_Button :dfDIMouse2(8)\dwOfs = #DIMOFS_BUTTON5 :dfDIMouse2(8)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(8)\dwFlags = 0
dfDIMouse2(9)\pguid = GUID_Button :dfDIMouse2(9)\dwOfs = #DIMOFS_BUTTON6 :dfDIMouse2(9)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(9)\dwFlags = 0
dfDIMouse2(10)\pguid = GUID_Button :dfDIMouse2(10)\dwOfs = #DIMOFS_BUTTON7 :dfDIMouse2(10)\dwType = #DIDFT_OPTIONAL | #DIDFT_ANYINSTANCE | #DIDFT_BUTTON :dfDIMouse2(10)\dwFlags = 0 ;}

c_dfDIMouse2.DIDATAFORMAT ;{

c_dfDIMouse2\dwSize = SizeOf(DIDATAFORMAT)
c_dfDIMouse2\dwObjSize = SizeOf(DIOBJECTDATAFORMAT)
c_dfDIMouse2\dwFlags = #DIDF_RELAXIS
c_dfDIMouse2\dwDataSize = 20
c_dfDIMouse2\dwNumObjs = 11 ;SizeOf(c_rgodfDIMouse2)/SizeOf(c_rgodfDIMouse2[0])
c_dfDIMouse2\rgodf = @dfDIMouse2() ;}
From there: http://forums.purebasic.com/german/view ... irectinput

Posted: Sat Nov 26, 2005 11:56 pm
by Dreglor
edit:
erm there seams to be more that i thought

the field "rgodf" is a pointer to a structured array (more values grr)
i whent on modifiing the C++ program i wrote to get all of the values in the array, now i get a access voilation when i do the frist constant, c_dfDIMouse, its saying that the thrid item in the array and in frist field in the structure which is pguid (another pointer)

im assuming its null because the volation is that its accessing 0x000000
it does 0,1,2 just fine the structure defines that there are 7 objects
and im thinking that i should right up my own dataformats in places of these predefined ones becasue this is frustrating me to no end...