Messages in this thread | | | From | "常廉志" <> | Subject | Re: [PATCH v7] tty: Fix the keyboard led light display problem | Date | Tue, 26 Oct 2021 23:41:17 +0800 |
| |
On Tue, Oct 26, 2021 at 05:23:35PM +0300, Andy Shevchenko wrote: > On Tue, Oct 26, 2021 at 10:40:32AM +0800, lianzhi chang wrote: > > Switching from the desktop environment to the tty environment, > > the state of the keyboard led lights and the state of the keyboard > > lock are inconsistent. This is because the attribute kb->kbdmode > > of the tty bound in the desktop environment (xorg) is set to > > Xorg > > I think I already pointed that out. > > > VC_OFF, which causes the ledstate and kb->ledflagstate > > values of the bound tty to always be 0, which causes the switch > > from the desktop When to the tty environment, the LED light > > status is inconsistent with the keyboard lock status. > > ... > > > +static void kbd_update_ledstate(struct input_dev *dev) > > +{ > > + if (!!test_bit(LED_NUML, dev->led) != > > + !!(ledstate & BIT(VC_NUMLOCK))) > > + ledstate ^= BIT(VC_NUMLOCK); > > + if (!!test_bit(LED_CAPSL, dev->led) != > > + !!(ledstate & BIT(VC_CAPSLOCK))) > > + ledstate ^= BIT(VC_CAPSLOCK); > > + if (!!test_bit(LED_SCROLLL, dev->led) != > > + !!(ledstate & BIT(VC_SCROLLOCK))) > > + ledstate ^= BIT(VC_SCROLLOCK); > > This looks ugly.
I think it can be done like this: static void kbd_update_ledstate(struct input_dev *dev) { ledstate = (test_bit(LED_SCROLL,dev->led) ?1 :0) | (test_bit(LED_NUML,dev->led) ?2 :0) | (test_bit(LED_CAPSL,dev->led) ?3 :0) }
If this change does not work, please reply to me. I have not understood the other content. It is too late today, I will continue tomorrow!
Thanks. -- lianzhi chang | |