Re: Calling DirectInput from IDL [message #38101 is a reply to message #38097] |
Wed, 18 February 2004 09:25  |
Karl Schultz
Messages: 341 Registered: October 1999
|
Senior Member |
|
|
You might consider using the ul (ULONG) member in IDL_ALLTYPES to pass the
DD handle around. Also, ptrint may be a better choice if you have 6.0.
You would need to cast the handle to a LPDIRECTINPUT8 in the Destroy
routine, and in any others that need the handle.
So you might want to try something like:
In create:
IDL_VPTR vpHandle;
vpHandle = IDL_GettmpULong((IDL_ULONG)g_pDI);
return vpHandle;
In destroy:
LPDIRECTINPUT8 pDIID;
pDIID = (LPDIRECTINPUT8) argv[0]->value.ul;
Code untested, but may give you an idea.
Karl
"IDLUser" <bbhyun2001@yahoo.com> wrote in message
news:a1d082bc.0402171504.5d0197df@posting.google.com...
> Hi,all
> I need to call direct input(force feedback) functionality from IDL for
> my application. I played with DLM little bit and I decide to call
> joystick functionality from IDL for practice first. I know that this
> will be a long way with my poor DLM experience to get the result I
> want. Anyway,I wrote the simple following code: getting direct input
> ID from IDL and returning it back to DLM for destroying direct input.
> But I have a compiling error as I run the file. How can I solve this
> problem? Am I in the right track? Any advice will be greatly
> appreciated.
>
> #define STRICT
> #define DIRECTINPUT_VERSION 0x0800
> ;
> ;
> ;
> #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
> #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
>
> LPDIRECTINPUT8 g_pDI = NULL;
> ;
> ;
> ;
> extern IDL_VPTR IDL_CDECL diTestBedINI_HC(int argc,IDL_VPTR
> argv[],char* argk)
> {
> // called in IDL: pbDirectInputID = diTestBedINI_HC();
>
> HRESULT hr;
> if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL),
> DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )
> IDL_Message(IDL_M_NAMED_GENERIC,IDL_MSG_LONGJMP," Fail to get the DI
> Instance");
>
> UCHAR *store;
> IDL_VPTR new_array;
> IDL_LONG dims[1];
>
> dims[0] = sizeof(g_pDI);
> store = (UCHAR *)malloc(dims[0]);
> memcpy(store,&g_pDI,dims[0]);
> new_array = IDL_ImportArray(1,dims,IDL_TYP_BYTE,store,NULL,NULL);
> return new_array;
>
> }
>
> void IDL_CDECL diTestBedDestroy_HC(int argc,IDL_VPTR argv[],char*
> argk)
> {
> // called in IDL: diTestBedDestroy_HC,pbDirectInputID;
> char *pDIID;//??
>
> IDL_ENSURE_ARRAY(argv[0]);
> pDIID = (char*)argv[0]->value.arr->data;//??
> SAFE_RELEASE(pDIID);//??
>
> }
> //error C2227: left of '->Release' must point to class/struct/union
>
> --BB
|
|
|