Control: retitle -1 Apple keyboard: Scan code event (EV_MSC) not generated when the EV_KEY event is generated by hid-apple.c Control: tags -1 patch
On 2021-05-26 10:39:11 +0200, Vincent Lefevre wrote: > And the cursor keys. Actually, all the keys corresponding to > > static const struct applespi_key_translation applespi_fn_codes[] = { > { KEY_BACKSPACE, KEY_DELETE }, > { KEY_ENTER, KEY_INSERT }, > { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, > { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, > { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, > { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, > { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, > { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, > { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, > { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, > { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY }, > { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, > { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, > { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, > { KEY_RIGHT, KEY_END }, > { KEY_LEFT, KEY_HOME }, > { KEY_DOWN, KEY_PAGEDOWN }, > { KEY_UP, KEY_PAGEUP }, > { } > }; > > in drivers/input/keyboard/applespi.c. > > Just in case, in /etc/modprobe.d/hid_apple.conf, I have > > options hid_apple fnmode=2 > options hid_apple iso_layout=0 But since I'm using hid_apple, I should have taken drivers/hid/hid-apple.c, which has the same kind of code: static const struct apple_key_translation apple_fn_keys[] = { { KEY_BACKSPACE, KEY_DELETE }, { KEY_ENTER, KEY_INSERT }, { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY }, { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, { KEY_UP, KEY_PAGEUP }, { KEY_DOWN, KEY_PAGEDOWN }, { KEY_LEFT, KEY_HOME }, { KEY_RIGHT, KEY_END }, { } }; In the conditions from hidinput_apple_event(), the only ones that should match according to my settings are if (usage->code == fn_keycode) { and if (fnmode) { and these are the keys (when trans is true, for fnmode) for which I do not get a scan code event. Said otherwise, if hidinput_apple_event() returns 1, I do not get a scan code event. There are input_event() calls, but I suppose that they will just generate an EV_KEY event, and EV_MSC is the one that is missing. Note: in hid-apple.c, apple_event() calls hidinput_apple_event(), and one has static struct hid_driver apple_driver = { [...] .event = apple_event, [...] }; module_hid_driver(apple_driver); I forgot that there was https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757356#35 from Daniel Lin, with a patch, in 2017. I've looked at this patch (but have not tried it), and it adds an additional EV_MSC event when hidinput_apple_event() has to generate an EV_KEY event. So I confirm that should solve this issue and I'm adding the patch tag (I don't know whether the patch needs an update, though). -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)