How does the keyboard driver binding logic work in UEFI? - uefi

The EFI console input device can not only have bindings with several keyboard drivers (PS/2, USB, terminal), but also several keyboards can be connected.
For instance: On my portable PC with built-in PS/2 keyboard I connected two USB keyboards by wire, and another wireless USB keyboard.
The keystrokes from all the keyboards enter as if typed from a single keyboard.
On top of that, this works hot plugable.
I assume that every driver binding instance has it's own buffer for scancode and efi code. So which (EDKII) function merges all the keystrokes?
Can I know on what keyboard the key data has been typed?

The merging of console input is done by the UEFI driver named "ConsoleSplitter", which hooks itself between the console drivers and a console user to merge console input and to split console output. I found this description on page 116 of the book "Beyond BIOS, 2° edition" published by intelpress. It is not mentioned on how to know the source of the input data.

Related

Keyboard Filter Driver. Scan Code -> VK_??? (OEM Specific)

Preface (Imaginary. So someone does not ask 'What are you trying to do?):
I have a Win32 C++ application.
This application wants to know when the user wants to open the start menu via Ctrl+Esc
Of course, Ctrl+Esc is fired from the operating system so the application never see's it.
I have looked at Windows Virtual Keys.
I see that there are plenty of OEM specific VK's
(0x92-0x96,0xE0,0xE9-0xF5,..)
So my thought was:
Keyboard Filter Driver.
When my application has the focus it tells the Keyboard Filter Driver.
When my driver sees the Ctrl is down and an Esc down occurs (And my application has focus):
-- Swallow the Esc and replace it with a scan code that will produce say a VK_0x92 (OEM Specific).
Since I have swallowed the Esc the operating system will never see Ctr+Esc
My application will then see the VK_0x92 and know the user wants to open the start menu and perform some action.
My question is how do I 'muck' the input within my driver (KEYBOARD_INPUT_DATA) in order for a say
VK_0x92 to appear within my application?
Thanks in advance for any pointers.
It is all about the Keyboard Layout.
What I needed to do was not supported by Microsoft Keyboard Layout Creator (MKLC).
See: Keyboard Layout Samples.
I found the samples to be very old and hard to read through. Clearly the US and German keyboard samples are not the most recent.
I wrote a program to create Visual Studio projects for keyboard layouts by pointing to a specific layout (I.e, KBDUS.dll for example). I generate the source code, .vxcproj, ... I then make my modifications and build it.
Installing the layout is another can of worms entirely. I have asked in several places for Microsoft to release the source code for the CustomAction Dll that is contained within the MKLC generated .MSI to no avail.

How do programs like Emacs and Nano get user input while running in terminal without the user having to press enter?

Programs like Emacs and Nano can run in a terminal window and accept real time user input, how might I accomplish this myself? I am looking to use C++ but I can see this could require interfacing with the user's shell, in this case Bash. How can I take input (be it from the mouse or keyboard) from the terminal window without the user having to press enter?
My target platform is Mac OSX Version 10.13.5, but answers on how to do this on other platforms like Windows or Linux are also welcome.
These programs set the terminal to raw mode as opposed to cooked mode. Cooked mode is read a line at a time and is handled by the terminal driver, and raw mode is read a character at a time and is handled by the running program instead.
This Answer has more information.
This Repo is a simple project that implements this mode that you can learn from. man termios will also give you information about manipulating terminal modes.

Controlling VS code with a launchpad

I really enjoy using vs code but there are some many shortcuts to remember and every new plugins come with a new set.
Of course, I can use the command palette in order to quickly execute a command, but I would like something even more faster such as assigning a shortcut to any of the keys for a device like a Novation Launchpad midi controller.
Stackoverflow is maybe not the best plase to ask this question but I didn't knew where to post it, so is there anyone who tried something like this? I have seen this video (https://www.youtube.com/watch?v=LOyNUGS4RC8) linking such a device with visual studio so perhaps someone created a software dedicated for vs code already.
Regards,
Johnny -
I've setup this with MIDI Loupe and midiStroke.
MIDI Loupe listens your device and logs channel/key/value you just hit on your midi controller - with this tool you inspect your device's output.
Then in midiStroke you map controls to shortcuts.
Note: I've found my midiStroke setup for M-Audio Axiom 49 keys don't require values (only key number) but controls (e.g. record start) do require it. Also for me letter keys didn't not work if uppercased (e.g. for garageband recording start I need simply R button hit and R should be r in this case)
Detailed tutorial here

Remap meta key to other key on the keyboard

I have a programmable mechanical keyboard and can place any key anywhere.
At our company we recently switched to windows PCs and so that broke my emacs configuration because of the dreaded windows key which I tried to map to Meta but never got it to work.
Basically I use tigervnc to run vnc session that runs on linux.
Running emacs under linux in the VNC on a windows machine is a pain.
Every time I click the windows button to act as a meta the windows menu popup.
Anyways, I wonder if I can map Meta key to say "insert key", and the program the keyboard to have "insert" in place of "windows key" and vice versa.
I am also using ALT for other configurations so I don't want to map meta to ALT since I sometimes use all three combinations "Ctrl+ALT+Meta"+F-keys.
Is there a way to do so?
It would help if you can tell us which keyboard you own.
If it supports QMK firmware, you can just create two layers of keymaps for regular Windows usage and for VNC.
I think you will need to peruse Keymaps for Translating Sequences of Events (function-key-map et al).

How to create your own Windows XP Keyboard Mapping?

My father has found a Russian language keyboard mapping that he really likes here. However, it is non-standard and therefore is not one that appears in the Languages (Control Panel->Regional and Language Options->Languages->Details->Text Services And Input Languages->Add) dropdown for keyboard layout selection. To my understanding, it should be a simple task to create a new mapping - perhaps editing an XML file and a reboot. Does anyone know how to do this?
Barring that, how would I go about writing a program to emulate this? It seems like it would have to run in the system tray (I can figure that out), have a hook intercepting incoming keyboard input (no idea how to do this), convert it off a configuration file, and send it to whatever application and text window has current focus (again, no idea). With any luck this should not be too hard.
Any advice?
There's this utility from Microsoft
The Microsoft Keyboard Layout Creator
(MSKLC) extends the international
functionality of Windows 2000, Windows
XP, Windows Server 2003,and Windows
Vistas systems by allowing users to:
Create new keyboard layouts from scratch
Base a new layout on an existing one
Modify an existing keyboard layout and build a new layout from it
Multilingual input locales within edit control fields.
Build keyboard layout DLLs for x86, x64, and IA64 platforms.
Package the resulting keyboard layouts for subsequent delivery and installation.
Try AutoHotKey (http://www.autohotkey.com/) i use it to get emacs keybindings in normal text editors, i'm sure it could tackle this too.
edit: the bit you're looking for is in the quickstart here: http://www.autohotkey.com/docs/Tutorial.htm#Send