- Notifications
You must be signed in to change notification settings - Fork0
Convert MIDI input to linux evdev input with uinput and Jack
License
eras/midihidi
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Copyright 2022 Erkki Seppäläerkki.seppala@vincit.fi
Licensed under theMIT license
.
midihidi
converts a MIDI keyboard to a regularevdev
-supported oneby reading MIDI data (via Jack or the Jack layer of PipeWire) andproviding them via/dev/uinput
to/dev/input/event?
. This providesthe ability to enter keyboard input to any Linux application,including virtual consoles.
Grab a binary built on Linux x86/64 Ubuntu from Releases,chmod +x
it and move it to a directory of your choice.
You can also compile it yourself. To compile it you first need have athe Rust compiler. If your operating system doesn't come with the Rustcompiler, or the compiler is too old, then the easiest way to installone is to userustup
.
Once the compiler (andcargo
, the Rust package manager) isinstalled, you can just run the commandcargo install --git https://github.com/eras/midihidi
to install the latest version to~/.cargo/bin
.
You need to arrange both Jack (or PipeWire) and/dev/uinput
to beaccessible by the same user. The easiestand least secure way toachieve this is by changing the ownership of/dev/uinput
to have thesame user id as your current user id:
sudo chown $USER /dev/uinput
This change is temporary and will be reverted on boot. You can add anudev
rule to make permanent changes to the permissions. Be awarethat after this change any process you own is able to behave as if itwere a mouse or a keyboard.
The secure alternative would be to have special user that is able toaccess the device via ownership or group ownership, and also able tointeract with the user's media. I haven't yet tried how to make thishappen..
One step easier, but still probably slightly involved due to mediaaccess permissions, would be to runmidihidi
as root. I wouldconsider this secure.
For basic use you can use
midihidi --keymap alphabet
If you want it to automatically connect to some MIDI input, you can also use like
midihidi --keymap alphabet --input "Novation SL MkIII:Novation SL MkIII MIDI 1"
Once running, you can make use of the following mapping. On mykeyboard with zero transposition, the lowest key of the 49-key is key36, while the highest key is 84.
Alphabet(0) is either the key 'a' or the key 'q', on the 'alphabet'and 'qwerty' mappings, correspondingly.
(36u8, Mapping::Alphabet(0)), (37u8, Mapping::Fixed(input_linux::Key::LeftCtrl)), (38u8, Mapping::Alphabet(1)), (39u8, Mapping::Fixed(input_linux::Key::LeftAlt)), (40u8, Mapping::Alphabet(2)), (41u8, Mapping::Alphabet(3)), (42u8, Mapping::Fixed(input_linux::Key::CapsLock)), (43u8, Mapping::Alphabet(4)), (44u8, Mapping::Fixed(input_linux::Key::Esc)), (45u8, Mapping::Alphabet(5)), (47u8, Mapping::Alphabet(6)), // (48u8, Mapping::Alphabet(7)), (49u8, Mapping::Fixed(input_linux::Key::Num1)), (50u8, Mapping::Alphabet(8)), (51u8, Mapping::Fixed(input_linux::Key::Num2)), (52u8, Mapping::Alphabet(9)), (53u8, Mapping::Alphabet(10)), (54u8, Mapping::Fixed(input_linux::Key::Num3)), (55u8, Mapping::Alphabet(11)), (56u8, Mapping::Fixed(input_linux::Key::Num4)), (57u8, Mapping::Alphabet(12)), (58u8, Mapping::Fixed(input_linux::Key::Num5)), (59u8, Mapping::Alphabet(13)), // (60u8, Mapping::Alphabet(14)), (61u8, Mapping::Fixed(input_linux::Key::Num6)), (62u8, Mapping::Alphabet(15)), (63u8, Mapping::Fixed(input_linux::Key::Num7)), (64u8, Mapping::Alphabet(16)), (65u8, Mapping::Alphabet(17)), (66u8, Mapping::Fixed(input_linux::Key::Num8)), (67u8, Mapping::Alphabet(18)), (68u8, Mapping::Fixed(input_linux::Key::Num9)), (69u8, Mapping::Alphabet(19)), (70u8, Mapping::Fixed(input_linux::Key::Num0)), (71u8, Mapping::Alphabet(20)), // (72u8, Mapping::Alphabet(21)), (73u8, Mapping::Fixed(input_linux::Key::Left)), (74u8, Mapping::Alphabet(22)), (75u8, Mapping::Fixed(input_linux::Key::Down)), (76u8, Mapping::Alphabet(23)), (77u8, Mapping::Alphabet(24)), (78u8, Mapping::Fixed(input_linux::Key::Up)), (79u8, Mapping::Alphabet(25)), (80u8, Mapping::Fixed(input_linux::Key::Right)), // (81u8, Mapping::Fixed(input_linux::Key::Backspace)), (82u8, Mapping::Fixed(input_linux::Key::Break)), (83u8, Mapping::Fixed(input_linux::Key::Space)), (84u8, Mapping::Fixed(input_linux::Key::Enter)),
About
Convert MIDI input to linux evdev input with uinput and Jack