[
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\nDerivedData\nLilu.kext\nVirtualSMC.kext\nxcuserdata\nxcshareddata\nproject.xcworkspace\nbuild\n.idea\n.vscode\n.svace-dir\ncov-int\n/MacKernelSDK\n"
  },
  {
    "path": ".maciasl",
    "content": "[als] --> Ambient Light Sensor\tpatches/NullPatch.txt\n[als] Fake ALS\tpatches/fake_als.txt\n[kbl] --> Keyboard Backlight\tpatches/NullPatch.txt\n[kbl] Ivy Bridge\tpatches/kbl_ivybridge.txt\n[kbl] Haswell/Broadwell/Skylake\tpatches/kbl_broadwell.txt\n[kbl] Kaby Lake/Kaby Lake-R\tpatches/kbl_kabylake.txt\n[kbl] Whiskey Lake\tpatches/kbl_whiskeylake.txt\n[kbl] Coffee Lake\tpatches/kbl_coffeelake.txt\n[kbl] Ice Lake\tpatches/kbl_icelake.txt\n[fn] --> FN keys\tpatches/NullPatch.txt\n[fn] ALS toggle\tpatches/als_toggle.txt\n[fn] Media - arrow keys\tpatches/media_arrow.txt\n[fn] Media - Space, C, V\tpatches/media_cvspace.txt\n[fn] F1 key\tpatches/f1.txt\n[fn] F2 key\tpatches/f2.txt\n[fn] F3 key\tpatches/f3.txt\n[fn] F4 key\tpatches/f4.txt\n[fn] F5 key\tpatches/f5.txt\n[fn] F6 key\tpatches/f6.txt\n[fn] F7 key\tpatches/f7.txt\n[fn] F8 key\tpatches/f8.txt\n[fn] F9 key\tpatches/f9.txt\n[fn] F10 key\tpatches/f10.txt\n[fn] F11 key\tpatches/f11.txt\n[fn] F12 key\tpatches/f12.txt\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: cpp\n\nmatrix:\n  include:\n  - os: osx\n    name: \"Build\"\n    osx_image: xcode11.6\n    compiler: clang\n\n    script:\n      - git clone https://github.com/acidanthera/MacKernelSDK\n      - src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/hieplpvip/AsusSMC/master/Scripts/bootstrap.sh) && eval \"$src\" || exit 1\n      - xcodebuild -jobs 1 -configuration Debug\n      - xcodebuild -jobs 1 -configuration Release\n\n    deploy:\n      provider: releases\n      skip_cleanup: true\n      file: \"build/*/*.zip\"\n      file_glob: true\n      api_key:\n        secure: \"BOTxFlC2lE8LtOZ0eVXz5eQRV21a248Rirr3Fvsj51kzvUpExtcdlpWv+xFOlIIqsZb2luzj6q1cG8bNpWWp2/EseHdtWqF2/ZwfBLs2XdXTyS5aunUxbZ4FHLhMPDRgNunTcoZuzMRtSAyNl5maGKveKN9irWwI1HbKOh4p9jQDATA2QNDC6v/uQ1fJR3Vjiye9nIKk6SOhmy62qBCjLzEEe0SiRYw2ewMjm0eybfHt3YNwRy2lBfKXpnxsapA41kq4B/ThoJk3TFmRRZDzveJin20CXI2L2jvN9K2d2gWncHG5oRV63m+4CBGl7MLxJaAHD7flGmr4l2qFbIUgMXGlKmQSo7SJEO09K6weG2n6duqXxprnQSyFCOERRu0KyDPHnSUkr6y5FBTkkV3YMOUXRVUk7pA+kOlKjV89O6WLxpirZ9NzGz9jlKg32wTTyj9UBYcrCDIOravL/eTZ7g+xdXNV9vKyhsN2v3iPmHQ+DNJ73DdZjhj+BFT56E8Fz+r5aF13Z6tGVChKNqe3+CYih59Tgzwd+y5YU0Et4b/55Qkh/MexXm8YqJNzzZD7jRKpP3zlOFNuAxIDlBXYUtfgYh5CmcXlOgk8626JDFUSakjwYfxE2+rpQxyhAVNn/etmaSOfsL1pbKDjE1aM0M4Pho68dOju/k4Vb0x4FgA=\"\n      on:\n        tags: true\n\n  - os: osx\n    name: \"Analyze Clang\"\n    osx_image: xcode11\n    compiler: clang\n\n    script:\n      - git clone https://github.com/acidanthera/MacKernelSDK\n      - src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/hieplpvip/AsusSMC/master/Scripts/bootstrap.sh) && eval \"$src\" || exit 1\n      - xcodebuild analyze -quiet -configuration Debug CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR=\"$(pwd)/clang-analyze\" && [ \"$(find clang-analyze -name \"*.html\")\" = \"\" ]\n      - xcodebuild analyze -quiet -configuration Release CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR=\"$(pwd)/clang-analyze\" && [ \"$(find clang-analyze -name \"*.html\")\" = \"\" ]\n\n  - os: osx\n    name: \"Analyze Coverity\"\n    osx_image: xcode10.2\n    compiler: clang\n\n    before_install:\n      - git clone https://github.com/acidanthera/MacKernelSDK\n      - curl -Ls https://entrust.com/root-certificates/entrust_l1k.cer -o ~/entrust_l1k.crt || exit 1\n      - curl -LS https://curl.haxx.se/ca/cacert.pem -o ~/cacert.pem || exit 1\n      - cat ~/entrust_l1k.crt >> ~/cacert.pem || exit 1\n      - echo \"cacert=\\\"$HOME/cacert.pem\\\"\" > ~/.curlrc || exit 1\n      - echo \"ca_certificate=$HOME/cacert.pem\" > ~/.wgetrc || exit 1\n    script:\n      - echo \"This script runs coverity...\"\n\n    addons:\n      coverity_scan:\n        project:\n          name: \"hieplpvip/AsusSMC\"\n          description: \"AsusSMC\"\n        notification_email: $NOTIFICATION_EMAIL\n        build_command_prepend: \"src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/hieplpvip/AsusSMC/master/Scripts/bootstrap.sh) && eval \\\"$src\\\" || exit 1 ; src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/Lilu/master/Lilu/Scripts/covstrap.sh) && eval \\\"$src\\\" || exit 1\"\n        build_command: \"xcodebuild -configuration Release\"\n        branch_pattern: ^(master|dev)$\n"
  },
  {
    "path": "AsusSMC/AsusSMC.cpp",
    "content": "//\n//  AsusSMC.cpp\n//  AsusSMC\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#include \"AsusSMC.hpp\"\n\nbool ADDPR(debugEnabled) = false;\nuint32_t ADDPR(debugPrintDelay) = 0;\n\n#define super IOService\nOSDefineMetaClassAndStructors(AsusSMC, IOService)\n\nbool AsusSMC::init(OSDictionary *dict) {\n    if (!super::init(dict)) {\n        return false;\n    }\n\n    _notificationServices = OSSet::withCapacity(1);\n\n    kev.setVendorID(\"com.hieplpvip\");\n    kev.setEventCode(AsusSMCEventCode);\n\n    atomic_init(&currentLux, 0);\n    atomic_init(&currentFanSpeed, 0);\n\n    return true;\n}\n\nIOService *AsusSMC::probe(IOService *provider, SInt32 *score) {\n    if (!super::probe(provider, score)) {\n        return NULL;\n    }\n\n    IOACPIPlatformDevice *dev = OSDynamicCast(IOACPIPlatformDevice, provider);\n    if (!dev) {\n        return NULL;\n    }\n\n    OSObject *obj;\n    dev->evaluateObject(\"_UID\", &obj);\n\n    OSString *name = OSDynamicCast(OSString, obj);\n    if (!name) {\n        return NULL;\n    }\n\n    IOService *ret = NULL;\n    if (name->isEqualTo(\"ATK\")) {\n        ret = this;\n    }\n    name->release();\n\n    return ret;\n}\n\nbool AsusSMC::start(IOService *provider) {\n    if (!provider || !super::start(provider)) {\n        SYSLOG(\"atk\", \"failed to start parent\");\n        return false;\n    }\n\n    atkDevice = (IOACPIPlatformDevice *)provider;\n\n    parse_WDG();\n\n    initATKDevice();\n\n    initALSDevice();\n\n    initEC0Device();\n\n    initBattery();\n\n    initVirtualKeyboard();\n\n    startATKDevice();\n\n    workloop = getWorkLoop();\n    if (!workloop) {\n        DBGLOG(\"atk\", \"Failed to get workloop\");\n        return false;\n    }\n    workloop->retain();\n\n    command_gate = IOCommandGate::commandGate(this);\n    if (!command_gate || (workloop->addEventSource(command_gate) != kIOReturnSuccess)) {\n        DBGLOG(\"atk\", \"Could not open command gate\");\n        return false;\n    }\n\n    setProperty(\"IsTouchpadEnabled\", true);\n    setProperty(\"Copyright\", \"Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\");\n\n    extern kmod_info_t kmod_info;\n    setProperty(\"AsusSMC-Version\", kmod_info.version);\n#ifdef DEBUG\n    setProperty(\"AsusSMC-Build\", \"Debug\");\n#else\n    setProperty(\"AsusSMC-Build\", \"Release\");\n#endif\n\n    registerNotifications();\n\n    registerVSMC();\n\n    registerService();\n\n    return true;\n}\n\nvoid AsusSMC::stop(IOService *provider) {\n    if (poller) {\n        poller->cancelTimeout();\n    }\n    if (workloop && poller) {\n        workloop->removeEventSource(poller);\n    }\n    if (workloop && command_gate) {\n        workloop->removeEventSource(command_gate);\n    }\n    OSSafeReleaseNULL(workloop);\n    OSSafeReleaseNULL(poller);\n    OSSafeReleaseNULL(command_gate);\n\n    _publishNotify->remove();\n    _terminateNotify->remove();\n    _notificationServices->flushCollection();\n    OSSafeReleaseNULL(_publishNotify);\n    OSSafeReleaseNULL(_terminateNotify);\n    OSSafeReleaseNULL(_notificationServices);\n\n    OSSafeReleaseNULL(kbdDevice);\n\n    super::stop(provider);\n    return;\n}\n\nIOReturn AsusSMC::message(uint32_t type, IOService *provider, void *argument) {\n    DBGLOG(\"atk\", \"Received message: %u Type %x Provider %s\", *((uint32_t *)argument), type, provider ? provider->getName() : \"unknown\");\n\n    switch (type) {\n        case kIOACPIMessageDeviceNotification:\n        {\n            if (directACPImessaging) {\n                handleMessage(*((uint32_t *)argument));\n            } else {\n                uint32_t event = *((uint32_t *)argument);\n                OSNumber *arg = OSNumber::withNumber(event, 32);\n                uint32_t res;\n                atkDevice->evaluateInteger(\"_WED\", &res, (OSObject **)&arg, 1);\n                arg->release();\n                handleMessage(res);\n            }\n            break;\n        }\n\n        case kSetKeyboardBacklightMessage:\n        {\n            if (hasKeyboardBacklight) {\n                OSNumber *arg = OSNumber::withNumber(*((uint16_t *)argument) / 16, 16);\n                atkDevice->evaluateObject(\"SKBV\", NULL, (OSObject **)&arg, 1);\n                arg->release();\n            }\n            break;\n        }\n\n        default:\n            return kIOReturnInvalid;\n    }\n    return kIOReturnSuccess;\n}\n\nint AsusSMC::wmi_parse_guid(const char *in, char *out) {\n    for (int i = 3; i >= 0; i--) {\n        out += snprintf(out, 3, \"%02X\", in[i] & 0xFF);\n    }\n\n    out += snprintf(out, 2, \"-\");\n    out += snprintf(out, 3, \"%02X\", in[5] & 0xFF);\n    out += snprintf(out, 3, \"%02X\", in[4] & 0xFF);\n    out += snprintf(out, 2, \"-\");\n    out += snprintf(out, 3, \"%02X\", in[7] & 0xFF);\n    out += snprintf(out, 3, \"%02X\", in[6] & 0xFF);\n    out += snprintf(out, 2, \"-\");\n    out += snprintf(out, 3, \"%02X\", in[8] & 0xFF);\n    out += snprintf(out, 3, \"%02X\", in[9] & 0xFF);\n    out += snprintf(out, 2, \"-\");\n\n    for (int i = 10; i <= 15; i++) {\n        out += snprintf(out, 3, \"%02X\", in[i] & 0xFF);\n    }\n\n    *out = '\\0';\n    return 0;\n}\n\nint AsusSMC::wmi_evaluate_method(uint32_t method_id, uint32_t arg0, uint32_t arg1) {\n    OSObject *params[3];\n\n    struct wmi_args args = {\n        .arg0 = arg0,\n        .arg1 = arg1\n    };\n\n    params[0] = OSNumber::withNumber(static_cast<uint32_t>(0), 32);\n    params[1] = OSNumber::withNumber(method_id, 32);\n    params[2] = OSData::withBytes(&args, sizeof(wmi_args));\n\n    uint32_t val;\n    IOReturn ret = atkDevice->evaluateInteger(wmi_method, &val, params, 3);\n    params[0]->release();\n    params[1]->release();\n    params[2]->release();\n\n    if (ret != kIOReturnSuccess) {\n        DBGLOG(\"wmi\", \"wmi_evaluate_method failed\");\n        return -1;\n    }\n\n    if (val == 0xfffffffe) {\n        DBGLOG(\"wmi\", \"wmi_evaluate_method invalid method_id\");\n        return -1;\n    }\n\n    return val;\n}\n\nint AsusSMC::wmi_get_devstate(uint32_t dev_id) {\n    return wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, dev_id, 0);\n}\n\nbool AsusSMC::wmi_dev_is_present(uint32_t dev_id) {\n    int status = wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, dev_id, 0);\n    return status != -1 && (status & ASUS_WMI_DSTS_PRESENCE_BIT);\n}\n\nvoid AsusSMC::parse_WDG() {\n    OSObject *wdg;\n    if (atkDevice->evaluateObject(\"_WDG\", &wdg) != kIOReturnSuccess) {\n        SYSLOG(\"wmi\", \"No method _WDG!\");\n        return;\n    }\n\n    OSData *data = OSDynamicCast(OSData, wdg);\n    if (!data) {\n        SYSLOG(\"guid\", \"Cast WDG error!\");\n        return;\n    }\n\n    int total = data->getLength() / sizeof(struct guid_block);\n\n    char guid_string[37];\n\n    for (int i = 0; i < total; i++) {\n        struct guid_block *g = (struct guid_block *) data->getBytesNoCopy(i * sizeof(struct guid_block), sizeof(struct guid_block));\n        wmi_parse_guid(g->guid, guid_string);\n\n        if (strncmp(guid_string, ASUS_WMI_MGMT_GUID, 36) == 0) {\n            snprintf(wmi_method, 5, \"WM%c%c\", g->object_id[0], g->object_id[1]);\n            DBGLOG(\"wmi\", \"parse_WDG found WMI method %s\", wmi_method);\n            return;\n        }\n    }\n\n    // Couldn't find WMI method. Let's assume it's WMNB\n    SYSLOG(\"wmi\", \"parse_WDG couldn't find WMI method\");\n    lilu_os_strncpy(wmi_method, \"WMNB\", 5);\n}\n\nvoid AsusSMC::initATKDevice() {\n    wmi_evaluate_method(ASUS_WMI_METHODID_INIT, 0, 0);\n}\n\nvoid AsusSMC::initALSDevice() {\n    auto dict = IOService::nameMatching(\"AppleACPIPlatformExpert\");\n    if (!dict) {\n        SYSLOG(\"als\", \"WTF? Failed to create matching dictionary\");\n        return;\n    }\n\n    auto acpi = IOService::waitForMatchingService(dict);\n    dict->release();\n\n    if (!acpi) {\n        SYSLOG(\"als\", \"WTF? No ACPI\");\n        return;\n    }\n\n    acpi->release();\n\n    dict = IOService::nameMatching(\"ACPI0008\");\n    if (!dict) {\n        SYSLOG(\"als\", \"WTF? Failed to create matching dictionary\");\n        return;\n    }\n\n    auto deviceIterator = IOService::getMatchingServices(dict);\n    dict->release();\n\n    if (!deviceIterator) {\n        SYSLOG(\"als\", \"No iterator\");\n        return;\n    }\n\n    alsDevice = OSDynamicCast(IOACPIPlatformDevice, deviceIterator->getNextObject());\n    deviceIterator->release();\n\n    if (!alsDevice) {\n        SYSLOG(\"als\", \"ACPI0008 device not found\");\n        return;\n    }\n\n    if (alsDevice->validateObject(\"_ALI\") != kIOReturnSuccess || !refreshALS(false)) {\n        SYSLOG(\"als\", \"No functional method _ALI on ALS device\");\n        return;\n    }\n\n    SYSLOG(\"als\", \"Found ALS Device %s\", alsDevice->getName());\n}\n\nvoid AsusSMC::initEC0Device() {\n    isTACHAvailable = true;\n\n    auto dict = IOService::nameMatching(\"AppleACPIPlatformExpert\");\n    if (!dict) {\n        SYSLOG(\"ec0\", \"WTF? Failed to create matching dictionary\");\n        isTACHAvailable = false;\n        return;\n    }\n\n    auto acpi = IOService::waitForMatchingService(dict);\n    dict->release();\n\n    if (!acpi) {\n        SYSLOG(\"ec0\", \"WTF? No ACPI\");\n        isTACHAvailable = false;\n        return;\n    }\n\n    acpi->release();\n\n    dict = IOService::nameMatching(\"PNP0C09\");\n    if (!dict) {\n        SYSLOG(\"ec0\", \"WTF? Failed to create matching dictionary\");\n        isTACHAvailable = false;\n        return;\n    }\n\n    auto deviceIterator = IOService::getMatchingServices(dict);\n    dict->release();\n\n    if (!deviceIterator) {\n        SYSLOG(\"ec0\", \"No iterator\");\n        isTACHAvailable = false;\n        return;\n    }\n\n    ec0Device = OSDynamicCast(IOACPIPlatformDevice, deviceIterator->getNextObject());\n    deviceIterator->release();\n\n    if (!ec0Device) {\n        SYSLOG(\"ec0\", \"PNP0C09 device not found\");\n        isTACHAvailable = false;\n        return;\n    }\n\n    if (ec0Device->validateObject(\"TACH\") != kIOReturnSuccess || !refreshFan()) {\n        SYSLOG(\"ec0\", \"No functional method TACH on EC0 device\");\n        isTACHAvailable = false;\n        return;\n    }\n\n    SYSLOG(\"ec0\", \"Found EC0 Device %s\", ec0Device->getName());\n}\n\nvoid AsusSMC::initBattery() {\n    // Battery Health was introduced in 10.15.5\n    // Check if we're on 10.15.5+\n    if (getKernelVersion() < KernelVersion::Catalina || (getKernelVersion() == KernelVersion::Catalina && getKernelMinorVersion() < 5)) {\n        return;\n    }\n\n    isBatteryRSOCAvailable = wmi_dev_is_present(ASUS_WMI_DEVID_RSOC);\n    if (isBatteryRSOCAvailable) {\n        toggleBatteryConservativeMode(true);\n    }\n}\n\nvoid AsusSMC::initVirtualKeyboard() {\n    kbdDevice = new VirtualAppleKeyboard;\n\n    if (!kbdDevice || !kbdDevice->init() || !kbdDevice->attach(this) || !kbdDevice->start(this)) {\n        OSSafeReleaseNULL(kbdDevice);\n        SYSLOG(\"vkbd\", \"Failed to init VirtualAppleKeyboard\");\n    }\n}\n\nvoid AsusSMC::startATKDevice() {\n    // Check direct ACPI messaging support\n    if (atkDevice->validateObject(\"DMES\") == kIOReturnSuccess) {\n        DBGLOG(\"atk\", \"Direct ACPI message is supported\");\n        setProperty(\"IsDirectACPIMessagingSupported\", kOSBooleanTrue);\n        directACPImessaging = true;\n    }\n\n    // Check keyboard backlight support\n    if (atkDevice->validateObject(\"SKBV\") == kIOReturnSuccess) {\n        SYSLOG(\"atk\", \"Keyboard backlight is supported\");\n        hasKeyboardBacklight = true;\n    } else {\n        hasKeyboardBacklight = false;\n        DBGLOG(\"atk\", \"Keyboard backlight is not supported\");\n    }\n    setProperty(\"IsKeyboardBacklightSupported\", hasKeyboardBacklight);\n\n    // Turn on ALS sensor\n    toggleALS(true);\n    isALSEnabled = true;\n    setProperty(\"IsALSEnabled\", isALSEnabled);\n    SYSLOG(\"atk\", \"ALS is turned on at boot\");\n}\n\nbool AsusSMC::refreshALS(bool post) {\n    if (!alsDevice) {\n        return false;\n    }\n\n    IOReturn ret = kIOReturnSuccess;\n    uint32_t lux = 150;\n\n    if (isALSEnabled) {\n        ret = alsDevice->evaluateInteger(\"_ALI\", &lux);\n        if (ret != kIOReturnSuccess) {\n            lux = 0xFFFFFFFF; // ACPI invalid\n        }\n    }\n\n    atomic_store_explicit(&currentLux, lux, memory_order_release);\n\n    if (post) {\n        VirtualSMCAPI::postInterrupt(SmcEventALSChange);\n        poller->setTimeoutMS(SensorUpdateTimeoutMS);\n    }\n\n    DBGLOG(\"als\", \"refreshALS lux %u\", lux);\n\n    return ret == kIOReturnSuccess;\n}\n\nbool AsusSMC::refreshFan() {\n    uint32_t speed = 10000;\n\n    if (isTACHAvailable) {\n        OSNumber *arg = OSNumber::withNumber(static_cast<uint32_t>(0), 32);\n        IOReturn ret = ec0Device->evaluateInteger(\"TACH\", &speed, (OSObject **)&arg, 1);\n        arg->release();\n\n        if (ret != kIOReturnSuccess) {\n            DBGLOG(\"fan\", \"read fan speed using TACH failed\");\n            speed = 10000;\n        }\n    } else {\n        int ret = wmi_get_devstate(ASUS_WMI_DEVID_CPU_FAN_CTRL);\n        if (ret == -1) {\n            DBGLOG(\"fan\", \"read fan speed using WMI failed\");\n            speed = 10000;\n        } else {\n            speed = (ret & 0xffff) * 100;\n        }\n    }\n\n    atomic_store_explicit(&currentFanSpeed, speed, memory_order_release);\n\n    DBGLOG(\"fan\", \"refreshFan speed %u\", speed);\n\n    return speed != 10000;\n}\n\nvoid AsusSMC::handleMessage(int code) {\n    switch (code) {\n        case 0x57: // AC disconnected\n        case 0x58: // AC connected\n            // ignore silently\n            break;\n\n        case 0x30: // Volume up\n            dispatchCSMRReport(kHIDUsage_Csmr_VolumeIncrement);\n            break;\n\n        case 0x31: // Volume down\n            dispatchCSMRReport(kHIDUsage_Csmr_VolumeDecrement);\n            break;\n\n        case 0x32: // Mute\n            dispatchCSMRReport(kHIDUsage_Csmr_Mute);\n            break;\n\n        // Media buttons\n        case 0x40:\n        case 0x8A:\n            dispatchCSMRReport(kHIDUsage_Csmr_ScanPreviousTrack);\n            break;\n\n        case 0x41:\n        case 0x82:\n            dispatchCSMRReport(kHIDUsage_Csmr_ScanNextTrack);\n            break;\n\n        case 0x45:\n        case 0x5C:\n            dispatchCSMRReport(kHIDUsage_Csmr_PlayOrPause);\n            break;\n\n        case 0x33: // hardwired On\n        case 0x34: // hardwired Off\n        case 0x35: // Soft Event, Fn + F7\n            displayOff();\n            break;\n\n        case 0x61: // Video Mirror\n            dispatchTCReport(kHIDUsage_AV_TopCase_VideoMirror);\n            break;\n\n        case 0x6B: // Fn + F9, Touchpad On/Off\n            toggleTouchpad();\n            break;\n\n        case 0x5E:\n            letSleep();\n            break;\n\n        case 0x7A: // Fn + A, ALS Sensor\n            // We should really do this in userspace\n            // (e.g. \"Automatically adjust brightness\")\n            isALSEnabled = !isALSEnabled;\n            setProperty(\"IsALSEnabled\", isALSEnabled);\n            break;\n\n        case 0x7D: // Airplane mode\n            toggleAirplaneMode();\n            break;\n\n        case 0xC6:\n        case 0xC7: // ALS Notifcations\n            // ignore\n            break;\n\n        case 0xC5: // Keyboard Backlight Down\n            if (hasKeyboardBacklight) {\n                dispatchTCReport(kHIDUsage_AV_TopCase_IlluminationDown);\n            }\n            break;\n\n        case 0xC4: // Keyboard Backlight Up\n            if (hasKeyboardBacklight) {\n                dispatchTCReport(kHIDUsage_AV_TopCase_IlluminationUp);\n            }\n            break;\n\n        default:\n            if (code >= NOTIFY_BRIGHTNESS_DOWN_MIN && code<= NOTIFY_BRIGHTNESS_DOWN_MAX) // Brightness Down\n                dispatchTCReport(kHIDUsage_AV_TopCase_BrightnessDown);\n            else if (code >= NOTIFY_BRIGHTNESS_UP_MIN && code<= NOTIFY_BRIGHTNESS_UP_MAX) // Brightness Up\n                dispatchTCReport(kHIDUsage_AV_TopCase_BrightnessUp);\n            break;\n    }\n\n    DBGLOG(\"atk\", \"Received key %d(0x%x)\", code, code);\n}\n\nvoid AsusSMC::letSleep() {\n    kev.sendMessage(kDaemonSleep, 0, 0);\n}\n\nvoid AsusSMC::toggleAirplaneMode() {\n    kev.sendMessage(kDaemonAirplaneMode, 0, 0);\n}\n\nvoid AsusSMC::toggleTouchpad() {\n    dispatchMessage(kKeyboardGetTouchStatus, &isTouchpadEnabled);\n    isTouchpadEnabled = !isTouchpadEnabled;\n    dispatchMessage(kKeyboardSetTouchStatus, &isTouchpadEnabled);\n\n    if (isTouchpadEnabled) {\n        setProperty(\"IsTouchpadEnabled\", true);\n        DBGLOG(\"atk\", \"Enabled Touchpad\");\n    } else {\n        setProperty(\"IsTouchpadEnabled\", false);\n        DBGLOG(\"atk\", \"Disabled Touchpad\");\n    }\n}\n\nvoid AsusSMC::toggleALS(bool state) {\n    if (wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, ASUS_WMI_DEVID_ALS_ENABLE, state ? 1 : 0) == -1) {\n        SYSLOG(\"atk\", \"Failed to %s ALSC\", state ? \"enable\" : \"disable\");\n    } else {\n        DBGLOG(\"atk\", \"ALS is %s\", state ? \"enabled\" : \"disabled\");\n    }\n}\n\nvoid AsusSMC::toggleBatteryConservativeMode(bool state) {\n    if (!isBatteryRSOCAvailable) {\n        DBGLOG(\"batt\", \"RSOC unavailable\");\n        return;\n    }\n\n    if (wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, ASUS_WMI_DEVID_RSOC, state ? 80 : 100) != 1) {\n        SYSLOG(\"batt\", \"Failed to %s battery conservative mode\", state ? \"enable\" : \"disable\");\n    } else {\n        DBGLOG(\"batt\", \"Battery conservative mode is %s\", state ? \"enabled\" : \"disabled\");\n        setProperty(\"BatteryConservativeMode\", state);\n    }\n}\n\nvoid AsusSMC::displayOff() {\n    if (isPanelBackLightOn) {\n        // Read Panel brigthness value to restore later with backlight toggle\n        readPanelBrightnessValue();\n\n        dispatchTCReport(kHIDUsage_AV_TopCase_BrightnessDown, 16);\n    } else {\n        dispatchTCReport(kHIDUsage_AV_TopCase_BrightnessUp, panelBrightnessLevel);\n    }\n\n    isPanelBackLightOn = !isPanelBackLightOn;\n}\n\nint AsusSMC::checkBacklightEntry() {\n    if (IORegistryEntry *bkl = IORegistryEntry::fromPath(backlightEntry)) {\n        OSSafeReleaseNULL(bkl);\n        return 1;\n    } else {\n        DBGLOG(\"atk\", \"Failed to find backlight entry for %s\", backlightEntry);\n        return 0;\n    }\n}\n\nint AsusSMC::findBacklightEntry() {\n    // Check for previous found backlight entry\n    if (checkBacklightEntry()) {\n        return 1;\n    }\n\n    snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/IGPU@2/AppleIntelFramebuffer@0/display0/AppleBacklightDisplay\");\n    if (checkBacklightEntry()) {\n        return 1;\n    }\n\n    snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/GFX0@2/AppleIntelFramebuffer@0/display0/AppleBacklightDisplay\");\n    if (checkBacklightEntry()) {\n        return 1;\n    }\n\n    char deviceName[5][5] = {\"PEG0\", \"PEGP\", \"PEGR\", \"P0P2\", \"IXVE\"};\n    for (int i = 0; i < 5; i++) {\n        snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/%s@1/IOPP/GFX0@0/NVDA,Display-A@0/NVDA/display0/AppleBacklightDisplay\", deviceName[i]);\n        if (checkBacklightEntry()) {\n            return 1;\n        }\n\n        snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/%s@3/IOPP/GFX0@0/NVDA,Display-A@0/NVDATesla/display0/AppleBacklightDisplay\", deviceName[i]);\n        if (checkBacklightEntry()) {\n            return 1;\n        }\n\n        snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/%s@10/IOPP/GFX0@0/NVDA,Display-A@0/NVDATesla/display0/AppleBacklightDisplay\", deviceName[i]);\n        if (checkBacklightEntry()) {\n            return 1;\n        }\n\n        snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/%s@1/IOPP/display@0/NVDA,Display-A@0/NVDA/display0/AppleBacklightDisplay\", deviceName[i]);\n        if (checkBacklightEntry()) {\n            return 1;\n        }\n\n        snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/%s@3/IOPP/display@0/NVDA,Display-A@0/NVDATesla/display0/AppleBacklightDisplay\", deviceName[i]);\n        if (checkBacklightEntry()) {\n            return 1;\n        }\n\n        snprintf(backlightEntry, sizeof(backlightEntry), \"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/%s@10/IOPP/display@0/NVDA,Display-A@0/NVDATesla/display0/AppleBacklightDisplay\", deviceName[i]);\n        if (checkBacklightEntry()) {\n            return 1;\n        }\n    }\n\n    return 0;\n}\n\nvoid AsusSMC::readPanelBrightnessValue() {\n    if (!findBacklightEntry()) {\n        DBGLOG(\"atk\", \"GPU device not found\");\n        return;\n    }\n\n    IORegistryEntry *displayDeviceEntry = IORegistryEntry::fromPath(backlightEntry);\n\n    if (displayDeviceEntry) {\n        if (OSDictionary *ioDisplayParaDict = OSDynamicCast(OSDictionary, displayDeviceEntry->getProperty(\"IODisplayParameters\"))) {\n            if (OSDictionary *brightnessDict = OSDynamicCast(OSDictionary, ioDisplayParaDict->getObject(\"brightness\"))) {\n                if (OSNumber *brightnessValue = OSDynamicCast(OSNumber, brightnessDict->getObject(\"value\"))) {\n                    panelBrightnessLevel = brightnessValue->unsigned32BitValue() / 64;\n                    DBGLOG(\"atk\", \"Panel brightness level: %d\", panelBrightnessLevel);\n                } else {\n                    DBGLOG(\"atk\", \"Failed to read brightness value\");\n                }\n            } else {\n                DBGLOG(\"atk\", \"Failed to find dictionary brightness\");\n            }\n        } else {\n            DBGLOG(\"atk\", \"Failed to find dictionary IODisplayParameters\");\n        }\n    }\n    OSSafeReleaseNULL(displayDeviceEntry);\n}\n\nIOReturn AsusSMC::postKeyboardInputReport(const void *report, uint32_t reportSize) {\n    IOReturn result = kIOReturnError;\n\n    if (!report || reportSize == 0) {\n        return kIOReturnBadArgument;\n    }\n\n    if (kbdDevice) {\n        if (auto buffer = IOBufferMemoryDescriptor::withBytes(report, reportSize, kIODirectionNone)) {\n            result = kbdDevice->handleReport(buffer, kIOHIDReportTypeInput, kIOHIDOptionsTypeNone);\n            buffer->release();\n        }\n    }\n\n    return result;\n}\n\nvoid AsusSMC::dispatchCSMRReport(int code, int loop) {\n    DBGLOG(\"atk\", \"Dispatched key %d(0x%x), loop %d time(s)\", code, code, loop);\n    while (loop--) {\n        csmrreport.keys.insert(code);\n        postKeyboardInputReport(&csmrreport, sizeof(csmrreport));\n        csmrreport.keys.erase(code);\n        postKeyboardInputReport(&csmrreport, sizeof(csmrreport));\n    }\n}\n\nvoid AsusSMC::dispatchTCReport(int code, int loop) {\n    DBGLOG(\"atk\", \"Dispatched key %d(0x%x), loop %d time(s)\", code, code, loop);\n    while (loop--) {\n        tcreport.keys.insert(code);\n        postKeyboardInputReport(&tcreport, sizeof(tcreport));\n        tcreport.keys.erase(code);\n        postKeyboardInputReport(&tcreport, sizeof(tcreport));\n    }\n}\n\nvoid AsusSMC::registerNotifications() {\n    auto *key = OSSymbol::withCString(kDeliverNotifications);\n    auto *propertyMatch = propertyMatching(key, kOSBooleanTrue);\n\n    IOServiceMatchingNotificationHandler notificationHandler = OSMemberFunctionCast(IOServiceMatchingNotificationHandler, this, &AsusSMC::notificationHandler);\n\n    _publishNotify = addMatchingNotification(gIOFirstPublishNotification,\n                                             propertyMatch,\n                                             notificationHandler,\n                                             this,\n                                             0, 10000);\n\n    _terminateNotify = addMatchingNotification(gIOTerminatedNotification,\n                                               propertyMatch,\n                                               notificationHandler,\n                                               this,\n                                               0, 10000);\n\n    key->release();\n    propertyMatch->release();\n}\n\nvoid AsusSMC::notificationHandlerGated(IOService *newService, IONotifier *notifier) {\n    if (notifier == _publishNotify) {\n        SYSLOG(\"notify\", \"Notification consumer published: %s\", newService->getName());\n        _notificationServices->setObject(newService);\n    }\n\n    if (notifier == _terminateNotify) {\n        SYSLOG(\"notify\", \"Notification consumer terminated: %s\", newService->getName());\n        _notificationServices->removeObject(newService);\n    }\n}\n\nbool AsusSMC::notificationHandler(void *refCon, IOService *newService, IONotifier *notifier) {\n    command_gate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &AsusSMC::notificationHandlerGated), newService, notifier);\n    return true;\n}\n\nvoid AsusSMC::dispatchMessageGated(int *message, void *data) {\n    OSCollectionIterator *i = OSCollectionIterator::withCollection(_notificationServices);\n\n    if (i != NULL) {\n        while (IOService *service = OSDynamicCast(IOService, i->getNextObject())) {\n            service->message(*message, this, data);\n        }\n        i->release();\n    }\n}\n\nvoid AsusSMC::dispatchMessage(int message, void *data) {\n    command_gate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &AsusSMC::dispatchMessageGated), &message, data);\n}\n\nvoid AsusSMC::registerVSMC() {\n    vsmcNotifier = VirtualSMCAPI::registerHandler(vsmcNotificationHandler, this);\n\n    ALSSensor sensor {ALSSensor::Type::Unknown7, true, 6, false};\n    ALSSensor noSensor {ALSSensor::Type::NoSensor, false, 0, false};\n    SMCALSValue::Value emptyValue;\n    SMCKBrdBLightValue::lkb lkb;\n    SMCKBrdBLightValue::lks lks;\n\n    VirtualSMCAPI::addKey(KeyAL, vsmcPlugin.data, VirtualSMCAPI::valueWithUint16(\n        0, &forceBits,\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE));\n\n    VirtualSMCAPI::addKey(KeyALI0, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&sensor), sizeof(sensor), SmcKeyTypeAli, nullptr,\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyALI1, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&noSensor), sizeof(noSensor), SmcKeyTypeAli, nullptr,\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyALRV, vsmcPlugin.data, VirtualSMCAPI::valueWithUint16(\n        1, nullptr,\n        SMC_KEY_ATTRIBUTE_READ));\n\n    VirtualSMCAPI::addKey(KeyALV0, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&emptyValue), sizeof(emptyValue), SmcKeyTypeAlv, new SMCALSValue(&currentLux, &forceBits),\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyALV1, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&emptyValue), sizeof(emptyValue), SmcKeyTypeAlv, nullptr,\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyLKSB, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&lkb), sizeof(lkb), SmcKeyTypeLkb, new SMCKBrdBLightValue(this),\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyLKSS, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&lks), sizeof(lks), SmcKeyTypeLks, nullptr,\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyMSLD, vsmcPlugin.data, VirtualSMCAPI::valueWithUint8(\n        0, nullptr,\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    VirtualSMCAPI::addKey(KeyFNum, vsmcPlugin.data, VirtualSMCAPI::valueWithUint8(\n        1, nullptr,\n        SMC_KEY_ATTRIBUTE_CONST | SMC_KEY_ATTRIBUTE_READ));\n\n    VirtualSMCAPI::addKey(KeyF0Ac, vsmcPlugin.data, VirtualSMCAPI::valueWithFp(\n        0, SmcKeyTypeFpe2, new F0Ac(&currentFanSpeed),\n        SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_FUNCTION));\n\n    FanTypeDescStruct desc;\n    lilu_os_strncpy(desc.strFunction, \"System Fan\", DiagFunctionStrLen);\n\n    VirtualSMCAPI::addKey(KeyF0ID, vsmcPlugin.data, VirtualSMCAPI::valueWithData(\n        reinterpret_cast<const SMC_DATA *>(&desc), sizeof(desc), SmcKeyTypeFds, nullptr,\n        SMC_KEY_ATTRIBUTE_CONST | SMC_KEY_ATTRIBUTE_READ));\n\n    if (isBatteryRSOCAvailable) {\n        VirtualSMCAPI::addKey(KeyBDVT, vsmcPlugin.data, VirtualSMCAPI::valueWithFlag(\n            false, new BDVT(this),\n            SMC_KEY_ATTRIBUTE_READ | SMC_KEY_ATTRIBUTE_WRITE | SMC_KEY_ATTRIBUTE_ATOMIC));\n    }\n\n    qsort(const_cast<VirtualSMCKeyValue *>(vsmcPlugin.data.data()), vsmcPlugin.data.size(), sizeof(VirtualSMCKeyValue), VirtualSMCKeyValue::compare);\n}\n\nbool AsusSMC::vsmcNotificationHandler(void *sensors, void *refCon, IOService *vsmc, IONotifier *notifier) {\n    if (sensors && vsmc) {\n        DBGLOG(\"atk\", \"got vsmc notification\");\n        auto self = static_cast<AsusSMC *>(sensors);\n        auto ret = vsmc->callPlatformFunction(VirtualSMCAPI::SubmitPlugin, true, sensors, &self->vsmcPlugin, nullptr, nullptr);\n        if (ret == kIOReturnSuccess) {\n            DBGLOG(\"atk\", \"Submitted plugin\");\n\n            self->workloop = self->getWorkLoop();\n            self->poller = IOTimerEventSource::timerEventSource(self, [](OSObject *object, IOTimerEventSource *sender) {\n                auto ls = OSDynamicCast(AsusSMC, object);\n                if (ls) {\n                    ls->refreshALS(true);\n                    ls->refreshFan();\n                }\n            });\n\n            if (!self->poller || !self->workloop) {\n                SYSLOG(\"atk\", \"Failed to create poller or workloop\");\n                return false;\n            }\n\n            if (self->workloop->addEventSource(self->poller) != kIOReturnSuccess) {\n                SYSLOG(\"atk\", \"Failed to add timer event source to workloop\");\n                return false;\n            }\n\n            if (self->poller->setTimeoutMS(SensorUpdateTimeoutMS) != kIOReturnSuccess) {\n                SYSLOG(\"atk\", \"Failed to set timeout\");\n                return false;\n            }\n\n            return true;\n        } else if (ret != kIOReturnUnsupported) {\n            SYSLOG(\"atk\", \"Plugin submission failure %X\", ret);\n        } else {\n            DBGLOG(\"atk\", \"Plugin submission to non vsmc\");\n        }\n    } else {\n        SYSLOG(\"atk\", \"Got null vsmc notification\");\n    }\n\n    return false;\n}\n\nEXPORT extern \"C\" kern_return_t ADDPR(kern_start)(kmod_info_t *, void *) {\n    // Report success but actually do not start and let I/O Kit unload us.\n    // This works better and increases boot speed in some cases.\n    PE_parse_boot_argn(\"liludelay\", &ADDPR(debugPrintDelay), sizeof(ADDPR(debugPrintDelay)));\n    ADDPR(debugEnabled) = checkKernelArgument(\"-vsmcdbg\") || checkKernelArgument(\"-asussmcdbg\");\n    return KERN_SUCCESS;\n}\n\nEXPORT extern \"C\" kern_return_t ADDPR(kern_stop)(kmod_info_t *, void *) {\n    // It is not safe to unload VirtualSMC plugins!\n    return KERN_FAILURE;\n}\n"
  },
  {
    "path": "AsusSMC/AsusSMC.hpp",
    "content": "//\n//  AsusSMC.hpp\n//  AsusSMC\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#ifndef _AsusSMC_hpp\n#define _AsusSMC_hpp\n\n#include <IOKit/IOTimerEventSource.h>\n#include <IOKit/IOCommandGate.h>\n#include <IOKit/acpi/IOACPIPlatformDevice.h>\n#include \"HIDReport.hpp\"\n#include \"HIDUsageTables.h\"\n#include \"VirtualAppleKeyboard.hpp\"\n#include \"KernEventServer.hpp\"\n#include \"KeyImplementations.hpp\"\n\n#define ASUS_WMI_METHODID_DSTS         0x53545344\n#define ASUS_WMI_METHODID_DEVS         0x53564544\n#define ASUS_WMI_METHODID_INIT         0x54494E49\n#define ASUS_WMI_DEVID_ALS_ENABLE      0x00050001\n#define ASUS_WMI_DEVID_CPU_FAN_CTRL    0x00110013\n#define ASUS_WMI_DEVID_RSOC            0x00120057\n#define ASUS_WMI_DSTS_PRESENCE_BIT     0x00010000\n#define ASUS_WMI_MGMT_GUID             \"97845ED0-4E6D-11DE-8A39-0800200C9A66\"\n\n#define kDeliverNotifications \"RM,deliverNotifications\"\n\n#define AsusSMCEventCode 0x8102\n\nclass AsusSMC : public IOService {\n    OSDeclareDefaultStructors(AsusSMC)\n\n    VirtualSMCAPI::Plugin vsmcPlugin {\n        xStringify(PRODUCT_NAME),\n        parseModuleVersion(xStringify(MODULE_VERSION)),\n        VirtualSMCAPI::Version,\n    };\n\npublic:\n    bool init(OSDictionary *dictionary) override;\n    bool start(IOService *provider) override;\n    void stop(IOService *provider) override;\n    IOService *probe(IOService *provider, SInt32 *score) override;\n    IOReturn message(uint32_t type, IOService *provider, void *argument) override;\n\n    void letSleep();\n    void toggleAirplaneMode();\n    void toggleTouchpad();\n    void toggleALS(bool state);\n    void toggleBatteryConservativeMode(bool state);\n    void displayOff();\n\nprivate:\n    struct guid_block {\n        char guid[16];\n        union {\n            char object_id[2];\n            struct {\n                uint8_t notify_id;\n                uint8_t reserved;\n            };\n        };\n        uint8_t instance_count;\n        uint8_t flags;\n    };\n\n    struct wmi_args {\n        uint32_t arg0;\n        uint32_t arg1;\n    } __packed;\n\n    enum {\n        kKeyboardSetTouchStatus = iokit_vendor_specific_msg(100), // set disable/enable touchpad (data is bool*)\n        kKeyboardGetTouchStatus = iokit_vendor_specific_msg(101), // get disable/enable touchpad (data is bool*)\n        kKeyboardKeyPressTime = iokit_vendor_specific_msg(110),   // notify of timestamp a non-modifier key was pressed (data is uint64_t*)\n    };\n\n    enum {\n        kDaemonKeyboardBacklight = 1,\n        kDaemonAirplaneMode = 2,\n        kDaemonSleep = 3,\n        kDaemonTouchpad = 4,\n    };\n\n    static constexpr uint32_t SensorUpdateTimeoutMS {1000};\n\n    static constexpr uint8_t NOTIFY_BRIGHTNESS_UP_MIN = 0x10;\n    static constexpr uint8_t NOTIFY_BRIGHTNESS_UP_MAX = 0x1F;\n\n    static constexpr uint8_t NOTIFY_BRIGHTNESS_DOWN_MIN = 0x20;\n    static constexpr uint8_t NOTIFY_BRIGHTNESS_DOWN_MAX = 0x2F;\n\n    char wmi_method[5];\n    int wmi_parse_guid(const char *in, char *out);\n    int wmi_evaluate_method(uint32_t method_id, uint32_t arg0, uint32_t arg1);\n    int wmi_get_devstate(uint32_t dev_id);\n    bool wmi_dev_is_present(uint32_t dev_id);\n    void parse_WDG();\n\n    void initATKDevice();\n    void initALSDevice();\n    void initEC0Device();\n    void initBattery();\n    void initVirtualKeyboard();\n\n    void startATKDevice();\n    \n    bool refreshALS(bool post);\n    bool refreshFan();\n\n    void handleMessage(int code);\n\n    IOACPIPlatformDevice *atkDevice {nullptr};\n    IOACPIPlatformDevice *alsDevice {nullptr};\n    IOACPIPlatformDevice *ec0Device {nullptr};\n    VirtualAppleKeyboard *kbdDevice {nullptr};\n\n    ALSForceBits forceBits;\n    _Atomic(uint32_t) currentLux = ATOMIC_VAR_INIT(0);\n    _Atomic(uint16_t) currentFanSpeed = ATOMIC_VAR_INIT(0);\n\n    IONotifier *vsmcNotifier {nullptr};\n\n    IOWorkLoop *workloop {nullptr};\n    IOCommandGate *command_gate {nullptr};\n    IOTimerEventSource *poller {nullptr};\n\n    KernEventServer kev;\n\n    consumer_input csmrreport;\n    apple_vendor_top_case_input tcreport;\n\n    bool directACPImessaging {false};\n    bool hasKeyboardBacklight {false};\n    bool isALSEnabled {true};\n    bool isTouchpadEnabled {true};\n    bool isPanelBackLightOn {true};\n    bool isTACHAvailable {false};\n    bool isBatteryRSOCAvailable {false};\n\n    uint32_t panelBrightnessLevel {16};\n    char backlightEntry[1000];\n\n    int checkBacklightEntry();\n    int findBacklightEntry();\n    void readPanelBrightnessValue();\n\n    IOReturn postKeyboardInputReport(const void *report, uint32_t reportSize);\n    void dispatchCSMRReport(int code, int loop = 1);\n    void dispatchTCReport(int code, int loop = 1);\n\n    IONotifier *_publishNotify {nullptr};\n    IONotifier *_terminateNotify {nullptr};\n    OSSet *_notificationServices {nullptr};\n    void registerNotifications(void);\n    void notificationHandlerGated(IOService *newService, IONotifier *notifier);\n    bool notificationHandler(void *refCon, IOService *newService, IONotifier *notifier);\n    void dispatchMessageGated(int *message, void *data);\n    void dispatchMessage(int message, void *data);\n\n    void registerVSMC(void);\n    static bool vsmcNotificationHandler(void *sensors, void *refCon, IOService *vsmc, IONotifier *notifier);\n};\n\n#endif //_AsusSMC_hpp\n"
  },
  {
    "path": "AsusSMC/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>$(DEVELOPMENT_LANGUAGE)</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>KEXT</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>$(MODULE_VERSION)</string>\n\t<key>CFBundleVersion</key>\n\t<string>$(MODULE_VERSION)</string>\n\t<key>IOKitPersonalities</key>\n\t<dict>\n\t\t<key>AsusSMC</key>\n\t\t<dict>\n\t\t\t<key>CFBundleIdentifier</key>\n\t\t\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t\t\t<key>IOClass</key>\n\t\t\t<string>AsusSMC</string>\n\t\t\t<key>IONameMatch</key>\n\t\t\t<array>\n\t\t\t\t<string>PNP0c14</string>\n\t\t\t\t<string>PNP0C14</string>\n\t\t\t\t<string>PnP0C14</string>\n\t\t\t\t<string>pnp0c14</string>\n\t\t\t\t<string>ASUS010</string>\n\t\t\t\t<string>ASUS0100</string>\n\t\t\t\t<string>ASUS0010</string>\n\t\t\t\t<string>ATK0100</string>\n\t\t\t</array>\n\t\t\t<key>IOProbeScore</key>\n\t\t\t<integer>9999</integer>\n\t\t\t<key>IOProviderClass</key>\n\t\t\t<string>IOACPIPlatformDevice</string>\n\t\t</dict>\n\t</dict>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>Copyright © 2018-2020 Le Bao Hiep. All rights reserved.</string>\n\t<key>OSBundleCompatibleVersion</key>\n\t<string>1.0.0</string>\n\t<key>OSBundleLibraries</key>\n\t<dict>\n\t\t<key>as.vit9696.Lilu</key>\n\t\t<string>1.2.0</string>\n\t\t<key>as.vit9696.VirtualSMC</key>\n\t\t<string>1.0.0</string>\n\t\t<key>com.apple.iokit.IOACPIFamily</key>\n\t\t<string>1.0.0d1</string>\n\t\t<key>com.apple.iokit.IOHIDFamily</key>\n\t\t<string>2.0.0</string>\n\t\t<key>com.apple.iokit.IOUSBHostFamily</key>\n\t\t<string>1.0.1</string>\n\t\t<key>com.apple.kpi.bsd</key>\n\t\t<string>12.0.0</string>\n\t\t<key>com.apple.kpi.dsep</key>\n\t\t<string>12.0.0</string>\n\t\t<key>com.apple.kpi.iokit</key>\n\t\t<string>12.0.0</string>\n\t\t<key>com.apple.kpi.libkern</key>\n\t\t<string>12.0.0</string>\n\t\t<key>com.apple.kpi.mach</key>\n\t\t<string>12.0.0</string>\n\t\t<key>com.apple.kpi.unsupported</key>\n\t\t<string>12.0.0</string>\n\t</dict>\n\t<key>OSBundleRequired</key>\n\t<string>Root</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "AsusSMC/KeyImplementations.cpp",
    "content": "//\n//  KeyImplementations.cpp\n//  AsusSMC\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#include \"KeyImplementations.hpp\"\n#include \"AsusSMC.hpp\"\n\nSMC_RESULT SMCALSValue::readAccess() {\n    auto value = reinterpret_cast<Value *>(data);\n    uint32_t lux = atomic_load_explicit(currentLux, memory_order_acquire);\n    uint8_t bits = forceBits->bits();\n\n    if (lux == 0xFFFFFFFF) {\n        value->valid = false;\n    } else {\n        value->valid = true;\n        if (!(bits & ALSForceBits::kALSForceHighGain))\n            value->highGain = true;\n        if (!(bits & ALSForceBits::kALSForceChan))\n            value->chan0 = OSSwapHostToBigInt16(lux);\n        if (!(bits & ALSForceBits::kALSForceLux))\n            value->roomLux = OSSwapHostToBigInt32(lux << 14);\n    }\n\n    return SmcSuccess;\n}\n\nSMC_RESULT SMCKBrdBLightValue::update(const SMC_DATA *src)  {\n    lkb *value = new lkb;\n    lilu_os_memcpy(value, src, size);\n\n    // tval is in range [0x0, 0xffb]\n    uint16_t tval = (value->val1 << 4) | (value->val2 >> 4);\n    DBGLOG(\"lksb\", \"LKSB update %d\", tval);\n\n    delete value;\n\n    if (asusSMCInstance) {\n        asusSMCInstance->message(kSetKeyboardBacklightMessage, nullptr, &tval);\n    }\n\n    lilu_os_memcpy(data, src, size);\n    return SmcSuccess;\n}\n\nSMC_RESULT F0Ac::readAccess() {\n    uint16_t speed = atomic_load_explicit(currentSpeed, memory_order_acquire);\n    *reinterpret_cast<uint16_t *>(data) = VirtualSMCAPI::encodeIntFp(SmcKeyTypeFpe2, speed);\n    return SmcSuccess;\n}\n\nSMC_RESULT BDVT::update(const SMC_DATA *src)  {\n    bool state = false;\n    lilu_os_memcpy(&state, src, size);\n\n    // BDVT is 00 when battery health is enabled and 01 when disabled\n    state = !state;\n\n    AsusSMC *drv = OSDynamicCast(AsusSMC, dst);\n    drv->toggleBatteryConservativeMode(state);\n\n    lilu_os_memcpy(data, src, size);\n    return SmcSuccess;\n}\n"
  },
  {
    "path": "AsusSMC/KeyImplementations.hpp",
    "content": "//\n//  KeyImplementations.hpp\n//  AsusSMC\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n//  Ambient light sensor support is based on SMCLightSensor\n\n#ifndef KeyImplementations_hpp\n#define KeyImplementations_hpp\n\n#include <IOKit/IOService.h>\n#include <VirtualSMCSDK/kern_vsmcapi.hpp>\n\n#define kSetKeyboardBacklightMessage 812002\n\nstatic constexpr SMC_KEY KeyAL   = SMC_MAKE_IDENTIFIER('A','L','!',' ');\nstatic constexpr SMC_KEY KeyALI0 = SMC_MAKE_IDENTIFIER('A','L','I','0');\nstatic constexpr SMC_KEY KeyALI1 = SMC_MAKE_IDENTIFIER('A','L','I','1');\nstatic constexpr SMC_KEY KeyALRV = SMC_MAKE_IDENTIFIER('A','L','R','V');\nstatic constexpr SMC_KEY KeyALV0 = SMC_MAKE_IDENTIFIER('A','L','V','0');\nstatic constexpr SMC_KEY KeyALV1 = SMC_MAKE_IDENTIFIER('A','L','V','1');\nstatic constexpr SMC_KEY KeyLKSB = SMC_MAKE_IDENTIFIER('L','K','S','B');\nstatic constexpr SMC_KEY KeyLKSS = SMC_MAKE_IDENTIFIER('L','K','S','S');\nstatic constexpr SMC_KEY KeyMSLD = SMC_MAKE_IDENTIFIER('M','S','L','D');\n\nstatic constexpr SMC_KEY KeyFNum = SMC_MAKE_IDENTIFIER('F','N','u','m');\nstatic constexpr SMC_KEY KeyF0ID = SMC_MAKE_IDENTIFIER('F','0','I','D');\nstatic constexpr SMC_KEY KeyF0Ac = SMC_MAKE_IDENTIFIER('F','0','A','c');\n\nstatic constexpr SMC_KEY KeyBDVT = SMC_MAKE_IDENTIFIER('B','D','V','T');\n\ntypedef enum { FAN_PWM_TACH, FAN_RPM, PUMP_PWM, PUMP_RPM, FAN_PWM_NOTACH, EMPTY_PLACEHOLDER } FanType;\n\ntypedef enum {\n    LEFT_LOWER_FRONT, CENTER_LOWER_FRONT, RIGHT_LOWER_FRONT,\n    LEFT_MID_FRONT,   CENTER_MID_FRONT,   RIGHT_MID_FRONT,\n    LEFT_UPPER_FRONT, CENTER_UPPER_FRONT, RIGHT_UPPER_FRONT,\n    LEFT_LOWER_REAR,  CENTER_LOWER_REAR,  RIGHT_LOWER_REAR,\n    LEFT_MID_REAR,    CENTER_MID_REAR,    RIGHT_MID_REAR,\n    LEFT_UPPER_REAR,  CENTER_UPPER_REAR,  RIGHT_UPPER_REAR\n} LocationType;\n\nstatic constexpr int32_t DiagFunctionStrLen = 12;\n\ntypedef struct fanTypeDescStruct {\n    uint8_t type        {FAN_RPM};\n    uint8_t ui8Zone     {1};\n    uint8_t location    {LEFT_MID_REAR};\n    uint8_t rsvd        {0}; // padding to get us to 16 bytes\n    char    strFunction[DiagFunctionStrLen];\n} FanTypeDescStruct;\n\nclass ALSForceBits : public VirtualSMCValue {\npublic:\n    enum {\n        kALSForceScale      = 1,\n        kALSForceChan       = 2,\n        kALSForceLux        = 4,\n        kALSForceHighGain   = 8,\n        kALSForceTemp       = 16\n    };\n\n    uint8_t bits() { return data[0]; }\n};\n\nstruct ALSSensor {\n    enum Type : uint8_t {\n        NoSensor  = 0,\n        BS520     = 1,\n        TSL2561CS = 2,\n        LX1973A   = 3,\n        ISL29003  = 4,\n        Unknown7  = 7\n    };\n\n    Type sensorType {Type::NoSensor};\n    bool validWhenLidClosed {false};\n    uint8_t unknown {0};\n    bool controlSIL {false};\n\n    ALSSensor(Type sensorType, bool validWhenLidClosed, uint8_t unknown, bool controlSIL): sensorType(sensorType), validWhenLidClosed(validWhenLidClosed), unknown(unknown), controlSIL(controlSIL) {}\n};\n\nclass SMCALSValue : public VirtualSMCValue {\n    _Atomic(uint32_t) *currentLux;\n    ALSForceBits *forceBits;\n\nprotected:\n    SMC_RESULT readAccess() override;\n\npublic:\n    struct PACKED Value {\n        bool valid {false};\n        bool highGain {true};\n        uint16_t chan0 {0};\n        uint16_t chan1 {0};\n        uint32_t roomLux {0};\n    };\n\n    SMCALSValue(_Atomic(uint32_t) *currentLux, ALSForceBits *forceBits) :\n    currentLux(currentLux), forceBits(forceBits) {}\n};\n\nclass SMCKBrdBLightValue : public VirtualSMCValue {\n    IOService *asusSMCInstance {nullptr};\n\nprotected:\n    SMC_RESULT update(const SMC_DATA *src) override;\n\npublic:\n    struct PACKED lks {\n        uint8_t unknown0 {0};\n        uint8_t unknown1 {1};\n    };\n    struct PACKED lkb {\n        uint8_t val1 {0};\n        uint8_t val2 {1};\n    };\n\n    SMCKBrdBLightValue(IOService *asusSMCInstance): asusSMCInstance(asusSMCInstance) {}\n};\n\nclass F0Ac : public VirtualSMCValue {\n    _Atomic(uint16_t) *currentSpeed;\n\nprotected:\n    SMC_RESULT readAccess() override;\n\npublic:\n    F0Ac(_Atomic(uint16_t) *currentSpeed) : currentSpeed(currentSpeed) {}\n};\n\nclass BDVT : public VirtualSMCValue {\n    IOService *dst {nullptr};\n\nprotected:\n    SMC_RESULT update(const SMC_DATA *src) override;\n\npublic:\n    BDVT(IOService *dst) : dst(dst) {}\n};\n\n#endif /* KeyImplementations_hpp */\n"
  },
  {
    "path": "AsusSMC.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 50;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t4C17428122C85E6E00469B7E /* HIDUsageTables.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C17428022C85E6E00469B7E /* HIDUsageTables.h */; };\n\t\t4C4FCB282326880C0010505E /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4FCB272326880C0010505E /* CoreServices.framework */; };\n\t\t4C4FCB2A232688390010505E /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4FCB29232688390010505E /* AppKit.framework */; };\n\t\t4C4FE6252156A1690074AD08 /* AsusSMC.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4C4FE6242156A1690074AD08 /* AsusSMC.hpp */; };\n\t\t4C4FE6272156A1690074AD08 /* AsusSMC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FE6262156A1690074AD08 /* AsusSMC.cpp */; };\n\t\t4C4FE6A02156A3AD0074AD08 /* KernEventServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FE69E2156A3AD0074AD08 /* KernEventServer.cpp */; };\n\t\t4C4FE6A12156A3AD0074AD08 /* KernEventServer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4C4FE69F2156A3AD0074AD08 /* KernEventServer.hpp */; };\n\t\t4C4FE6A62156A4340074AD08 /* VirtualAppleKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FE6A32156A4340074AD08 /* VirtualAppleKeyboard.cpp */; };\n\t\t4C4FE6A72156A4340074AD08 /* VirtualAppleKeyboard.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4C4FE6A42156A4340074AD08 /* VirtualAppleKeyboard.hpp */; };\n\t\t4C4FE6A82156A4340074AD08 /* HIDReport.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4C4FE6A52156A4340074AD08 /* HIDReport.hpp */; };\n\t\t4C4FE6B62156A4A20074AD08 /* IOBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4FE6B52156A4A20074AD08 /* IOBluetooth.framework */; };\n\t\t4C4FE6B82156A4A70074AD08 /* CoreWLAN.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4FE6B72156A4A70074AD08 /* CoreWLAN.framework */; };\n\t\t4C4FE6BD2156A4FB0074AD08 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FE6BB2156A4FB0074AD08 /* main.m */; };\n\t\t4C4FE6C02156A5820074AD08 /* KeyImplementations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FE6BE2156A5820074AD08 /* KeyImplementations.cpp */; };\n\t\t4C4FE6C12156A5820074AD08 /* KeyImplementations.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4C4FE6BF2156A5820074AD08 /* KeyImplementations.hpp */; };\n\t\t4CA82AB2251A07F300B02E1C /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CA82AB1251A07F000B02E1C /* libkmod.a */; };\n\t\t4CC5A8C2244611E600AB526E /* com.hieplpvip.AsusSMCDaemon.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4C4FE6BC2156A4FB0074AD08 /* com.hieplpvip.AsusSMCDaemon.plist */; };\n\t\t4CC5A8C3244611EA00AB526E /* install_daemon.sh in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4C32364A2159051A00700256 /* install_daemon.sh */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t4C8C666224460F2D00D694EB /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 4C4FE6182156A1690074AD08 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 4C4FE6AC2156A4730074AD08;\n\t\t\tremoteInfo = AsusSMCDaemon;\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t4C4FE6AB2156A4730074AD08 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 12;\n\t\t\tdstPath = usr/share/man/man1;\n\t\t\tdstSubfolderSpec = 16;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4CC5A8C1244611D300AB526E /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 16;\n\t\t\tfiles = (\n\t\t\t\t4CC5A8C2244611E600AB526E /* com.hieplpvip.AsusSMCDaemon.plist in CopyFiles */,\n\t\t\t\t4CC5A8C3244611EA00AB526E /* install_daemon.sh in CopyFiles */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t4C17428022C85E6E00469B7E /* HIDUsageTables.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HIDUsageTables.h; sourceTree = \"<group>\"; };\n\t\t4C27D2BF218B647F0089409B /* LICENSE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = \"<group>\"; };\n\t\t4C32364A2159051A00700256 /* install_daemon.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = install_daemon.sh; sourceTree = \"<group>\"; };\n\t\t4C4FCB272326880C0010505E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };\n\t\t4C4FCB29232688390010505E /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };\n\t\t4C4FE6212156A1690074AD08 /* AsusSMC.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AsusSMC.kext; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t4C4FE6242156A1690074AD08 /* AsusSMC.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AsusSMC.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6262156A1690074AD08 /* AsusSMC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AsusSMC.cpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6282156A1690074AD08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t4C4FE6672156A3610074AD08 /* kern_config.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_config.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6682156A3610074AD08 /* kern_time.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_time.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6692156A3610074AD08 /* kern_nvram.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_nvram.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE66A2156A3610074AD08 /* kern_cpu.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_cpu.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE66B2156A3610074AD08 /* kern_devinfo.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_devinfo.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE66C2156A3610074AD08 /* kern_efi.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_efi.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE66D2156A3610074AD08 /* kern_policy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_policy.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE66E2156A3610074AD08 /* kern_user.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_user.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE66F2156A3610074AD08 /* plugin_start.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = plugin_start.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6702156A3610074AD08 /* kern_iokit.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_iokit.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6712156A3610074AD08 /* kern_crypto.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_crypto.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6722156A3610074AD08 /* kern_mach.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_mach.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6732156A3610074AD08 /* kern_compression.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_compression.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6742156A3610074AD08 /* kern_file.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_file.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6752156A3610074AD08 /* kern_rtc.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_rtc.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6762156A3610074AD08 /* kern_disasm.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_disasm.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6782156A3610074AD08 /* capstone.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = capstone.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6792156A3610074AD08 /* mips.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mips.h; sourceTree = \"<group>\"; };\n\t\t4C4FE67A2156A3610074AD08 /* sparc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sparc.h; sourceTree = \"<group>\"; };\n\t\t4C4FE67B2156A3610074AD08 /* systemz.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = systemz.h; sourceTree = \"<group>\"; };\n\t\t4C4FE67C2156A3610074AD08 /* arm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = arm.h; sourceTree = \"<group>\"; };\n\t\t4C4FE67D2156A3610074AD08 /* x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = x86.h; sourceTree = \"<group>\"; };\n\t\t4C4FE67E2156A3610074AD08 /* ppc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ppc.h; sourceTree = \"<group>\"; };\n\t\t4C4FE67F2156A3610074AD08 /* arm64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = arm64.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6802156A3610074AD08 /* xcore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = xcore.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6812156A3610074AD08 /* platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6822156A3610074AD08 /* kern_patcher.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_patcher.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6852156A3610074AD08 /* kern_compat.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_compat.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6862156A3610074AD08 /* kern_api.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_api.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6872156A3610074AD08 /* kern_util.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_util.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE68B2156A3610074AD08 /* entry64.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = entry64.S; sourceTree = \"<group>\"; };\n\t\t4C4FE68C2156A3620074AD08 /* build.tool */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build.tool; sourceTree = \"<group>\"; };\n\t\t4C4FE68D2156A3620074AD08 /* entry32.S */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = entry32.S; sourceTree = \"<group>\"; };\n\t\t4C4FE68E2156A3620074AD08 /* wrappers.inc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.pascal; path = wrappers.inc; sourceTree = \"<group>\"; };\n\t\t4C4FE6932156A3620074AD08 /* plugin_start.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = plugin_start.cpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6962156A3700074AD08 /* kern_smcinfo.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_smcinfo.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6972156A3700074AD08 /* kern_vsmcapi.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_vsmcapi.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6982156A3700074AD08 /* AppleSmc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleSmc.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6992156A3700074AD08 /* kern_keyvalue.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_keyvalue.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE69A2156A3700074AD08 /* kern_value.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = kern_value.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE69C2156A3700074AD08 /* AppleSmcBridge.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AppleSmcBridge.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE69E2156A3AD0074AD08 /* KernEventServer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KernEventServer.cpp; sourceTree = \"<group>\"; };\n\t\t4C4FE69F2156A3AD0074AD08 /* KernEventServer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = KernEventServer.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6A32156A4340074AD08 /* VirtualAppleKeyboard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VirtualAppleKeyboard.cpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6A42156A4340074AD08 /* VirtualAppleKeyboard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VirtualAppleKeyboard.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6A52156A4340074AD08 /* HIDReport.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HIDReport.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6AD2156A4730074AD08 /* AsusSMCDaemon */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = AsusSMCDaemon; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t4C4FE6B52156A4A20074AD08 /* IOBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOBluetooth.framework; path = System/Library/Frameworks/IOBluetooth.framework; sourceTree = SDKROOT; };\n\t\t4C4FE6B72156A4A70074AD08 /* CoreWLAN.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreWLAN.framework; path = System/Library/Frameworks/CoreWLAN.framework; sourceTree = SDKROOT; };\n\t\t4C4FE6B92156A4FB0074AD08 /* OSD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSD.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6BA2156A4FB0074AD08 /* BezelServices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BezelServices.h; sourceTree = \"<group>\"; };\n\t\t4C4FE6BB2156A4FB0074AD08 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = \"<group>\"; };\n\t\t4C4FE6BC2156A4FB0074AD08 /* com.hieplpvip.AsusSMCDaemon.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.hieplpvip.AsusSMCDaemon.plist; sourceTree = \"<group>\"; };\n\t\t4C4FE6BE2156A5820074AD08 /* KeyImplementations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyImplementations.cpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6BF2156A5820074AD08 /* KeyImplementations.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyImplementations.hpp; sourceTree = \"<group>\"; };\n\t\t4C4FE6C22156AA810074AD08 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = \"<group>\"; };\n\t\t4CA82AB1251A07F000B02E1C /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libkmod.a; path = MacKernelSDK/Library/x86_64/libkmod.a; sourceTree = \"<group>\"; };\n\t\t4CDDD8C822E899F700CC38F4 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t4C4FE61E2156A1690074AD08 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4CA82AB2251A07F300B02E1C /* libkmod.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4C4FE6AA2156A4730074AD08 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4C4FCB2A232688390010505E /* AppKit.framework in Frameworks */,\n\t\t\t\t4C4FCB282326880C0010505E /* CoreServices.framework in Frameworks */,\n\t\t\t\t4C4FE6B82156A4A70074AD08 /* CoreWLAN.framework in Frameworks */,\n\t\t\t\t4C4FE6B62156A4A20074AD08 /* IOBluetooth.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t4C4FE6172156A1690074AD08 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4CE3969E22CCAB5C00693C33 /* Global */,\n\t\t\t\t4C4FE6232156A1690074AD08 /* AsusSMC */,\n\t\t\t\t4C4FE6AE2156A4730074AD08 /* AsusSMCDaemon */,\n\t\t\t\t4C4FE69D2156A3970074AD08 /* KernEventServer */,\n\t\t\t\t4C4FE6A22156A4270074AD08 /* VirtualAppleKeyboard */,\n\t\t\t\t4C4FE62E2156A2980074AD08 /* SDK */,\n\t\t\t\t4C4FE6222156A1690074AD08 /* Products */,\n\t\t\t\t4C4FE6B42156A4A20074AD08 /* Frameworks */,\n\t\t\t\t4C4FE6C22156AA810074AD08 /* README.md */,\n\t\t\t\t4CDDD8C822E899F700CC38F4 /* CHANGELOG.md */,\n\t\t\t\t4C27D2BF218B647F0089409B /* LICENSE.md */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6222156A1690074AD08 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6212156A1690074AD08 /* AsusSMC.kext */,\n\t\t\t\t4C4FE6AD2156A4730074AD08 /* AsusSMCDaemon */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6232156A1690074AD08 /* AsusSMC */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6262156A1690074AD08 /* AsusSMC.cpp */,\n\t\t\t\t4C4FE6242156A1690074AD08 /* AsusSMC.hpp */,\n\t\t\t\t4C4FE6BE2156A5820074AD08 /* KeyImplementations.cpp */,\n\t\t\t\t4C4FE6BF2156A5820074AD08 /* KeyImplementations.hpp */,\n\t\t\t\t4C4FE6282156A1690074AD08 /* Info.plist */,\n\t\t\t);\n\t\t\tpath = AsusSMC;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE62E2156A2980074AD08 /* SDK */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6952156A3700074AD08 /* VirtualSMCSDK */,\n\t\t\t\t4C4FE6662156A3610074AD08 /* Headers */,\n\t\t\t\t4C4FE6882156A3610074AD08 /* Library */,\n\t\t\t);\n\t\t\tname = SDK;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6662156A3610074AD08 /* Headers */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6672156A3610074AD08 /* kern_config.hpp */,\n\t\t\t\t4C4FE6682156A3610074AD08 /* kern_time.hpp */,\n\t\t\t\t4C4FE6692156A3610074AD08 /* kern_nvram.hpp */,\n\t\t\t\t4C4FE66A2156A3610074AD08 /* kern_cpu.hpp */,\n\t\t\t\t4C4FE66B2156A3610074AD08 /* kern_devinfo.hpp */,\n\t\t\t\t4C4FE66C2156A3610074AD08 /* kern_efi.hpp */,\n\t\t\t\t4C4FE66D2156A3610074AD08 /* kern_policy.hpp */,\n\t\t\t\t4C4FE66E2156A3610074AD08 /* kern_user.hpp */,\n\t\t\t\t4C4FE66F2156A3610074AD08 /* plugin_start.hpp */,\n\t\t\t\t4C4FE6702156A3610074AD08 /* kern_iokit.hpp */,\n\t\t\t\t4C4FE6712156A3610074AD08 /* kern_crypto.hpp */,\n\t\t\t\t4C4FE6722156A3610074AD08 /* kern_mach.hpp */,\n\t\t\t\t4C4FE6732156A3610074AD08 /* kern_compression.hpp */,\n\t\t\t\t4C4FE6742156A3610074AD08 /* kern_file.hpp */,\n\t\t\t\t4C4FE6752156A3610074AD08 /* kern_rtc.hpp */,\n\t\t\t\t4C4FE6762156A3610074AD08 /* kern_disasm.hpp */,\n\t\t\t\t4C4FE6772156A3610074AD08 /* capstone */,\n\t\t\t\t4C4FE6822156A3610074AD08 /* kern_patcher.hpp */,\n\t\t\t\t4C4FE6852156A3610074AD08 /* kern_compat.hpp */,\n\t\t\t\t4C4FE6862156A3610074AD08 /* kern_api.hpp */,\n\t\t\t\t4C4FE6872156A3610074AD08 /* kern_util.hpp */,\n\t\t\t);\n\t\t\tname = Headers;\n\t\t\tpath = Lilu.kext/Contents/Resources/Headers;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6772156A3610074AD08 /* capstone */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6782156A3610074AD08 /* capstone.h */,\n\t\t\t\t4C4FE6792156A3610074AD08 /* mips.h */,\n\t\t\t\t4C4FE67A2156A3610074AD08 /* sparc.h */,\n\t\t\t\t4C4FE67B2156A3610074AD08 /* systemz.h */,\n\t\t\t\t4C4FE67C2156A3610074AD08 /* arm.h */,\n\t\t\t\t4C4FE67D2156A3610074AD08 /* x86.h */,\n\t\t\t\t4C4FE67E2156A3610074AD08 /* ppc.h */,\n\t\t\t\t4C4FE67F2156A3610074AD08 /* arm64.h */,\n\t\t\t\t4C4FE6802156A3610074AD08 /* xcore.h */,\n\t\t\t\t4C4FE6812156A3610074AD08 /* platform.h */,\n\t\t\t);\n\t\t\tpath = capstone;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6882156A3610074AD08 /* Library */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE68A2156A3610074AD08 /* wrappers */,\n\t\t\t\t4C4FE6932156A3620074AD08 /* plugin_start.cpp */,\n\t\t\t);\n\t\t\tname = Library;\n\t\t\tpath = Lilu.kext/Contents/Resources/Library;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE68A2156A3610074AD08 /* wrappers */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE68B2156A3610074AD08 /* entry64.S */,\n\t\t\t\t4C4FE68C2156A3620074AD08 /* build.tool */,\n\t\t\t\t4C4FE68D2156A3620074AD08 /* entry32.S */,\n\t\t\t\t4C4FE68E2156A3620074AD08 /* wrappers.inc */,\n\t\t\t);\n\t\t\tpath = wrappers;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6952156A3700074AD08 /* VirtualSMCSDK */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6962156A3700074AD08 /* kern_smcinfo.hpp */,\n\t\t\t\t4C4FE6972156A3700074AD08 /* kern_vsmcapi.hpp */,\n\t\t\t\t4C4FE6982156A3700074AD08 /* AppleSmc.h */,\n\t\t\t\t4C4FE6992156A3700074AD08 /* kern_keyvalue.hpp */,\n\t\t\t\t4C4FE69A2156A3700074AD08 /* kern_value.hpp */,\n\t\t\t\t4C4FE69C2156A3700074AD08 /* AppleSmcBridge.hpp */,\n\t\t\t);\n\t\t\tname = VirtualSMCSDK;\n\t\t\tpath = VirtualSMC.kext/Contents/Resources/VirtualSMCSDK;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE69D2156A3970074AD08 /* KernEventServer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE69E2156A3AD0074AD08 /* KernEventServer.cpp */,\n\t\t\t\t4C4FE69F2156A3AD0074AD08 /* KernEventServer.hpp */,\n\t\t\t);\n\t\t\tpath = KernEventServer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6A22156A4270074AD08 /* VirtualAppleKeyboard */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6A32156A4340074AD08 /* VirtualAppleKeyboard.cpp */,\n\t\t\t\t4C4FE6A42156A4340074AD08 /* VirtualAppleKeyboard.hpp */,\n\t\t\t);\n\t\t\tpath = VirtualAppleKeyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6AE2156A4730074AD08 /* AsusSMCDaemon */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C4FE6BA2156A4FB0074AD08 /* BezelServices.h */,\n\t\t\t\t4C4FE6BC2156A4FB0074AD08 /* com.hieplpvip.AsusSMCDaemon.plist */,\n\t\t\t\t4C32364A2159051A00700256 /* install_daemon.sh */,\n\t\t\t\t4C4FE6BB2156A4FB0074AD08 /* main.m */,\n\t\t\t\t4C4FE6B92156A4FB0074AD08 /* OSD.h */,\n\t\t\t);\n\t\t\tpath = AsusSMCDaemon;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4C4FE6B42156A4A20074AD08 /* Frameworks */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4CA82AB1251A07F000B02E1C /* libkmod.a */,\n\t\t\t\t4C4FCB29232688390010505E /* AppKit.framework */,\n\t\t\t\t4C4FCB272326880C0010505E /* CoreServices.framework */,\n\t\t\t\t4C4FE6B72156A4A70074AD08 /* CoreWLAN.framework */,\n\t\t\t\t4C4FE6B52156A4A20074AD08 /* IOBluetooth.framework */,\n\t\t\t);\n\t\t\tname = Frameworks;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4CE3969E22CCAB5C00693C33 /* Global */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4C17428022C85E6E00469B7E /* HIDUsageTables.h */,\n\t\t\t\t4C4FE6A52156A4340074AD08 /* HIDReport.hpp */,\n\t\t\t);\n\t\t\tpath = Global;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t4C4FE61C2156A1690074AD08 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4C4FE6A82156A4340074AD08 /* HIDReport.hpp in Headers */,\n\t\t\t\t4C4FE6A12156A3AD0074AD08 /* KernEventServer.hpp in Headers */,\n\t\t\t\t4C17428122C85E6E00469B7E /* HIDUsageTables.h in Headers */,\n\t\t\t\t4C4FE6252156A1690074AD08 /* AsusSMC.hpp in Headers */,\n\t\t\t\t4C4FE6C12156A5820074AD08 /* KeyImplementations.hpp in Headers */,\n\t\t\t\t4C4FE6A72156A4340074AD08 /* VirtualAppleKeyboard.hpp in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t4C4FE6202156A1690074AD08 /* AsusSMC */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4C4FE62B2156A1690074AD08 /* Build configuration list for PBXNativeTarget \"AsusSMC\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t4C4FE61C2156A1690074AD08 /* Headers */,\n\t\t\t\t4C4FE61D2156A1690074AD08 /* Sources */,\n\t\t\t\t4C4FE61E2156A1690074AD08 /* Frameworks */,\n\t\t\t\t4C4FE61F2156A1690074AD08 /* Resources */,\n\t\t\t\t4CC5A8C1244611D300AB526E /* CopyFiles */,\n\t\t\t\t4C8C666424460F3C00D694EB /* Archive */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t4C8C666324460F2D00D694EB /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = AsusSMC;\n\t\t\tproductName = AsusSMC;\n\t\t\tproductReference = 4C4FE6212156A1690074AD08 /* AsusSMC.kext */;\n\t\t\tproductType = \"com.apple.product-type.kernel-extension\";\n\t\t};\n\t\t4C4FE6AC2156A4730074AD08 /* AsusSMCDaemon */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4C4FE6B12156A4730074AD08 /* Build configuration list for PBXNativeTarget \"AsusSMCDaemon\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t4C4FE6A92156A4730074AD08 /* Sources */,\n\t\t\t\t4C4FE6AA2156A4730074AD08 /* Frameworks */,\n\t\t\t\t4C4FE6AB2156A4730074AD08 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = AsusSMCDaemon;\n\t\t\tproductName = AsusSMCDaemon;\n\t\t\tproductReference = 4C4FE6AD2156A4730074AD08 /* AsusSMCDaemon */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t4C4FE6182156A1690074AD08 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 1200;\n\t\t\t\tORGANIZATIONNAME = \"Le Bao Hiep\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t4C4FE6202156A1690074AD08 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 10.0;\n\t\t\t\t\t};\n\t\t\t\t\t4C4FE6AC2156A4730074AD08 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 10.0;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 4C4FE61B2156A1690074AD08 /* Build configuration list for PBXProject \"AsusSMC\" */;\n\t\t\tcompatibilityVersion = \"Xcode 9.3\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 4C4FE6172156A1690074AD08;\n\t\t\tproductRefGroup = 4C4FE6222156A1690074AD08 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t4C4FE6202156A1690074AD08 /* AsusSMC */,\n\t\t\t\t4C4FE6AC2156A4730074AD08 /* AsusSMCDaemon */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t4C4FE61F2156A1690074AD08 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t4C8C666424460F3C00D694EB /* Archive */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputFileListPaths = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\tname = Archive;\n\t\t\toutputFileListPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"cd \\\"${TARGET_BUILD_DIR}\\\"\\n\\narchive=\\\"${PRODUCT_NAME}-${MODULE_VERSION}-$(echo $CONFIGURATION | tr /a-z/ /A-Z/).zip\\\"\\nrm -rf *.zip\\nif [ \\\"$CONFIGURATION\\\" == \\\"Release\\\" ]; then\\n  strip -x -T \\\"${EXECUTABLE_PATH}\\\" &>/dev/null || strip -x \\\"${EXECUTABLE_PATH}\\\"\\nfi\\nzip -qry -FS \\\"${archive}\\\" *\\n\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t4C4FE61D2156A1690074AD08 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4C4FE6272156A1690074AD08 /* AsusSMC.cpp in Sources */,\n\t\t\t\t4C4FE6C02156A5820074AD08 /* KeyImplementations.cpp in Sources */,\n\t\t\t\t4C4FE6A62156A4340074AD08 /* VirtualAppleKeyboard.cpp in Sources */,\n\t\t\t\t4C4FE6A02156A3AD0074AD08 /* KernEventServer.cpp in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4C4FE6A92156A4730074AD08 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4C4FE6BD2156A4FB0074AD08 /* main.m in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t4C8C666324460F2D00D694EB /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 4C4FE6AC2156A4730074AD08 /* AsusSMCDaemon */;\n\t\t\ttargetProxy = 4C8C666224460F2D00D694EB /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\t4C4FE6292156A1690074AD08 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1.4.1;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tKERNEL_EXTENSION_HEADER_SEARCH_PATHS = \"$(PROJECT_DIR)/MacKernelSDK/Headers\";\n\t\t\t\tKERNEL_FRAMEWORK_HEADERS = \"$(PROJECT_DIR)/MacKernelSDK/Headers\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"$(PROJECT_DIR)/MacKernelSDK/Library/x86_64\";\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.11;\n\t\t\t\tMODULE_VERSION = 1.4.1;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4C4FE62A2156A1690074AD08 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1.4.1;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tKERNEL_EXTENSION_HEADER_SEARCH_PATHS = \"$(PROJECT_DIR)/MacKernelSDK/Headers\";\n\t\t\t\tKERNEL_FRAMEWORK_HEADERS = \"$(PROJECT_DIR)/MacKernelSDK/Headers\";\n\t\t\t\tLIBRARY_SEARCH_PATHS = \"$(PROJECT_DIR)/MacKernelSDK/Library/x86_64\";\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.11;\n\t\t\t\tMODULE_VERSION = 1.4.1;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4C4FE62C2156A1690074AD08 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ANALYZER_DEADCODE_DEADSTORES = NO;\n\t\t\t\tCLANG_ANALYZER_DIVIDE_BY_ZERO = NO;\n\t\t\t\tCLANG_ANALYZER_NULL_DEREFERENCE = NO;\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"MODULE_VERSION=$(MODULE_VERSION)\",\n\t\t\t\t\t\"PRODUCT_NAME=$(PRODUCT_NAME)\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t\"$(PROJECT_DIR)/VirtualSMC.kext/Contents/Resources/\",\n\t\t\t\t\t\"$(PROJECT_DIR)/Lilu.kext/Contents/Resources/\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = AsusSMC/Info.plist;\n\t\t\t\tMODULE_NAME = com.hieplpvip.AsusSMC;\n\t\t\t\tMODULE_START = \"$(PRODUCT_NAME)_kern_start\";\n\t\t\t\tMODULE_STOP = \"$(PRODUCT_NAME)_kern_stop\";\n\t\t\t\tOTHER_CPLUSPLUSFLAGS = \"-Wno-inconsistent-missing-override\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.hieplpvip.AsusSMC;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tRUN_CLANG_STATIC_ANALYZER = YES;\n\t\t\t\tWRAPPER_EXTENSION = kext;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4C4FE62D2156A1690074AD08 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"MODULE_VERSION=$(MODULE_VERSION)\",\n\t\t\t\t\t\"PRODUCT_NAME=$(PRODUCT_NAME)\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t\"$(PROJECT_DIR)/VirtualSMC.kext/Contents/Resources/\",\n\t\t\t\t\t\"$(PROJECT_DIR)/Lilu.kext/Contents/Resources/\",\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = AsusSMC/Info.plist;\n\t\t\t\tMODULE_NAME = com.hieplpvip.AsusSMC;\n\t\t\t\tMODULE_START = \"$(PRODUCT_NAME)_kern_start\";\n\t\t\t\tMODULE_STOP = \"$(PRODUCT_NAME)_kern_stop\";\n\t\t\t\tOTHER_CPLUSPLUSFLAGS = \"-Wno-inconsistent-missing-override\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.hieplpvip.AsusSMC;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tWRAPPER_EXTENSION = kext;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4C4FE6B22156A4730074AD08 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tINFOPLIST_FILE = AsusSMCDaemon/com.hieplpvip.AsusSMCDaemon.plist;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4C4FE6B32156A4730074AD08 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tINFOPLIST_FILE = AsusSMCDaemon/com.hieplpvip.AsusSMCDaemon.plist;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t4C4FE61B2156A1690074AD08 /* Build configuration list for PBXProject \"AsusSMC\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4C4FE6292156A1690074AD08 /* Debug */,\n\t\t\t\t4C4FE62A2156A1690074AD08 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4C4FE62B2156A1690074AD08 /* Build configuration list for PBXNativeTarget \"AsusSMC\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4C4FE62C2156A1690074AD08 /* Debug */,\n\t\t\t\t4C4FE62D2156A1690074AD08 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4C4FE6B12156A4730074AD08 /* Build configuration list for PBXNativeTarget \"AsusSMCDaemon\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4C4FE6B22156A4730074AD08 /* Debug */,\n\t\t\t\t4C4FE6B32156A4730074AD08 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 4C4FE6182156A1690074AD08 /* Project object */;\n}\n"
  },
  {
    "path": "AsusSMCDaemon/BezelServices.h",
    "content": "//\n//  BezelServices.h\n//  AsusSMCDaemon\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#ifndef BezelServices_h\n#define BezelServices_h\n\ntypedef enum {\n    BSGraphicBacklightMeter                         = 0xfffffff7,\n    BSGraphicBacklightFailure                       = 0xfffffff6,\n    BSGraphicBacklightFailureMessage                = 0xfffffff3,\n    BSGraphicBacklightDoubleFailureMessage          = 0xfffffff2,\n    BSGraphicKeyboardBacklightMeter                 = 0xfffffff1,\n    BSGraphicKeyboardBacklightDisabledMeter         = 0xfffffff0,\n    BSGraphicKeyboardBacklightNotConnected          = 0xffffffef,\n    BSGraphicKeyboardBacklightDisabledNotConnected  = 0xffffffee,\n    BSGraphicMacProOpen                             = 0xffffffe9,\n    BSGraphicSpeakerMuted                           = 0xffffffe8,\n    BSGraphicSpeaker                                = 0xffffffe7,\n    BSGraphicRemoteBattery                          = 0xffffffe6,\n    BSGraphicHotspot                                = 0xffffffe5,\n    BSGraphicSleep                                  = 0xffffffe3,\n    BSGraphicSpeakerDisabledMuted                   = 0xffffffe2,\n    BSGraphicSpeakerDisabled                        = 0xffffffe1,\n    BSGraphicSpeakerMeter                           = 0xffffffe0,\n    BSGraphicNewRemoteBattery                       = 0xffffffcb,\n} BSGraphic;\n\nextern void *BSDoGraphicWithMessage(CGDirectDisplayID arg0, BSGraphic arg1, int arg2, const char *arg3, int length);\nextern void *BSDoGraphicWithMeterAndTimeout(CGDirectDisplayID arg0, BSGraphic arg1, int arg2, float v, int timeout);\n\n#endif /* BezelServices_h */\n"
  },
  {
    "path": "AsusSMCDaemon/OSD.h",
    "content": "//\n//  OSD.h\n//  AsusSMCDaemon\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#ifndef OSD_h\n#define OSD_h\n\ntypedef enum {\n    OSDGraphicBacklight                              = 1, // 1, 2, 7, 8\n    OSDGraphicSpeaker                                = 3, // 3, 5, 17, 23\n    OSDGraphicSpeakerMuted                           = 4, // 4, 16, 21, 22\n    OSDGraphicEject                                  = 6,\n    OSDGraphicNoWiFi                                 = 9,\n    OSDGraphicKeyboardBacklightMeter                 = 11, // 11, 25\n    OSDGraphicKeyboardBacklightDisabledMeter         = 12, // 12, 26\n    OSDGraphicKeyboardBacklightNotConnected          = 13, // 13, 27\n    OSDGraphicKeyboardBacklightDisabledNotConnected  = 14, // 14, 28\n    OSDGraphicMacProOpen                             = 15,\n    OSDGraphicHotspot                                = 19,\n    OSDGraphicSleep                                  = 20,\n    // There may be more\n} OSDGraphic;\n\ntypedef enum {\n    OSDPriorityDefault = 0x1f4\n} OSDPriority;\n\n@interface OSDManager : NSObject\n+ (instancetype)sharedManager;\n- (void)showImage:(OSDGraphic)image onDisplayID:(CGDirectDisplayID)display priority:(OSDPriority)priority msecUntilFade:(int)timeout;\n- (void)showImage:(OSDGraphic)image onDisplayID:(CGDirectDisplayID)display priority:(OSDPriority)priority msecUntilFade:(int)timeout withText:(NSString *)text;\n- (void)showImage:(OSDGraphic)image onDisplayID:(CGDirectDisplayID)display priority:(OSDPriority)priority msecUntilFade:(int)timeout filledChiclets:(int)filled totalChiclets:(int)total locked:(BOOL)locked;\n@end\n\n#endif /* OSD_h */\n"
  },
  {
    "path": "AsusSMCDaemon/com.hieplpvip.AsusSMCDaemon.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>KeepAlive</key>\n\t<true/>\n\t<key>Label</key>\n\t<string>com.hieplpvip.AsusSMCDaemon</string>\n\t<key>ProgramArguments</key>\n\t<array>\n\t\t<string>/usr/local/bin/AsusSMCDaemon</string>\n\t</array>\n\t<key>RunAtLoad</key>\n\t<true/>\n\t<key>ServiceIPC</key>\n\t<false/>\n</dict>\n</plist>\n"
  },
  {
    "path": "AsusSMCDaemon/install_daemon.sh",
    "content": "#!/bin/bash\nDIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" >/dev/null && pwd )\"\n\n# remove AsusFnKeysDaemon\nsudo launchctl unload /Library/LaunchAgents/com.hieplpvip.AsusFnKeysDaemon.plist 2>/dev/null\nsudo pkill -f AsusFnKeysDaemon\nsudo rm /usr/bin/AsusFnKeysDaemon 2>/dev/null\nsudo rm /Library/LaunchAgents/com.hieplpvip.AsusFnKeysDaemon.plist 2>/dev/null\n\n# remove old AsusSMCDaemon\nsudo launchctl unload /Library/LaunchAgents/com.hieplpvip.AsusSMCDaemon.plist 2>/dev/null\nsudo rm /usr/bin/AsusSMCDaemon 2>/dev/null\n\nsudo mkdir -p /usr/local/bin/\nsudo chmod -R 755 /usr/local/bin/\nsudo cp $DIR/AsusSMCDaemon /usr/local/bin/\nsudo chmod 755 /usr/local/bin/AsusSMCDaemon\nsudo chown root:wheel /usr/local/bin/AsusSMCDaemon\nsudo xattr -d com.apple.quarantine /usr/local/bin/AsusSMCDaemon 2>/dev/null\n\nsudo cp $DIR/com.hieplpvip.AsusSMCDaemon.plist /Library/LaunchAgents\nsudo chmod 644 /Library/LaunchAgents/com.hieplpvip.AsusSMCDaemon.plist\nsudo chown root:wheel /Library/LaunchAgents/com.hieplpvip.AsusSMCDaemon.plist\nsudo xattr -d com.apple.quarantine /Library/LaunchAgents/com.hieplpvip.AsusSMCDaemon.plist 2>/dev/null\n\nsudo launchctl load /Library/LaunchAgents/com.hieplpvip.AsusSMCDaemon.plist\n"
  },
  {
    "path": "AsusSMCDaemon/main.m",
    "content": "//\n//  main.m\n//  AsusSMCDaemon\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#define AsusSMCEventCode 0x8102\n\n#import <Cocoa/Cocoa.h>\n#import <CoreWLAN/CoreWLAN.h>\n#import <CoreServices/CoreServices.h>\n#import <sys/ioctl.h>\n#import <sys/socket.h>\n#import <sys/kern_event.h>\n#import <dlfcn.h>\n#import \"BezelServices.h\"\n#import \"OSD.h\"\n\n/*\n *    kAERestart        will cause system to restart\n *    kAEShutDown       will cause system to shutdown\n *    kAEReallyLogout   will cause system to logout\n *    kAESleep          will cause system to sleep\n */\nextern OSStatus MDSendAppleEventToSystemProcess(AEEventID eventToSend);\n\n// requires IOBluetooth.framework\nvoid IOBluetoothPreferenceSetControllerPowerState(int);\nint IOBluetoothPreferenceGetControllerPowerState(void);\n\nstatic void *(*_BSDoGraphicWithMeterAndTimeout)(CGDirectDisplayID arg0, BSGraphic arg1, int arg2, float v, int timeout) = NULL;\n\nenum {\n    kDaemonKeyboardBacklight = 1,\n    kDaemonAirplaneMode = 2,\n    kDaemonSleep = 3,\n    kDaemonTouchpad = 4,\n};\n\nstruct AsusSMCMessage {\n    int type;\n    int x;\n    int y;\n};\n\nconst int kMaxDisplays = 16;\nu_int32_t vendorID = 0;\n\nbool _loadBezelServices() {\n    // Load BezelServices framework\n    void *handle = dlopen(\"/System/Library/PrivateFrameworks/BezelServices.framework/Versions/A/BezelServices\", RTLD_GLOBAL);\n    if (!handle) {\n        NSLog(@\"Error opening framework\");\n        return NO;\n    } else {\n        _BSDoGraphicWithMeterAndTimeout = dlsym(handle, \"BSDoGraphicWithMeterAndTimeout\");\n        return _BSDoGraphicWithMeterAndTimeout != NULL;\n    }\n}\n\nbool _loadOSDFramework() {\n    return [[NSBundle bundleWithPath:@\"/System/Library/PrivateFrameworks/OSD.framework\"] load];\n}\n\nOSStatus MDSendAppleEventToSystemProcess(AEEventID eventToSendID) {\n    AEAddressDesc targetDesc;\n    static const ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess };\n    AppleEvent eventReply = {typeNull, NULL};\n    AppleEvent eventToSend = {typeNull, NULL};\n\n    OSStatus status = AECreateDesc(typeProcessSerialNumber,\n                                   &kPSNOfSystemProcess, sizeof(kPSNOfSystemProcess), &targetDesc);\n\n    if (status != noErr) return status;\n\n    status = AECreateAppleEvent(kCoreEventClass, eventToSendID,\n                                &targetDesc, kAutoGenerateReturnID, kAnyTransactionID, &eventToSend);\n\n    AEDisposeDesc(&targetDesc);\n\n    if (status != noErr) return status;\n\n    status = AESendMessage(&eventToSend, &eventReply,\n                           kAENormalPriority, kAEDefaultTimeout);\n\n    AEDisposeDesc(&eventToSend);\n    if (status != noErr) return status;\n    AEDisposeDesc(&eventReply);\n    return status;\n}\n\nvoid showBezelServices(BSGraphic image, float filled) {\n    CGDirectDisplayID currentDisplayId = [NSScreen.mainScreen.deviceDescription [@\"NSScreenNumber\"] unsignedIntValue];\n    _BSDoGraphicWithMeterAndTimeout(currentDisplayId, image, 0x0, filled, 1);\n}\n\nvoid showOSD(OSDGraphic image, int filled, int total) {\n    CGDirectDisplayID currentDisplayId = [NSScreen.mainScreen.deviceDescription [@\"NSScreenNumber\"] unsignedIntValue];\n    [[NSClassFromString(@\"OSDManager\") sharedManager] showImage:image onDisplayID:currentDisplayId priority:OSDPriorityDefault msecUntilFade:1000 filledChiclets:filled totalChiclets:total locked:NO];\n}\n\nvoid showKBoardBLightStatus(int level, int max) {\n    if (_BSDoGraphicWithMeterAndTimeout != NULL) {\n        // El Capitan and probably older systems\n        if (level)\n            showBezelServices(BSGraphicKeyboardBacklightMeter, (float)level/max);\n        else\n            showBezelServices(BSGraphicKeyboardBacklightDisabledMeter, 0);\n    } else {\n        // Sierra+\n        if (level)\n            showOSD(OSDGraphicKeyboardBacklightMeter, level, max);\n        else\n            showOSD(OSDGraphicKeyboardBacklightDisabledMeter, level, max);\n    }\n}\n\nvoid goToSleep() {\n    if (_BSDoGraphicWithMeterAndTimeout != NULL) // El Capitan and probably older systems\n        MDSendAppleEventToSystemProcess(kAESleep);\n    else {\n        // Sierra+\n        CGDirectDisplayID currentDisplayId = [NSScreen.mainScreen.deviceDescription [@\"NSScreenNumber\"] unsignedIntValue];\n        [[NSClassFromString(@\"OSDManager\") sharedManager] showImage:OSDGraphicSleep onDisplayID:currentDisplayId priority:OSDPriorityDefault msecUntilFade:1000];\n    }\n}\n\nBOOL airplaneModeEnabled = NO, lastWifiState;\nint lastBluetoothState;\nvoid toggleAirplaneMode() {\n    airplaneModeEnabled = !airplaneModeEnabled;\n\n    CWInterface *currentInterface = [CWWiFiClient.sharedWiFiClient interface];\n    NSError *err = nil;\n\n    if (airplaneModeEnabled) {\n        lastWifiState = currentInterface.powerOn;\n        lastBluetoothState = IOBluetoothPreferenceGetControllerPowerState();\n        [currentInterface setPower:NO error:&err];\n        IOBluetoothPreferenceSetControllerPowerState(0);\n    } else {\n        [currentInterface setPower:lastWifiState error:&err];\n        IOBluetoothPreferenceSetControllerPowerState(lastBluetoothState);\n    }\n}\n\nint main(int argc, const char *argv[]) {\n    @autoreleasepool {\n        printf(\"daemon started...\\n\");\n\n        if (!_loadBezelServices()) {\n            _loadOSDFramework();\n        }\n\n        // system socket\n        int systemSocket = -1;\n\n        // create system socket to receive kernel event data\n        systemSocket = socket(PF_SYSTEM, SOCK_RAW, SYSPROTO_EVENT);\n\n        // struct for vendor code\n        struct kev_vendor_code vendorCode = {0};\n\n        // set vendor name string\n        strncpy(vendorCode.vendor_string, \"com.hieplpvip\", KEV_VENDOR_CODE_MAX_STR_LEN);\n\n        // get vendor code\n        ioctl(systemSocket, SIOCGKEVVENDOR, &vendorCode);\n\n        // struct for kernel request filtering options\n        struct kev_request kevRequest = {0};\n\n        // any class\n        kevRequest.kev_class = KEV_ANY_CLASS;\n\n        // any subclass\n        kevRequest.kev_subclass = KEV_ANY_SUBCLASS;\n\n        // tell kernel what we want to filter on\n        ioctl(systemSocket, SIOCSKEVFILT, &kevRequest);\n\n        // bytes received from system socket\n        ssize_t bytesReceived = -1;\n\n        // message from kext\n        // size is cumulation of header, struct, and max length of a proc path\n        char kextMsg[KEV_MSG_HEADER_SIZE + sizeof(struct AsusSMCMessage)] = {0};\n\n        struct AsusSMCMessage *message = NULL;\n\n        while (YES) {\n            bytesReceived = recv(systemSocket, kextMsg, sizeof(kextMsg), 0);\n\n            if (bytesReceived != sizeof(kextMsg)) continue;\n\n            // struct for broadcast data from the kext\n            struct kern_event_msg *kernEventMsg = {0};\n\n            // type cast to access kev_event_msg header\n            kernEventMsg = (struct kern_event_msg *)kextMsg;\n\n            // only care about events sent by AsusSMC\n            if (AsusSMCEventCode != kernEventMsg->event_code) {\n                continue;\n            }\n\n            // typecast custom data\n            // begins right after header\n            message = (struct AsusSMCMessage *)&kernEventMsg->event_data[0];\n\n            //printf(\"type:%d x:%d y:%d\\n\", message->type, message->x, message->y);\n\n            switch (message->type) {\n                case kDaemonKeyboardBacklight:\n                    showKBoardBLightStatus(message->x, message->y);\n                    break;\n                case kDaemonAirplaneMode:\n                    toggleAirplaneMode();\n                    break;\n                case kDaemonSleep:\n                    goToSleep();\n                    break;\n                //default:\n                    //printf(\"unknown type %d\\n\", message->type);\n            }\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "AsusSMC Changelog\n=======================\n\n#### v1.4.1\n- Added MacKernelSDK with Xcode 12 compatibility\n- Drop experimental custom fan control code\n- Drop AsusHID as I couldn't make it work on Catalina and above. Please use ROG-HID by @black-dragon74\n- Improving touchpad toggling mechanism\n\n#### v1.4.0\n- Rework keyboard backlight mechanism. Users need to repatch DSDT. More specific, the line `^^KBLV = Arg0 / 16` must be removed.\n- Rework ambient light sensor mechanism (use WMI for toggling sensor; read value directly with method `_ALI`). DSDT patch is not needed anymore.\n- Add experimental support for reading fan speed with WMI\n- Support battery charge threshold found on new laptops (charging stops at 80%). Can be disabled by turning off `Battery Health` in `Energy Saver`.\n\n#### v1.3.1\n- Removed unimplemented virtual methods for kext to load correctly (thanks @Ubsefor)\n\n#### v1.3.0\n- Native keyboard backlight on Catalina\n\n#### v1.2.3\n- Remove unused WMI code\n- Correct usage of `powerStateOrdinal` in `setPowerState`\n\n#### v1.2.2\n- Fix keyboard backlight remaining off after sleep on Catalina (thanks to @AR-CADE)\n\n#### v1.2.1\n- Built with Lilu 1.4.1 and VirtualSMC 1.1.0\n- Update `OSBundleLibraries`\n- Fix `install_daemon.sh` to make it work when folder `/usr/local/bin` does not exist\n\n#### v1.2.0\n- Added support for USB HID keyboards found on ROG models\n- Optimized code\n- Updated MaciASL patches\n- Unified release archive names\n- Changed dependency com.apple.iokit.IOHIDSystem to com.apple.iokit.IOHIDFamily\n- Change AsusSMCDaemon installation location to support Catalina\n- Add workaround for keyboard backlight on Catalina\n\n#### v1.1.1\n- Fixed memory leaks\n- Added support for direct messages from ACPI\n\n#### v1.1\n- Optimized code\n\n#### v1.0.3\n- Improved message handling mechanism\n\n#### v1.0.2\n- Optimized code\n\n#### v1.0.1\n- Write data to SMC key after setting keyboard backlight\n\n#### v1.0.0\n- Initial release\n"
  },
  {
    "path": "Global/HIDReport.hpp",
    "content": "//\n//  HIDReport.hpp\n//  VirtualAppleKeyboard\n//\n//  Copyright © 2019 Le Bao Hiep. All rights reserved.\n//\n\nclass __attribute__((packed)) keys final {\npublic:\n    keys(void) : keys_{} {}\n\n    const uint8_t(&get_raw_value(void) const)[32] {\n        return keys_;\n    }\n\n    bool empty(void) const {\n        for (const auto& k : keys_) {\n            if (k != 0) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    void clear(void) {\n        memset(keys_, 0, sizeof(keys_));\n    }\n\n    void insert(uint8_t key) {\n        if (!exists(key)) {\n            for (auto&& k : keys_) {\n                if (k == 0) {\n                    k = key;\n                    return;\n                }\n            }\n        }\n    }\n\n    void erase(uint8_t key) {\n        for (auto&& k : keys_) {\n            if (k == key) {\n                k = 0;\n            }\n        }\n    }\n\n    bool exists(uint8_t key) const {\n        for (const auto& k : keys_) {\n            if (k == key) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    size_t count(void) const {\n        size_t result = 0;\n        for (const auto& k : keys_) {\n            if (k) {\n                ++result;\n            }\n        }\n        return result;\n    }\n\n    bool operator==(const keys& other) const { return (memcmp(this, &other, sizeof(*this)) == 0); }\n    bool operator!=(const keys& other) const { return !(*this == other); }\n\nprivate:\n    uint8_t keys_[32];\n};\n\nclass __attribute__((packed)) consumer_input final {\npublic:\n    consumer_input(void) : report_id_(2) {}\n    bool operator==(const consumer_input& other) const { return (memcmp(this, &other, sizeof(*this)) == 0); }\n    bool operator!=(const consumer_input& other) const { return !(*this == other); }\n\nprivate:\n    uint8_t report_id_ __attribute__((unused));\n\npublic:\n    keys keys;\n};\n\nclass __attribute__((packed)) apple_vendor_top_case_input final {\npublic:\n    apple_vendor_top_case_input(void) : report_id_(3) {}\n    bool operator==(const apple_vendor_top_case_input& other) const { return (memcmp(this, &other, sizeof(*this)) == 0); }\n    bool operator!=(const apple_vendor_top_case_input& other) const { return !(*this == other); }\n\nprivate:\n    uint8_t report_id_ __attribute__((unused));\n\npublic:\n    keys keys;\n};\n"
  },
  {
    "path": "Global/HIDUsageTables.h",
    "content": "//\n//  HIDUsageTables.h\n//  AsusSMC\n//\n//  Copyright © 2019 Le Bao Hiep. All rights reserved.\n//\n\n#ifndef _HIDUsageTables_h\n#define _HIDUsageTables_h\n\n/* Usage Pages */\nenum {\n    kHIDPage_AppleVendorTopCase = 0x00ff,\n    kHIDPage_AsusVendor         = 0xff31,\n    kHIDPage_MicrosoftVendor    = 0xff00\n};\n\n/* AppleVendor Page Top Case (0x00ff) */\nenum\n{\n    kHIDUsage_AV_TopCase_KeyboardFn            = 0x0003,\n    kHIDUsage_AV_TopCase_BrightnessUp          = 0x0004,\n    kHIDUsage_AV_TopCase_BrightnessDown        = 0x0005,\n    kHIDUsage_AV_TopCase_VideoMirror           = 0x0006,\n    kHIDUsage_AV_TopCase_IlluminationToggle    = 0x0007,\n    kHIDUsage_AV_TopCase_IlluminationUp        = 0x0008,\n    kHIDUsage_AV_TopCase_IlluminationDown      = 0x0009,\n    kHIDUsage_AV_TopCase_ClamshellLatched      = 0x000a,\n    kHIDUsage_AV_TopCase_Reserved_MouseData    = 0x00c0\n};\n\n/* AsusVendor Page (0xff31) */\nenum {\n    kHIDUsage_AsusVendor_BrightnessDown      = 0x10,\n    kHIDUsage_AsusVendor_BrightnessUp        = 0x20,\n    kHIDUsage_AsusVendor_DisplayOff          = 0x35,\n    kHIDUsage_AsusVendor_ROG                 = 0x38,\n    kHIDUsage_AsusVendor_Power4Gear          = 0x5c, /* Fn+Space Power4Gear Hybrid */\n    kHIDUsage_AsusVendor_TouchpadToggle      = 0x6b,\n    kHIDUsage_AsusVendor_Sleep               = 0x6c,\n    kHIDUsage_AsusVendor_MicMute             = 0x7c,\n    kHIDUsage_AsusVendor_Camera              = 0x82,\n    kHIDUsage_AsusVendor_RFKill              = 0x88,\n    kHIDUsage_AsusVendor_Fan                 = 0x99, /* Fn+F5 \"fan\" symbol on FX503VD */\n    kHIDUsage_AsusVendor_Calc                = 0xb5,\n    kHIDUsage_AsusVendor_Splendid            = 0xba, /* Fn+C ASUS Splendid */\n    kHIDUsage_AsusVendor_IlluminationUp      = 0xc4,\n    kHIDUsage_AsusVendor_IlluminationDown    = 0xc5\n};\n\n/* MicrosoftVendor Page (0xff31) */\nenum {\n    kHIDUsage_MicrosoftVendor_WLAN              = 0xf1,\n    kHIDUsage_MicrosoftVendor_BrightnessDown    = 0xf2,\n    kHIDUsage_MicrosoftVendor_BrightnessUp      = 0xf3,\n    kHIDUsage_MicrosoftVendor_DisplayOff        = 0xf4,\n    kHIDUsage_MicrosoftVendor_Camera            = 0xf7,\n    kHIDUsage_MicrosoftVendor_ROG               = 0xf8,\n};\n\n#endif /* _HIDUsageTables_h */\n"
  },
  {
    "path": "KernEventServer/KernEventServer.cpp",
    "content": "//\n//  KernEventServer.cpp\n//  KernEventServer\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#include \"KernEventServer.hpp\"\n#include <Headers/kern_util.hpp>\n\nbool KernEventServer::setVendorID(const char *vendorCode) {\n    if (KERN_SUCCESS != kev_vendor_code_find(vendorCode, &vendorID)) {\n        DBGLOG(\"kevserver\", \"setVendorID error\");\n        return false;\n    }\n    return true;\n}\n\nvoid KernEventServer::setEventCode(u_int32_t code) {\n    eventCode = code;\n}\n\nbool KernEventServer::sendMessage(int type, int x, int y) {\n    // kernel event message\n    struct kev_msg kEventMsg = {0};\n\n    // zero out kernel message\n    bzero(&kEventMsg, sizeof(struct kev_msg));\n\n    // set vendor code\n    kEventMsg.vendor_code = vendorID;\n\n    // set class\n    kEventMsg.kev_class = KEV_ANY_CLASS;\n\n    // set subclass\n    kEventMsg.kev_subclass = KEV_ANY_SUBCLASS;\n\n    // set event code\n    kEventMsg.event_code = eventCode;\n\n    // type\n    kEventMsg.dv[0].data_length = sizeof(int);\n    kEventMsg.dv[0].data_ptr = &type;\n\n    // x\n    kEventMsg.dv[1].data_length = sizeof(int);\n    kEventMsg.dv[1].data_ptr = &x;\n\n    // y\n    kEventMsg.dv[2].data_length = sizeof(int);\n    kEventMsg.dv[2].data_ptr = &y;\n\n    if (KERN_SUCCESS != kev_msg_post(&kEventMsg)) {\n        DBGLOG(\"kevserver\", \"sendMessage error\");\n        return false;\n    }\n    return true;\n}\n"
  },
  {
    "path": "KernEventServer/KernEventServer.hpp",
    "content": "//\n//  KernEventServer.hpp\n//  KernEventServer\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#ifndef KernEventServer_hpp\n#define KernEventServer_hpp\n\nextern \"C\" {\n#include <sys/kern_event.h>\n}\n#include <IOKit/IOLib.h>\n\nclass KernEventServer {\npublic:\n    bool setVendorID(const char *vendorCode);\n    void setEventCode(u_int32_t code);\n    bool sendMessage(int type, int x, int y);\n\nprivate:\n    const char *getName();\n    u_int32_t vendorID = 0, eventCode = 0;\n};\n\n#endif /* KernEventServer_hpp */\n"
  },
  {
    "path": "LICENSE.md",
    "content": "The MIT License (MIT)\n\n=====================\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the “Software”), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# AsusSMC\n\n[![Github release](https://img.shields.io/github/release/hieplpvip/AsusSMC.svg?color=blue)](https://github.com/hieplpvip/AsusSMC/releases/latest)\n[![Github downloads](https://img.shields.io/github/downloads/hieplpvip/AsusSMC/total.svg?color=blue)](https://github.com/hieplpvip/AsusSMC/releases)\n[![Build Status](https://travis-ci.com/hieplpvip/AsusSMC.svg?branch=master)](https://travis-ci.com/hieplpvip/AsusSMC)\n[![Scan Status](https://scan.coverity.com/projects/18304/badge.svg)](https://scan.coverity.com/projects/18304)\n[![Gitter chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg?colorB=ed1965)](https://gitter.im/hieplpvip/AsusSMC)\n[![Donate with PayPal](https://img.shields.io/badge/paypal-donate-red.svg)](https://paypal.me/lebhiep)\n\nA VirtualSMC plugin provides native support for ALS, keyboard backlight and Fn keys for Asus laptops on macOS.\n\n#### Features\n- Full Fn keys support\n- Native ALS support\n- Native keyboard backlight support (16 levels, smooth transition, auto adjusting, auto turning off)\n- Battery Health Charging\n\n#### Requirements\n- Asus laptop with ATK device\n- Knowing how to patch DSDT (if not, read [this](https://www.tonymacx86.com/threads/guide-patching-laptop-dsdt-ssdts.152573/))\n\n#### Boot arguments\n- Add `-asussmcdbg` to enable debug printing (available in DEBUG binaries).\n\n#### How to install\n- Instruction is available in the Wiki.\n\n#### Credits\n- [Apple](https://www.apple.com) for macOS\n- [vit9696](https://github.com/vit9696) for [Lilu](https://github.com/acidanthera/Lilu) and [VirtualSMC](https://github.com/acidanthera/VirtualSMC)\n- [lvs1974](https://github.com/lvs1974) and [usr-sse2](https://github.com/usr-sse2) for developing ambient light sensor support\n- [EMlyDinEsHMG](https://osxlatitude.com/profile/7370-emlydinesh/) for [AsusNBFnKeys source code](https://github.com/EMlyDinEsHMG/AsusNBFnKeys)\n- [Objective-See](https://objective-see.com) for [kernel-userspace communication](https://objective-see.com/blog/blog_0x0B.html)\n- [tekezo](https://github.com/tekezo) for [VirtualHIDKeyboard](https://github.com/pqrs-org/Karabiner-VirtualHIDDevice/)\n- [williambj1](https://github.com/williambj1) for testing HID support\n"
  },
  {
    "path": "Scripts/bootstrap.sh",
    "content": "#!/bin/bash\n\n#\n#  bootstrap.sh\n#\n#  Copyright © 2019 hieplpvip. All rights reserved.\n#\n#  This script is supposed to quickly bootstrap Lilu/VirtualSMC SDK for plugin building.\n#\n#  Latest version available at:\n#  https://raw.githubusercontent.com/hieplpvip/AsusSMC/master/Scripts/bootstrap.sh\n#\n#  Example usage:\n#  src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/hieplpvip/AsusSMC/master/Scripts/bootstrap.sh) && eval \"$src\" || exit 1\n#\n\nSDK_PATH=\"Lilu.kext\"\n\nPROJECT_PATH=\"$(pwd)\"\nif [ $? -ne 0 ] || [ ! -d \"${PROJECT_PATH}\" ]; then\n  echo \"ERROR: Failed to determine working directory!\"\n  exit 1\nfi\n\n# Avoid conflicts with PATH overrides.\nCURL=\"/usr/bin/curl\"\nGIT=\"/usr/bin/git\"\nGREP=\"/usr/bin/grep\"\nMKDIR=\"/bin/mkdir\"\nMV=\"/bin/mv\"\nRM=\"/bin/rm\"\nSED=\"/usr/bin/sed\"\nUNAME=\"/usr/bin/uname\"\nUNZIP=\"/usr/bin/unzip\"\nUUIDGEN=\"/usr/bin/uuidgen\"\nXCODEBUILD=\"/usr/bin/xcodebuild\"\n\nTOOLS=(\n  \"${CURL}\"\n  \"${GIT}\"\n  \"${GREP}\"\n  \"${MKDIR}\"\n  \"${MV}\"\n  \"${RM}\"\n  \"${SED}\"\n  \"${UNAME}\"\n  \"${UNZIP}\"\n  \"${UUIDGEN}\"\n  \"${XCODEBUILD}\"\n)\n\nfor tool in \"${TOOLS[@]}\"; do\n  if [ ! -x \"${tool}\" ]; then\n    echo \"ERROR: Missing ${tool}!\"\n    exit 1\n  fi\ndone\n\n# Prepare temporary directory to avoid conflicts with other scripts.\n# Sets TMP_PATH.\nprepare_environment() {\n  local ret=0\n\n  local sys=$(\"${UNAME}\") || ret=$?\n  if [ $ret -ne 0 ] || [ \"$sys\" != \"Darwin\" ]; then\n    echo \"ERROR: This script is only meant to be used on Darwin systems!\"\n    return 1\n  fi\n\n  local uuid=$(\"${UUIDGEN}\") || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to generate temporary UUID with code ${ret}!\"\n    return 1\n  fi\n\n  TMP_PATH=\"/tmp/lilutmp.${uuid}\"\n  if [ -e \"${TMP_PATH}\" ]; then\n    echo \"ERROR: Found existing temporary directory ${TMP_PATH}, aborting!\"\n    return 1\n  fi\n\n  \"${MKDIR}\" \"${TMP_PATH}\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to create temporary directory ${TMP_PATH} with code ${ret}!\"\n    return 1\n  fi\n\n  cd \"${TMP_PATH}\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd to temporary directory ${TMP_PATH} with code ${ret}!\"\n    \"${RM}\" -rf \"${TMP_PATH}\"\n    return 1\n  fi\n\n  return 0\n}\n\n# Install prebuilt Lilu SDK for release distribution.\ninstall_lilu_sdk() {\n  local ret=0\n\n  echo \"Installing prebuilt Lilu SDK...\"\n\n  echo \"-> Obtaining release manifest...\"\n\n  echo \"-> Cloning the latest version from master...\"\n\n  # This is a really ugly hack due to GitHub API rate limits.\n  local url=\"https://github.com/acidanthera/Lilu\"\n  \"${GIT}\" clone \"${url}\" -b \"master\" \"lilu\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to clone repository with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"-> Obtaining the latest tag...\"\n\n  cd \"lilu\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd to temporary directory lilu with code ${ret}!\"\n    return 1\n  fi\n\n  local vers=$(\"${GIT}\" describe --abbrev=0 --tags) || ret=$?\n  if [ \"$vers\" = \"\" ]; then\n    echo \"ERROR: Failed to determine the latest release tag!\"\n    return 1\n  fi\n\n  echo \"-> Discovered the latest tag ${vers}.\"\n\n  cd .. || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd back from temporary directory with code ${ret}!\"\n    return 1\n  fi\n\n  \"${RM}\" -rf lilu || ret=$?\n  if [ $ret -ne 0 ] || [ -d lilu ]; then\n    echo \"ERROR: Failed to remove temporary directory lilu with code ${ret}!\"\n    return 1\n  fi\n\n  local file=\"Lilu-${vers}-DEBUG.zip\"\n\n  echo \"-> Downloading prebuilt debug version ${file}...\"\n\n  local url=\"https://github.com/acidanthera/Lilu/releases/download/${vers}/${file}\"\n  \"${CURL}\" -LfsO \"${url}\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to download ${file} with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"-> Extracting SDK from prebuilt debug version...\"\n\n  if [ ! -f \"${file}\" ]; then\n    echo \"ERROR: Failed to download ${file} to a non-existent location!\"\n    return 1\n  fi\n\n  \"${MKDIR}\" \"lilu\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to create temporary directory at ${TMP_PATH} with code ${ret}!\"\n    return 1\n  fi\n\n  cd \"lilu\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd to temporary directory lilu with code ${ret}!\"\n    return 1\n  fi\n\n  \"${UNZIP}\" -q ../\"${file}\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to unzip ${file} with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"-> Installing SDK from the prebuilt debug version...\"\n\n  \"${RM}\" -rf \"${PROJECT_PATH}/Lilu.kext\"\n  \"${MV}\" \"Lilu.kext\" \"${PROJECT_PATH}/Lilu.kext\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to install SDK with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"Installed prebuilt Lilu SDK ${vers}!\"\n\n  return 0\n}\n\n# Install prebuilt VirtualSMC SDK for release distribution.\ninstall_vsmc_sdk() {\n  local ret=0\n\n  echo \"Installing prebuilt VirtualSMC SDK...\"\n\n  echo \"-> Obtaining release manifest...\"\n\n  echo \"-> Cloning the latest version from master...\"\n\n  # This is a really ugly hack due to GitHub API rate limits.\n  local url=\"https://github.com/acidanthera/VirtualSMC\"\n  \"${GIT}\" clone \"${url}\" -b \"master\" \"vsmc\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to clone repository with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"-> Obtaining the latest tag...\"\n\n  cd \"vsmc\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd to temporary directory vsmc with code ${ret}!\"\n    return 1\n  fi\n\n  local vers=$(\"${GIT}\" describe --abbrev=0 --tags) || ret=$?\n  if [ \"$vers\" = \"\" ]; then\n    echo \"ERROR: Failed to determine the latest release tag!\"\n    return 1\n  fi\n\n  echo \"-> Discovered the latest tag ${vers}.\"\n\n  cd .. || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd back from temporary directory with code ${ret}!\"\n    return 1\n  fi\n\n  \"${RM}\" -rf vsmc || ret=$?\n  if [ $ret -ne 0 ] || [ -d vsmc ]; then\n    echo \"ERROR: Failed to remove temporary directory vsmc with code ${ret}!\"\n    return 1\n  fi\n\n  local file=\"VirtualSMC-${vers}-DEBUG.zip\"\n\n  echo \"-> Downloading prebuilt debug version ${file}...\"\n\n  local url=\"https://github.com/acidanthera/VirtualSMC/releases/download/${vers}/${file}\"\n  \"${CURL}\" -LfsO \"${url}\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to download ${file} with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"-> Extracting SDK from prebuilt debug version...\"\n\n  if [ ! -f \"${file}\" ]; then\n    echo \"ERROR: Failed to download ${file} to a non-existent location!\"\n    return 1\n  fi\n\n  \"${MKDIR}\" \"vsmc\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to create temporary directory at ${TMP_PATH} with code ${ret}!\"\n    return 1\n  fi\n\n  cd \"vsmc\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to cd to temporary directory vsmc with code ${ret}!\"\n    return 1\n  fi\n\n  \"${UNZIP}\" -q ../\"${file}\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to unzip ${file} with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"-> Installing SDK from the prebuilt debug version...\"\n\n  \"${RM}\" -rf \"${PROJECT_PATH}/VirtualSMC.kext\"\n  \"${MV}\" \"Kexts/VirtualSMC.kext\" \"${PROJECT_PATH}/VirtualSMC.kext\" || ret=$?\n  if [ $ret -ne 0 ]; then\n    echo \"ERROR: Failed to install SDK with code ${ret}!\"\n    return 1\n  fi\n\n  echo \"Installed prebuilt VirtualSMC SDK ${vers}!\"\n\n  return 0\n}\n\nprepare_environment || exit 1\n\nret=0\n\ninstall_lilu_sdk || ret=$?\n\necho \"------------------------------\"\n\ninstall_vsmc_sdk || ret=$?\n\ncd \"${PROJECT_PATH}\" || ret=$?\n\n\"${RM}\" -rf \"${TMP_PATH}\"\n\nif [ $ret -ne 0 ]; then\n  echo \"ERROR: Failed to bootstrap SDK with code ${ret}!\"\n  exit 1\nfi\n"
  },
  {
    "path": "VirtualAppleKeyboard/VirtualAppleKeyboard.cpp",
    "content": "//\n//  VirtualAppleKeyboard.cpp\n//  VirtualAppleKeyboard\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#include \"VirtualAppleKeyboard.hpp\"\n\n#define super IOHIDDevice\nOSDefineMetaClassAndStructors(VirtualAppleKeyboard, super);\n\nconst uint8_t virt_reportDescriptor[] = {\n    0x05, 0x01,       // Usage Page (Generic Desktop)\n    0x09, 0x06,       // Usage (Keyboard)\n    0xa1, 0x01,       // Collection (Application)\n    0x85, 0x01,       //   Report Id (1)\n    0x05, 0x07,       //   Usage Page (Keyboard/Keypad)\n    0x19, 0xe0,       //   Usage Minimum........... (224)\n    0x29, 0xe7,       //   Usage Maximum........... (231)\n    0x15, 0x00,       //   Logical Minimum......... (0)\n    0x25, 0x01,       //   Logical Maximum......... (1)\n    0x75, 0x01,       //   Report Size............. (1)\n    0x95, 0x08,       //   Report Count............ (8)\n    0x81, 0x02,       //   Input...................(Data, Variable, Absolute)\n                      //\n    0x95, 0x01,       //   Report Count............ (1)\n    0x75, 0x08,       //   Report Size............. (8)\n    0x81, 0x01,       //   Input...................(Constant)\n                      //\n    0x95, 0x20,       //   Report Count............ (32)\n    0x75, 0x08,       //   Report Size............. (8)\n    0x15, 0x00,       //   Logical Minimum......... (0)\n    0x26, 0xff, 0x00, //   Logical Maximum......... (255)\n    0x05, 0x07,       //   Usage Page (Keyboard/Keypad)\n    0x19, 0x00,       //   Usage Minimum........... (0)\n    0x29, 0xff,       //   Usage Maximum........... (255)\n    0x81, 0x00,       //   Input...................(Data, Array, Absolute)\n    0xc0,             // End Collection\n\n    0x05, 0x0c,       // Usage Page (Consumer)\n    0x09, 0x01,       // Usage 1 (kHIDUsage_Csmr_ConsumerControl)\n    0xa1, 0x01,       // Collection (Application)\n    0x85, 0x02,       //   Report Id (2)\n    0x05, 0x0c,       //   Usage Page (Consumer)\n    0x95, 0x20,       //   Report Count............ (32)\n    0x75, 0x08,       //   Report Size............. (8)\n    0x15, 0x00,       //   Logical Minimum......... (0)\n    0x26, 0xff, 0x00, //   Logical Maximum......... (255)\n    0x19, 0x00,       //   Usage Minimum........... (0)\n    0x29, 0xff,       //   Usage Maximum........... (255)\n    0x81, 0x00,       //   Input...................(Data, Array, Absolute)\n    0xc0,             // End Collection\n\n    0x06, 0x00, 0xff, // Usage Page (kHIDPage_AppleVendor)\n    0x09, 0x01,       // Usage 1 (kHIDUsage_AppleVendor_TopCase)\n    0xa1, 0x01,       // Collection (Application)\n    0x85, 0x03,       //   Report Id (3)\n    0x05, 0xff,       //   Usage Page (kHIDPage_AppleVendorTopCase)\n    0x95, 0x20,       //   Report Count............ (32)\n    0x75, 0x08,       //   Report Size............. (8)\n    0x15, 0x00,       //   Logical Minimum......... (0)\n    0x26, 0xff, 0x00, //   Logical Maximum......... (255)\n    0x19, 0x00,       //   Usage Minimum........... (0)\n    0x29, 0xff,       //   Usage Maximum........... (255)\n    0x81, 0x00,       //   Input...................(Data, Array, Absolute)\n    0xc0,             // End Collection\n\n    0x06, 0x00, 0xff, // Usage Page (kHIDPage_AppleVendor)\n    0x09, 0x0f,       // Usage 15 (kHIDUsage_AppleVendor_KeyboardBacklight)\n    0xa1, 0x01,       // Collection (Application)\n    0x85, 0xbf,       //   Report ID (191)\n    0x06, 0x00, 0xff, //   Usage Page (kHIDUsage_AppleVendor_KeyboardBacklight)\n    0x95, 0x20,       //   Report Count............ (32)\n    0x75, 0x08,       //   Report Size............. (8)\n    0x15, 0x00,       //   Logical Minimum......... (0)\n    0x26, 0xff, 0x00, //   Logical Maximum......... (255)\n    0x19, 0x00,       //   Usage Minimum........... (0)\n    0x29, 0xff,       //   Usage Maximum........... (255)\n    0x81, 0x00,       //   Input...................(Data, Array, Absolute)\n    0xc0,             // End Collection\n};\n\nbool VirtualAppleKeyboard::handleStart(IOService *provider) {\n    if (!super::handleStart(provider)) {\n        return false;\n    }\n\n    setProperty(\"AppleVendorSupported\", kOSBooleanTrue);\n    setProperty(\"Built-In\", kOSBooleanTrue);\n    setProperty(\"HIDDefaultBehavior\", kOSBooleanTrue);\n\n    return true;\n}\n\nIOReturn VirtualAppleKeyboard::newReportDescriptor(IOMemoryDescriptor **descriptor) const {\n    *descriptor = IOBufferMemoryDescriptor::withBytes(virt_reportDescriptor, sizeof(virt_reportDescriptor), kIODirectionNone);\n    return kIOReturnSuccess;\n}\n\nIOReturn VirtualAppleKeyboard::getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) {\n    uint8_t report_id = options & 0xff;\n    OSData *get_buffer = OSData::withCapacity(1);\n\n    if (report_id == 0xbf) {\n        uint8_t buffer[] = {0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00};\n        get_buffer->appendBytes(buffer, sizeof(buffer));\n    }\n\n    report->writeBytes(0, get_buffer->getBytesNoCopy(), get_buffer->getLength());\n    get_buffer->release();\n\n    return kIOReturnSuccess;\n}\n\nOSString *VirtualAppleKeyboard::newManufacturerString() const {\n    return OSString::withCString(\"Apple Inc.\");\n}\n\nOSString *VirtualAppleKeyboard::newProductString() const {\n    return OSString::withCString(\"Virtual Apple Keyboard\");\n}\n\nOSNumber *VirtualAppleKeyboard::newVendorIDNumber() const {\n    return OSNumber::withNumber(0x5ac, 32);\n}\n\nOSNumber *VirtualAppleKeyboard::newProductIDNumber() const {\n    return OSNumber::withNumber(0x276, 32);\n}\n\nOSNumber *VirtualAppleKeyboard::newLocationIDNumber() const {\n    return OSNumber::withNumber(0x1000000, 32);\n}\n\nOSNumber *VirtualAppleKeyboard::newCountryCodeNumber() const {\n    return OSNumber::withNumber(0x21, 32);\n}\n\nOSNumber *VirtualAppleKeyboard::newVersionNumber() const {\n    return OSNumber::withNumber(0x895, 32);\n}\n\nOSNumber *VirtualAppleKeyboard::newPrimaryUsagePageNumber() const {\n    return OSNumber::withNumber(kHIDPage_GenericDesktop, 32);\n}\n\nOSNumber *VirtualAppleKeyboard::newPrimaryUsageNumber() const {\n    return OSNumber::withNumber(kHIDUsage_GD_Keyboard, 32);\n}\n"
  },
  {
    "path": "VirtualAppleKeyboard/VirtualAppleKeyboard.hpp",
    "content": "//\n//  VirtualAppleKeyboard.hpp\n//  VirtualAppleKeyboard\n//\n//  Copyright © 2018-2020 Le Bao Hiep. All rights reserved.\n//\n\n#include <IOKit/hid/IOHIDDevice.h>\n\nclass VirtualAppleKeyboard final : public IOHIDDevice {\n    OSDeclareDefaultStructors(VirtualAppleKeyboard);\n\npublic:\n    bool handleStart(IOService *provider) override;\n\n    IOReturn newReportDescriptor(IOMemoryDescriptor **descriptor) const override;\n\n    IOReturn getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) override;\n\n    OSString *newManufacturerString() const override;\n    OSString *newProductString() const override;\n    OSNumber *newVendorIDNumber() const override;\n    OSNumber *newProductIDNumber() const override;\n    OSNumber *newLocationIDNumber() const override;\n    OSNumber *newCountryCodeNumber() const override;\n    OSNumber *newVersionNumber() const override;\n    OSNumber *newPrimaryUsagePageNumber() const override;\n    OSNumber *newPrimaryUsageNumber() const override;\n};\n"
  },
  {
    "path": "patches/NullPatch.txt",
    "content": "#Maintained by hieplpvip\n#NullPatch.txt\n\n# This is not a patch....\n"
  },
  {
    "path": "patches/als_toggle.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q76 for ALS toggle A key to work\ninto Method label _Q76 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x7A)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f1.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q0A for F1 key to work\ninto Method label _Q0A replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x5E)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f10.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q13 for F10 key to work\ninto Method label _Q13 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x32)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f11.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q14 for F11 key to work\ninto Method label _Q14 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x31)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f12.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q15 for F12 key to work\ninto Method label _Q15 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x30)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f2.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q0B for F2 key to work\ninto Method label _Q0B replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x7D)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f3.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q0C for F3 key to work\ninto Method label _Q0C replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0xC5)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f4.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q0D for F4 key to work\ninto Method label _Q0D replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0xC4)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f5.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q0E for F5 key to work\ninto Method label _Q0E replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x20)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f6.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q0F for F6 key to work\ninto Method label _Q0F replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x10)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f7.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q10 for F7 key to work\ninto Method label _Q10 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x35)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f8.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q11 for F8 key to work\ninto Method label _Q11 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x61)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/f9.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q12 for F9 key to work\ninto Method label _Q12 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x6B)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/fake_als.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto_all device label ALS0 remove_entry;\ninto scope label _SB insert begin\nDevice(ALS0)\\n\n{\\n\n    Name(_HID, \"ACPI0008\")\\n\n    Name(_CID, \"smc-als\")\\n\n    Name(_ALI, 150)\\n\n    Name(_ALR, Package()\\n\n    {\\n\n        Package() { 100, 150 },\\n\n    })\\n\n}\nend;\n"
  },
  {
    "path": "patches/kbl_broadwell.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    ^^PCI0.LPCB.EC0.WRAM (0x04B1, Arg0)\\n\n    Return (Arg0)\\n\n}\\n\nend;\n\ninto method label KBLD code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC5)\nend;\n\ninto method label KBLU code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC4)\nend;\n"
  },
  {
    "path": "patches/kbl_coffeelake.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    ^^PCI0.LPCB.EC0.WRAM (0xBA, 0xC9F0, ^^KBLV)\\n\n    ^^PCI0.LPCB.EC0.ST9E (0x1F, 0xFF, Arg0)\\n\n    Return (Arg0)\\n\n}\\n\nend;\n\ninto method label KBLD code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC5)\nend;\n\ninto method label KBLU code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC4)\nend;\n"
  },
  {
    "path": "patches/kbl_icelake.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    ^^PCI0.LPCB.EC0.ST9E (0x1F, 0xFF, Arg0)\\n\n    Return (Arg0)\\n\n}\\n\nend;\n\ninto method label KBLD code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC5)\nend;\n\ninto method label KBLU code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC4)\nend;\n"
  },
  {
    "path": "patches/kbl_ivybridge.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    ^^PCI0.LPCB.EC0.WRAM (0x044B, Arg0)\\n\n    Return (Arg0)\\n\n}\\n\nend;\n\ninto method label KBLD code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC5)\nend;\n\ninto method label KBLU code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC4)\nend;\n"
  },
  {
    "path": "patches/kbl_kabylake.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    ^^PCI0.LPCB.EC0.WRAM (0x09F0, ^^KBLV)\\n\n    ^^PCI0.LPCB.EC0.ST9E (0x1F, 0xFF, Arg0)\\n\n    Return (Arg0)\\n\n}\\n\nend;\n\ninto method label KBLD code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC5)\nend;\n\ninto method label KBLU code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC4)\nend;\n"
  },
  {
    "path": "patches/kbl_tuf.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    Arg0 = (Arg0 / 16) | 0x80\\n\n    SLKI(Arg0)\\n\n    Return (One)\\n\n}\\n\nend;\n"
  },
  {
    "path": "patches/kbl_whiskeylake.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\ninto method label SKBV parent_label ATKD remove_entry;\ninto device label ATKD insert begin\nMethod (SKBV, 1, NotSerialized)\\n\n{\\n\n    ^^PCI0.LPCB.EC0.ST9E (0x1F, 0xFF, Arg0)\\n\n    Return (Arg0)\\n\n}\\n\nend;\n\ninto method label KBLD code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC5)\nend;\n\ninto method label KBLU code_regex ATKD.IANE\\s+\\(\\w+\\) replace_matched begin\nATKD.IANE (0xC4)\nend;\n"
  },
  {
    "path": "patches/media_arrow.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q6C for media left arrow key to work\ninto Method label _Q6C replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x40)\\n\n    }\nend;\n\n# Replacing method _Q6D for media right arrow key to work\ninto Method label _Q6D replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x41)\\n\n    }\nend;\n\n# Replacing method _Q6E for media up arrow key to work\ninto Method label _Q6E replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x43)\\n\n    }\nend;\n\n# Replacing method _Q6F for media down arrow key to work\ninto Method label _Q6F replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x45)\\n\n    }\nend;\n"
  },
  {
    "path": "patches/media_cvspace.txt",
    "content": "#Maintained by hieplpvip\n#See https://github.com/hieplpvip/AsusSMC/wiki/Installation-Instruction\n#for how to use\n\n# Replacing method _Q71 for space key to work\ninto Method label _Q71 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x5C)\\n\n    }\nend;\n\n# Replacing method _Q72 for V key to work\n# by removing the code which prevents\ninto Method label _Q72 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x8A)\\n\n    }\nend;\n\n# Replacing method _Q73 for C key to work\n# by removing the code which prevents\ninto Method label _Q73 replace_content begin\n    If (ATKP)\\n\n    {\\n\n        \\_SB.ATKD.IANE (0x82)\\n\n    }\nend;\n"
  }
]