[Guide] How to Remap Brightness Hotkeys on Laptop



EliteMacx86

Administrator
Staff member
After enabling the backlight which results in adding slider in SysPrefs->Displays, the brightness hotkeys may not work. This guide will enable the brightness hotkeys on your laptop. By using the hotkyes, you can control the amount of brightness.

Before starting with this guide, make sure you're using AppleBacklightInjector method from RehabMan which has been covered here: https://www.elitemacx86.com/threads/guide-how-to-enable-backlight-control-on-laptop.148/

Once you've fixed your backlight control, you can remap your brightness hotkeys.
All the keys on the keyboard have a unique code. The brightness keys can be controlled as Fn+Fx. Some laptops uses Arrow Keys too.

Find Keyboard Driver
First you need to find what Keyboard driver is there. To find this, you can use IOReg.
  • Open IOReg
  • Search for Keyboard
In the left pane, you'll find something similar to this
Screen Shot 2018-08-30 at 8.49.45 PM.png


In this case, ApplePS2Keyboard attaches to ApplePS2KeyboardDevice, which attaches to ps2controller, all of which attach to KBC0, this is the device name we're looking for.

Note :
  • All laptops do not use KBC0, some may use PS2K.
You'll need to know what exact codes or the commands is called when the key is pressed. Usually, media keys generate EC queries. A quick way to know is to use ACPIDebug.kext to instrument all EC query methods, then press the keys while monitoring system.log. When you press the keys, the name of the method will be output, which will allow you to patch that method.

Notes :
To determine the EC query methods:
  • ACPIDebug.kext: https://github.com/RehabMan/OS-X-ACPI-Debug
  • Download and install the ACPIDebug.kext to S/L/E
  • Open MaciASL and add the ACPIDebug in Sources
  • Open your DSDT and apply "Add DSDT Debug Methods"
  • Also apply "Instrument EC Queries"
  • Click on Close
  • Save the DSDT file to any other location.
  • Copy the patched DSDT to your EFI/ACPI/Patched
  • Restart
  • Press your brightness keys and monitor the system.log.
Once you get the methods which results to the brightness keys, you can patch your DSDT.

Assuming that _Q11 is brightness down, and _Q12 is up, as per the logs.

Code:
#Edit methods _Q11 and _Q12 to interface with KBC0 (or PS2K in some systems),
into method label _Q11 replace_content
begin
// Brightness Down\n
Notify (KBC0, 0x20)\n
end;

into method label _Q12 replace_content
begin
// Brightness Up\n
Notify (KBC0, 0x10)\n
end;
Open your DSDT, apply this patch

Notes :
  • Change the value of Keyboard according the IOReg found in your laptop. For e.g KBC0.
  • Change the value of corresponding keys according to the system.log. For e.g _Q11 for brightness down and _Q12 for down.
  • For ASUS and Lenovo, i recommend to use ASUSNBFnKeys and LenovoNBFnKeys. For this, you must patch your DSDT. For more information, read here: https://www.elitemacx86.com/threads/guide-how-to-patch-laptop-dsdt-and-ssdts.178/
Restart
After making all the necessary changes, restart your laptop.

Your brightness keys should be fully functional now.

Credits:
RehabMan
Shinzon
EMlyDinEsH
 


Top