Special Keys on Laptops? How to find scan codes?

My top row of keys has F1-12. It also has controls for working with brightness/sound. I want to be able to do brightness(8) work and volume adjustment from the console without using CLI tools.

In a strictly vt context, is there a way to get the scan codes so that I can bind them to the keyboard? I don't have/don't want X or Wayland.

Right now my next step is to recompile the kernel and add a debugging printf to emit everything about keys as they're read by vt_core.c. That seems...extreme, but if there's no other way...
 
Im looking at the same issue , Brightness and volume control buttons on laptop is not responding.
code in "/usr/src/sys/dev/acpi_support" is 20 years old. and in need of maintenance. se the thread in Mobile computing forum.
 
I went the kernel logging route and added some printf() into vt_core.

On my machine F1,2,3 look like:

0x8200001b
.....c
.....d

Given this, I should be able to test whether there's a windows key and F1/2/3
 
Im looking at the same issue , Brightness and volume control buttons on laptop is not responding.
code in "/usr/src/sys/dev/acpi_support" is 20 years old. and in need of maintenance. se the thread in Mobile computing forum.
On my laptop Thinkpad T495 I put in /etc/devd/ibm_brightness.conf:
Code:
notify 20 {
       match "system" "ACPI";
       match "subsystem" "IBM";
       match "notify" "0x10";
       action "/usr/bin/backlight incr 10";
 };

notify 20 {
       match "system" "ACPI";
       match "subsystem" "IBM";
       match "notify" "0x11";
       action "/usr/bin/backlight decr 10";
 };
and brightness works. I also loading acpi_ibm and Fn/F1, F2, F3 for sound works too. For brightness F5, F6. Other don't.
 
I want to be able to do brightness(8) work and volume adjustment from the console without using CLI tools.

In a strictly vt context, is there a way to get the scan codes so that I can bind them to the keyboard? I don't have/don't want X or Wayland.

There is misc/kbdscan (Show scancodes of keys pressed and released), but it does not show function key scancodes.

This is from observation, not knowledge, certain function keys (hotkeys), not all, are enable by specific kernel modules, depending on machine brand and model.
Code:
% ls -1 /boot/kernel/acpi_*
/boot/kernel/acpi_asus.ko
/boot/kernel/acpi_asus_wmi.ko
/boot/kernel/acpi_dock.ko
/boot/kernel/acpi_fujitsu.ko
/boot/kernel/acpi_ged.ko
/boot/kernel/acpi_hp.ko
/boot/kernel/acpi_ibm.ko
/boot/kernel/acpi_panasonic.ko
/boot/kernel/acpi_sony.ko
/boot/kernel/acpi_toshiba.ko
/boot/kernel/acpi_video.ko
/boot/kernel/acpi_wmi.ko

On my ThinkPad E15 AMD acpi_ibm(4) enables volume function keys, which work only in Xorg, not console, and only if the media player window has the focus. When the window focus or the virtual desktop changes, volume keys don't work anymore.

Brightness keys OTOH work in Xorg and console out of the box (no devd configuration needed as is the case in fernandel post # 7), but only when a drm-kmod graphics driver (amdgpu in my case) is loaded, which creates /dev/backlight/* device nodes:
Rich (BB code):
 % ls -l /dev/backlight/*
lrwxr-xr-x  1 root wheel    23 Feb 25 09:40 /dev/backlight/amdgpu_bl00 -> ../backlight/backlight0
crw-rw----  1 root video 0x199 Feb 25 09:40 /dev/backlight/backlight0

I went the kernel logging route and added some printf() into vt_core.
...
Given this, I should be able to test whether there's a windows key and F1/2/3
As for windows key on a ThinkPad E15 AMD:
Code:
 # kbdscan
Scancode 28 released.
Scancode 105 pressed.
Scancode 105 released.
Timeout. Exiting...

105 here the "windows" key scancode, 28 "Enter".
 
There is misc/kbdscan (Show scancodes of keys pressed and released), but it does not show function key scancodes. […]
Actually, misc/kbdscan prints key codes. kbdscan.c calls:​
C:
ioctl(0, KDSKBMODE, K_CODE)
K_CODE means according to sys/sys/kbio.h:​
C:
#define K_CODE		2		/* keyboard returns keycodes 	*/
If you want scan codes, use K_RAW. For most applications (e. g. kbdmap(5)) key codes are more suitable, though.​
 
Actually, misc/kbdscan prints key codes. kbdscan.c calls:​
C:
ioctl(0, KDSKBMODE, K_CODE)
K_CODE means according to sys/sys/kbio.h:​
C:
#define K_CODE        2        /* keyboard returns keycodes     */
If you want scan codes, use K_RAW. For most applications (e. g. kbdmap(5)) key codes are more suitable, though.​
Makes sense. Then misc/kbdscan has incorrect comment and description?
Rich (BB code):
Comment        : Show scancodes of keys pressed and released
..
Description    :
kbdscan is a small program to set the FreeBSD console keyboard in
raw scancode mode and show scancodes of keys pressed and released.
 
Is there an Xorg-free less version?
Without Xorg or wayland I'll assume you mainly want to listen to music files or streams. The keyboard multimedia keys are hard coded "XF86Audio...." and I'm not aware that the codes can be changed.

A work around is to use a terminal based music player/cdplayer. I use
audio/musicpd with the frontend audio/ncmpc
Out of the box, ncmpc provides the following key codes:

- Left : Decrease volume
+ Right : Increase volume
 
when using NVIDIA and NVIDIA_DRM the /dev/backlight is not created . instead its possible to run:

$ xrandr --output DP-4 --brightness 0.7

DP-4 is the active display in this case,
brightness can be set to a fraction , ( 1 = 100% ) ( 0.7 = 70% )
this command need to be triggered after the desktop/ Xorg is started.
 
Back
Top