lsongdev / lsongdev/input-event

library is not working with more than 2 keyboards

Open
#6 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
JavaScript
Stars
65
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Hi!

Thank you for this great library.
It is exactly what I need for a project where i have to listen to and be able to distinguish between 4 different keyboard inputs.

I tried it on ubuntu 16.04 and on raspberry pi 3.
Everything works fine with **2** keyboards attached, but unfortunately I get some very strange behaviour when I attach a **third** one.

I use this slightly modified example code inside of the `example` folder
```
const InputEvent = require('../')

let inputSlots = [21, 23]
let inputs = []
let readers = []

for (let i = 0; i < inputSlots.length; i++) {
try {
inputs[i] = new InputEvent(`/dev/input/event${inputSlots[i]}`)
readers[i] = new InputEvent.Keyboard(inputs[i])
readers[i].on('keyup', (data) => { console.log(`reader ${i}: ${data.code}`) })
} catch (err) {
console.error(`Can not open device ${i}`)
}
if (readers[i]) {
readers[i].on('error', (data) => { console.log(`reader ${i}: ${data.code}`) })
}
}
```
When I adapt the `inputSlots` array and attach a third keyboard, the keycode doesn't get logged to the console immediately when pressing a key.
I have to press a key on one of the other 2 attached keyboards, then the keycode from before **and** the keycode from the key that was just pressed are logged.
If i now press another key on this keyboard the thing starts again and i have to press a key on one of the other keyboards in order to log the keycode.

I am wondering if you have ever encountered this problem, or if you happen to know what could be the reason for this behaviour.

I also tried it with the 'keydown' and 'keypress' event, but that didnt change anything.

Thank you very much
Best regards

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the modified example in the example folder and reproduce the behavior using /dev/input/event21 and /dev/input/event23, then add a third keyboard as described. Trace how the library reads and emits events for each device on Ubuntu or Raspberry Pi; done means key events from all attached keyboards are logged immediately and independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.