2

My Xorg program uses tty1. Use Ctrl+Alt+F[2~6] to switch between ttY[2~6]. At this time, the NumLock or CapsLock state (including the corresponding LED light on the keyboard) can be synchronized normally.

If I switch between tty1 and tty[2~6], the NumLock or CapsLock state is normal, but the keyboard light does not switch normally. I want to know, who is responsible for saving and switching the NumLock or CapsLock state of the tty keyboard (including the corresponding LED light on the keyboard)?

Use evtest to monitor keyboard events, an example is as follows:

scene 1:

tty1: Num led is on, you can input numbers;
tty2: Num Led is off, you cannot enter numbers;
tty1-->tty2: Num led is on, no number can be input

ctrl+alt+f2, tty1-->tty2, evtest print as follows:

Event: time 1631671173.524324, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1631671173.524324, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1631671173.524324, -------------- SYN_REPORT ------------
Event: time 1631671173.612530, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e2
Event: time 1631671173.612530, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 1
Event: time 1631671173.612530, -------------- SYN_REPORT ------------
Event: time 1631671173.684525, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003b
Event: time 1631671173.684525, type 1 (EV_KEY), code 60 (KEY_F2), value 1
Event: time 1631671173.684525, -------------- SYN_REPORT ------------
Event: time 1631671173.804507, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1631671173.804507, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time 1631671173.804507, -------------- SYN_REPORT ------------
Event: time 1631671173.812235, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e2
Event: time 1631671173.812235, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0
Event: time 1631671173.812235, -------------- SYN_REPORT ------------
Event: time 1631671173.824310, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003b
Event: time 1631671173.824310, type 1 (EV_KEY), code 60 (KEY_F2), value 0
Event: time 1631671173.824310, -------------- SYN_REPORT ------------

scene 2:

tty2: Num led is on, you can input numbers;
tty3: Num Led is off, you cannot enter numbers;
tty2-->tty3: Num led is off, no number can be input

ctrl+alt+f3, tty2-->tty3, evtest print as follows:

Event: time 1631671357.985873, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1631671357.985873, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1631671357.985873, -------------- SYN_REPORT ------------
Event: time 1631671358.097893, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e2
Event: time 1631671358.097893, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 1
Event: time 1631671358.097893, -------------- SYN_REPORT ------------
Event: time 1631671358.181861, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003c
Event: time 1631671358.181861, type 1 (EV_KEY), code 61 (KEY_F3), value 1
Event: time 1631671358.181861, -------------- SYN_REPORT ------------
Event: time 1631671358.313866, type 17 (EV_LED), code 0 (LED_NUML), value 0
Event: time 1631671358.313866, type 4 (EV_MSC), code 4 (MSC_SCAN), value 7003c
Event: time 1631671358.313866, type 1 (EV_KEY), code 61 (KEY_F3), value 0
Event: time 1631671358.313866, -------------- SYN_REPORT ------------
Event: time 1631671358.321862, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1631671358.321862, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time 1631671358.321862, -------------- SYN_REPORT ------------
Event: time 1631671358.337870, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e2
Event: time 1631671358.337870, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0
Event: time 1631671358.337870, -------------- SYN_REPORT ------------

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.