Giter VIP home page Giter VIP logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 28, 2024
Very good investigative work!

Spawning just one more grep process, the workaround could be as easy as:

grep -E 'Name|Handlers' /proc/bus/input/devices | grep -EA1 '[Kk]eyboard' | 
grep -Eo 'event[0-9]+'

However, I would be very interested in your solution. :)

Original comment by [email protected] on 15 Aug 2010 at 6:20

  • Changed title: eventX different after USB keyboard is reconnected
  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****

from logkeys.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 28, 2024
Disregard that last part.
I am more than interested. :D

Original comment by [email protected] on 15 Aug 2010 at 6:23

  • Added labels: ****
  • Removed labels: ****

from logkeys.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 28, 2024
Hello!

The attached file contains the code for a new device detection routine, which I 
just finished writing.

Here is how it works:
- opens the file /proc/bus/input/devices
- scans for rows that begin with 'N' (name rows)
- checks if the name row contains text that indicates it's a keyboard (contains 
"keyboard", "kbd", "hid", etc.)
- then scans for rows that begin with 'H' (handler rows)
- extracts the event number from the handler row

It has some features to try to make it robust. For example, if a keyboard 
device is found but there is no handler row, then the code just continues 
looking for the next keyboard device.

Also the code should be easy to modify to locate all keyboard devices (e.g. 
return a std::vector<std::string> containing all input devices found). Right 
now it stops when it finds the first one.

Finally, please note that I have only spent about 30 minutes testing this 
routine. It seems to work properly on my machine, but bugs may turn up. :-)

Best regards,
Markus.

Original comment by [email protected] on 15 Aug 2010 at 6:47

  • Added labels: ****
  • Removed labels: ****

Attachments:

from logkeys.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 28, 2024
Oops :-) I just noticed that my determine_input_device() function is missing 
the following line at the very end:

    return std::string();

If no keyboard devices are found, and a return statement is not there, then we 
will get undefined behaviour.

Regards,
Markus.

Original comment by [email protected] on 15 Aug 2010 at 6:52

  • Added labels: ****
  • Removed labels: ****

from logkeys.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 28, 2024
Device detection now parses 'Handlers' line and results in a vector since r74.

Original comment by [email protected] on 19 Aug 2010 at 5:58

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

from logkeys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.