2 messages in net.java.dev.jna.usersvoid * typedefs passed by value
FromSent OnAttachments
Francis FernandezApr 10, 2008 7:33 am 
Timothy WallApr 10, 2008 7:42 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:void * typedefs passed by valueActions...
From:Francis Fernandez (fraf@infoinplace.net)
Date:Apr 10, 2008 7:33:21 am
List:net.java.dev.jna.users

Hi, I'm new to JNA, and I'm trying to work with the API for a USB camera peripheral (which doesn't register with Windows as an image capture device). One of the typedefs in the API is

typedef void * VRmUsbCamDevice

which acts as a handle for the device. I've tried including it as a PointerType, a PointerByReference, and a class that implements Callback.

Functions in the API that require a VRmUsbCamDevice to be passed as a pointer work fine, but some of the functions require that it be passed by value:

int VRmUsbCamOpenDevice (const VRmDeviceKey *fcp_device_key, VRmUsbCamDevice *fp_device) int VRmUsbCamCloseDevice(VRmUsbCamDevice f_device);

My JNA interface includes them like so:

//Open/Close device //VRmUsbCamDevice is of type (void *), not sure how to convert it. int VRmUsbCamOpenDevice(VRmDeviceKey.ByReference fcp_device_key, Pointer fp_device); int VRmUsbCamCloseDevice(VRmUsbCamDevice f_device);

So as it stands, a call to

VRmagicLibrary.INSTANCE.VRmUsbCamOpenDevice(keys[i], devices[i].getPointer());

returns 1, where keys is a Java array of VRmDeviceKey's for all detected devices and devices is a Java array of device handles. But a call to

VRmagicLibrary.INSTANCE.VRmUsbCamCloseDevice(devices[i]);

returns 0.

How can I handle this type with JNA? Thanks in advance to anyone who can help.

~Francis