Write LED Example

This example assumes that the all other output cookies (non LED cookies) are set to zero at this point. Whenever cookies are written to they must be cleared afterwards with the exception of the LED cookies, clearing these will result in turning the LED off.

Functions referenced are:
In the following example:
inCookie=155 for green LED on Desktop, Pro, Stick, Controller and Editor
inCookie=211 for green LED onMatrix, Footpedal and Switch Interface
inCookie=156 for red LED on Desktop, Pro, Stick, Controller and Editor
inCookie=212 for red LED on Matrix, Footpedal and Switch Interface

Functions referenced are:

//this function returns element associated with a cookie pRecElement HIDDevice::GetCookieMapping( IOHIDElementCookie inCookie )
{
    if( mCookieToElementMap == NULL ) return NULL;
    return (pRecElement) CFDictionaryGetValue( mCookieToElementMap, inCookie );
}


Start of Example

unsigned long HIDDevice::SetCookieValue( IOHIDElementCookie inCookie,SInt32 value)
{
    IOHIDEventStruct hidstruct = {kIOHIDElementTypeOutput};
    IOReturn result = 0;
    pRecElement pElem = GetCookieMapping(inCookie);
    hidstruct.type = (IOHIDElementType) pElem->type;
    hidstruct.elementCookie = inCookie;
    hidstruct.value = value;
    result = HIDSetElementValue(mDevice,pElem,&hidstruct;);
    return result;
}

Back to Contents