SpaceTraveler support using IOKit

Post questions, comments and feedback to our 3Dconnexion Mac Development Team.

Moderator: Moderators

SpaceTraveler support using IOKit

Postby felix » Wed Feb 14, 2007 11:07 am

Hi there,

Nice to see your support for Mac OS X, that's really great.

I've included support for the SpaceTraveler device in our Medical Applications on OSX using the IOKit.framework and the HID functions. One thing that's left is supporting the nice blue LED. Could you please provide me with some information about the HID report buffer I've to send to enable/disable the LED.

Thanks in advance,

Felix
felix
 
Posts: 3
Joined: Wed Feb 14, 2007 10:58 am

Postby flomotan » Wed Feb 14, 2007 4:15 pm

For our SpaceNavigator, the LEDs are turned on with a HID SetReport call with the following parameters:

report type = 2 (kHIDRtOutputReport)
report ID = 4
report length = 1 byte
report data = 0x00 or 0x01 (off or on)

This is called from the kernel so the API is not what you'd need in user space. In user space with the USBLib it would be something like this (untested):

buffer[0] = 0x01;
request.bmRequestType = USBmakebmRequestType(kUSBOut, kUSBClass,
kUSBInterface);
request.bRequest = kHIDRqSetReport;
request.wValue = 0x0204; // (reportType <<8>DeviceRequest(deviceInterface, &request);

I haven't tried the HIDLib but it should have a SetReport call with similar parameters.
flomotan
Moderator
Moderator
 
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Postby felix » Thu Feb 15, 2007 12:02 pm

Many thanks for the fast response. Unfortunately, it didn't work out for the SpaceTraveler. I'm using the following code, without an error:

Code: Select all
void
HIDSpaceTraveler::enableLED(bool trueOrFalse)
{
  IOHIDDeviceInterface122 ** hidDeviceInterface = getDeviceInterface();
  if (hidDeviceInterface != NULL) {
   
    UInt8 buffer[1] = {0};
    buffer[0] = (trueOrFalse) ? 0x01 : 0x00;
    IOReturn ret = (*hidDeviceInterface)->setReport(hidDeviceInterface, kIOHIDReportTypeOutput, 4, buffer, sizeof(buffer), 100, NULL, NULL, NULL);
    if (ret != kIOReturnSuccess) {
      std::cout << "error changing led state" << std::endl;
    }
  }
}


Any further hints would be greatly appreciated...

Felix
felix
 
Posts: 3
Joined: Wed Feb 14, 2007 10:58 am

Postby jwick » Thu Feb 15, 2007 12:20 pm

You have to send 3 bits for the SpaceTraveler, CadMan and SpaceMouse(0x07). Turning on/off these individual bits actually allows you to turn on/off every other LED. Some people have even suggested that this would make it easier for you to distinguish the individual buttons on the ST.

Jim
3Dx Software Development
jwick
Moderator
Moderator
 
Posts: 1769
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA

Postby felix » Fri Feb 16, 2007 6:24 am

This really makes a difference, I agree with those people. Again, many thanks and have a nice weekend.

Felix
felix
 
Posts: 3
Joined: Wed Feb 14, 2007 10:58 am


Return to Developer's Forum for Mac OS X

Who is online

Users browsing this forum: No registered users and 3 guests