0

How to simulate press a key in linux kernel module? I saw keybdev.c, but in my case I cant compile it `

error: implicit declaration of function ‘handle_scancode’

Maybe it's obsolete.

stark
  • 12,615
  • 3
  • 33
  • 50
JustOneMan
  • 231
  • 1
  • 9
  • 34
  • Does this answer your question? [Simulating mouse events and keyboard events c++ linux](https://stackoverflow.com/questions/13041511/simulating-mouse-events-and-keyboard-events-c-linux) – stark Aug 16 '22 at 17:56
  • It's not kernel module, your link is user space code as I understand. – JustOneMan Aug 16 '22 at 19:30

1 Answers1

1

In the kernel, keyboards can call input_report_key which generates a keyboard event. The USB keyboard driver in /drivers/hid/usbhid/usbkbd.c is a good example of code to do both keyboard input and LED output.

stark
  • 12,615
  • 3
  • 33
  • 50