[Haifux] preventing caps lock at the kernel level

Rami Rosen rosenrami at gmail.com
Sat Mar 20 13:49:13 MSK 2010


Hi, Boaz,

I suggest that you'll look at the interrupt handler of the keyboard.
Usually, the i8042 chip family is the keyboard controller in desktops
and laptops.
First make sure that i8042 is indeed the driver you are using; run cat
/proc/interrupts and see whether
interrupt number 1 (the keyboard interrupt) is handled by i8042.
Then goto drivers/input/serio/i8042.c; i8042_interrupt() is the
handler for  keyboard interrupts. You can try add a filter there for
Caps Lock.

Even better is try to add code in i8042_filter() method, which is
called from i8042_interrupt(); this way you can be sure about locking.

I think that you should **not** try to write a simple module which
hookskeyboard interrupts. While this solution is usually better (you
don't change kernel code), I think it won't work in this case.
Namely, if you try something like this, in a kernel module:

free_irq (1, NULL);
res = request_irq (1, mykbdhandler, IRQF_SHARED, "mykbd", dev_id);

I think you will get an error, since
interrupt 1 (the PC keyboard interrupt) is edge-triggered (see cat
/proc/interrupts;
for interrupt 1 it says:"IO-APIC-edge" ). In
case of level-triggered interrupts this might have been OK.


Rgs,
Rami Rosen


On Sat, Mar 20, 2010 at 3:19 AM, boazg <boaz.gezer at gmail.com> wrote:
> hi,
> i have a laptop in which due to a hardware problem, computer thinks the caps
> lock key is pressed about 5 times a second, at random. i've disabled caps
> lock at the X11 level, and it's now usable. however, a few programs still
> have problems with the fact that a key is pressed (regardless of it being
> caps lock). also, i can't use the consoles at ctrl+alt+f[1..6].
> i wanted to have the kernel filter out caps lock and have the userland never
> see that is was pressed. to this end i edited drivers/char/keyboard.c and
> added a few spots where i return if the key is caps lock. this doesn't seem
> to work.
> anyone have any better ideas as to where i should be looking?
>
> thanks
>
> boazg
>
> _______________________________________________
> Haifux mailing list
> Haifux at haifux.org
> http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux
>
>



More information about the Haifux mailing list