且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换已弃用的NXOpenEventStatus吗?

更新时间:2023-02-19 14:21:28

由于NXOpenEventStatusIOHIDGetAccelerationWithKey都是开源IOKit发行版的一部分,因此您可以

Since NXOpenEventStatus and IOHIDGetAccelerationWithKey are both part of the open-source IOKit distribution, you can look at how they're implemented. It turns out we can do what those functions do, using only non-deprecated functions.

要将其精简到最低限度,您可以像以下那样获得有关HID系统属性的字典:

To boil it down to the bare minimum, you can get a dictionary of the HID system's properties like this:

#import <Foundation/Foundation.h>
#import <IOKit/hidsystem/IOHIDLib.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        io_service_t service = IORegistryEntryFromPath(kIOMasterPortDefault, kIOServicePlane ":/IOResources/IOHIDSystem");

        CFDictionaryRef parameters = IORegistryEntryCreateCFProperty(service, CFSTR(kIOHIDParametersKey), kCFAllocatorDefault, kNilOptions);
        NSLog(@"%@", parameters);

        IOObjectRelease(service);
    }
    return 0;
}

输出(对于我,在macOS 10.13.4上为我):

Output (for me on macOS 10.13.4):

2018-04-05 17:06:55.560590-0500 accel[11924:131983] {
    ActuateDetents = 1;
    Clicking = 0;
    DragLock = 0;
    Dragging = 0;
    EjectDelay = 0;
    FirstClickThreshold = 1;
    ForceSuppressed = 0;
    HIDClickSpace =     (
        5,
        5
    );
    HIDClickTime = 500000000;
    HIDDefaultParameters = 1;
    HIDF12EjectDelay = 250;
    HIDFKeyMode = 1;
    HIDInitialKeyRepeat = 250000000;
    HIDKeyRepeat = 33333333;
    HIDKeyboardModifierMappingPairs =     (
    );
    HIDMouseAcceleration = 98304;
    HIDMouseKeysOptionToggles = 0;
    HIDPointerAcceleration = 45056;
    HIDPointerButtonMode = 2;
    HIDScrollAcceleration = 20480;
    HIDScrollZoomModifierMask = 262144;
    HIDSlowKeysDelay = 0;
    HIDStickyKeysDisabled = 0;
    HIDStickyKeysOn = 0;
    HIDStickyKeysShiftToggles = 0;
    HIDTrackpadAcceleration = 57344;
    HIDWaitCursorFrameInterval = 16666667;
    JitterNoClick = 1;
    JitterNoMove = 1;
    MouseButtonDivision = 55;
    MouseButtonMode = TwoButton;
    MouseHorizontalScroll = 1;
    MouseMomentumScroll = 1;
    MouseOneFingerDoubleTapGesture = 0;
    MouseTwoFingerDoubleTapGesture = 0;
    MouseTwoFingerHorizSwipeGesture = 0;
    MouseVerticalScroll = 1;
    "OutsidezoneNoAction When Typing" = 1;
    "PalmNoAction Permanent" = 1;
    "PalmNoAction When Typing" = 1;
    SecondClickThreshold = 1;
    "Trackpad Jitter Milliseconds" = 192;
    TrackpadCornerSecondaryClick = 0;
    TrackpadFiveFingerPinchGesture = 0;
    TrackpadFourFingerHorizSwipeGesture = 2;
    TrackpadFourFingerPinchGesture = 0;
    TrackpadFourFingerVertSwipeGesture = 0;
    TrackpadHandResting = 1;
    TrackpadHorizScroll = 1;
    TrackpadMomentumScroll = 1;
    TrackpadPinch = 1;
    TrackpadRightClick = 1;
    TrackpadRotate = 1;
    TrackpadScroll = 1;
    TrackpadThreeFingerDrag = 0;
    TrackpadThreeFingerHorizSwipeGesture = 2;
    TrackpadThreeFingerTapGesture = 0;
    TrackpadThreeFingerVertSwipeGesture = 0;
    TrackpadThreeFingersRightClick = 0;
    TrackpadTwoFingerDoubleTapGesture = 1;
    TrackpadTwoFingerFromRightEdgeSwipeGesture = 0;
    TwofingerNoAction = 1;
    USBMouseStopsTrackpad = 0;
    "Use Panther Settings for W" = 0;
    UserPreferences = 1;
    version = 1;
}
Program ended with exit code: 0

kIOHIDMouseAccelerationType常数的值为HIDMouseAcceleration.我还在那里看到HIDPointerAccelerationHIDTrackpadAcceleration.也有kIOHID...常量.

The kIOHIDMouseAccelerationType constant has value HIDMouseAcceleration. I also see HIDPointerAcceleration and HIDTrackpadAcceleration in there. There are kIOHID... constants for those too.