How to simulate press a key in linux kernel module? - linux

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.

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.

Related

VS Code not responding properly to keyboard switch in Linux Mint?

In my Linux Mint OS, I have switched the ESC key with the CAPS key. I know that the switch has been made because it works properly for every other application. However, when it comes to VS Code, in particular, I still need to press the ESC key in order to escape from auto complete suggestions.

Simulating Physical Keypress

So I have a keyboard, and it has a mode where it lights up every key you press.
I was wondering if you could physically simulate a keypress, AHK just sends it directly to the system.
However I need a way to make the keyboard light up, because AHK doesn't do that. The keyboard is not programmable.
Solutions in mostly any language are welcome.
This is not possible, you want to send a simulate keypress to your fysical keyboard. (this is i think a mechanical switch insite the keyboard self, that does do light up if you press a key) and it is only possible if the company did make a keyboard driver that allows you to change the settings (disable - light up) in the Windows Registry. (you did not give me the name of your keyboard but you can then try to searching into the registry for example software/Logitech/settings)

Which KEY_ macro in Linux input.h matches the menu key?

I want to use uinput to emulate pressing the menu key just next to the right Alt key. I tried KEY_MENU and KEY_CONTEXT_MENU, but neither of them worked. The key in Win32 API is VK_APPS.
KEY_COMPOSE is the correct Kernel keycode.
Some elaboration from Chromium’s keyboard event notes:
'Menu' and 'Props' naming differs between evdev and USB / UI Events. USB 0x010085 [System Main Menu] and USB 0x0C0040 [Menu Mode] both map to evdev 0x8B KEY_MENU (which has no corresponding UI Events |code|). USB 0x070076 [Keyboard Menu] does not map to KEY_MENU; it maps to evdev 0x82 KEY_PROPS, which is not the same as USB and UI Events "Props". USB 0x0700A3 [Props], which does correspond to UI Events "Props", is not mapped by the kernel. (And all of these are distinct from UI Events' "ContextMenu", which corresponds to USB 0x070065 [Keyboard Application] via evdev 0x7F KEY_COMPOSE, following Windows convention.)

Trouble Re-mapping keyboard on Raspberry Pi

I have Raspbian Debian Wheezy installed on my Raspberry Pi. I was trying to learn python in IDLE 3 but when I tried to type the Number symbol (aka Hashtag, Pound) it came out with "£", so I can't type the number symbol at all. Also this symbol " is now swapped with the #. I was trying to reconfigure my keyboard with "sudo raspi-config" but I don't know what my model for my keyboard is. I am not familiar with the logo. But in the back it says "98149 Multimedia Keyboard". Is there a way to remap my keyboard correctly?
P.S. The default selected model is Generic 105 key (Intl) PC
you can use this command
setxkbmap us

Keyboard input in Qt

I am working on a Qt application running on embedded Linux. I am pretty new to this Qt business since I have just started it a month back, so understand that I'm not that object-oriented ... :P
I have the Qt applications running on my target running Linux. The Qt documentation http://doc.qt.io/archives/qt-4.7/qt-embedded-pointer.html says that we have to enable touchscreen, USB keyboard, keypad, etc. by exporting certain variables. Namely,
export QWS_MOUSE_PROTO=tslib:/dev/input/event1
export QWS_KEYBOARD="linuxinput:/dev/input/event0 usb:/dev/input/event2"
well, as you can guess, first line sets the mouse device in QT as touchscreen. "tslib" is the touchscreen library, and the "event1" is the node representing the touchscreen. Similarly, second line is for on-board keypad (event0), and USB keyboard (event2).
Now, the touchscreen work very well. But the problem is with either keyboard. If I do not export the second variable, namely QWS_KEYBOARD , then the application runs fine. But if I do export the second variable, the application goes into stopped state (SIGSTOP) as soon as it is launched. This is evident from ps output. I can not make it work with SIGCONT.
I am going to try and reconfigure Qt from source. Any thoughts are welcome.
Can not believe this but setting the QWS_KEYBOARD variable as null solved the problem.
Found it in the Qt developer FAQ http://developer.qt.nokia.com/faq/answer/why_doesnt_my_keyboard_work_after_i_have_done_an_export_qws_keyboard_dev_tt
export QWS_KEYBOARD=""
Well, it did not completely solve the problem since I still have to include the native keypad along with the USB keyboard.
Anyway, I am able to move to fields using the arrow/TAB keys. Text input works well. Although CAPS-LOCK and NUM-LOCK do not seem to work. SHIFT works. I am able to terminate the application by Ctrl+Alt+Bkspce. So, for the time being, I am able to input text at least.
Will post if any improvements.

Resources