NX_KEYTYPE_BRIGHTNESS_UP/DOWN does't work

Hi,


I'm improving my app that simulates hardware keyboard and trackpad and want to add function keys like volume up/down and etc.

All the media keys are working fine (NX_KEYTYPE_SOUND_UP for example) but NX_KEYTYPE_BRIGHTNESS_UP/DOWN does't work.


Here the code I found that sends those keyboard events:


/
/
static io_connect_t _getAuxiliaryKeyDriver(void)
{
    static mach_port_t sEventDrvrRef = 0;
    mach_port_t masterPort, service, iter;
    kern_return_t kr;
   
    if (!sEventDrvrRef)
    {
        kr = IOMasterPort( bootstrap_port, &masterPort );
        assert(KERN_SUCCESS == kr);
       
        kr = IOServiceGetMatchingServices(masterPort, IOServiceMatching( kIOHIDSystemClass), &iter );
        assert(KERN_SUCCESS == kr);
       
        service = IOIteratorNext( iter );
        assert(service);
       
        kr = IOServiceOpen(service, mach_task_self(), kIOHIDParamConnectType, &sEventDrvrRef );
        assert(KERN_SUCCESS == kr);
       
        IOObjectRelease(service);
        IOObjectRelease(iter);
    }
    return sEventDrvrRef;
}
/
/
static void _postAuxiliaryKey(const UInt8 auxKeyCode)
{
    NXEventData   event;
    kern_return_t kr;
    IOGPoint loc = { 0, 0 };
   
   
    /
    UInt32 evtInfo = auxKeyCode << 16 | NX_KEYDOWN << 8;
    bzero(&event, sizeof(NXEventData));
    event.compound.subType = NX_SUBTYPE_AUX_CONTROL_BUTTONS;
    event.compound.misc.L[0] = evtInfo;
    kr = IOHIDPostEvent( _getAuxiliaryKeyDriver(), NX_SYSDEFINED, loc, &event, kNXEventDataVersion, 0, FALSE );
    assert( KERN_SUCCESS == kr );
   
    /
    evtInfo = auxKeyCode << 16 | NX_KEYUP << 8;
    bzero(&event, sizeof(NXEventData));
    event.compound.subType = NX_SUBTYPE_AUX_CONTROL_BUTTONS;
    event.compound.misc.L[0] = evtInfo;
    kr = IOHIDPostEvent( _getAuxiliaryKeyDriver(), NX_SYSDEFINED, loc, &event, kNXEventDataVersion, 0, FALSE );
    assert( KERN_SUCCESS == kr );
   
}


What so special about brigthness? (it does work when I change it using my hardware keyboard).


Thanks.

All the media keys are working fine (

NX_KEYTYPE_SOUND_UP
for example) but
NX_KEYTYPE_BRIGHTNESS_UP
/
DOWN
does't work.

Weird. I’ve no idea why there’d be a difference here. If no one else chimes in I recommend you open a DTS tech support incident so our HID system expert can dig into it.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks... and good to see you here again 🙂

No response on the DTS I opened (646418031)

If you have any way of bumping it up the chain would be much appriciated.

Thanks.

Hey,


This (IOHIDPostEvent) stopped working when display is a sleep.

Is this due to IOHIDLib being deprecated or something or its a bug?


Thanks.

Is this due to IOHIDLib being deprecated or something or its a bug?

This is, alas, way outside of my area of expertise, so I can’t offer on opinion.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
NX_KEYTYPE_BRIGHTNESS_UP/DOWN does't work
 
 
Q