Git Product home page Git Product logo

Comments (4)

gethiox avatar gethiox commented on July 16, 2024 1

I think commenting that is a great idea, I made required changes in #15
We can't easily comment specific XNames block, but there is a comment at the begging of XNames sections, should be sufficient.

from go-evdev.

gethiox avatar gethiox commented on July 16, 2024

@guettli
Because different names can point to the very same keycode (for example KEY_DIRECTION and KEY_ROTATE_DISPLAY points to the same code number), table has been split for string conversion and debug information separately.

First map KEYToString provides only one name for given keycode (first found in header files), this is used for conversion from keycode to string representation that can be easily reversed later with KEYFromString (XFromString actually provides conversion for all keycode aliases by the way).

KEYNames However, provides all aliases separated with slash, its purpose is debug/information only.
as an example:

KEY_ALL_APPLICATIONS: "KEY_ALL_APPLICATIONS/KEY_DASHBOARD",
KEY_COFFEE: "KEY_COFFEE/KEY_SCREENLOCK",
KEY_ROTATE_DISPLAY: "KEY_ROTATE_DISPLAY/KEY_DIRECTION",
KEY_BRIGHTNESS_AUTO: "KEY_BRIGHTNESS_AUTO/KEY_BRIGHTNESS_ZERO",
BTN_GAMEPAD: "BTN_GAMEPAD/BTN_SOUTH/BTN_A",
BTN_NORTH: "BTN_NORTH/BTN_X",
BTN_WEST: "BTN_WEST/BTN_Y",

You can argue if two tables has some real value in the library, for many usecases KeyToString representation is good enough. It was my idea to make it that way, memory cost of such additional table is negligible but on the other hand it adds a little bit of complexity at generating process.

from go-evdev.

zonque avatar zonque commented on July 16, 2024

@gethiox Thanks for answering this one.
@guettli Let me know if that answer satisfies you and the issue can be closed.

from go-evdev.

guettli avatar guettli commented on July 16, 2024

@gethiox thank you for the explanation. I had a rough look at both maps, and overlooked entries like "KEY_COFFEE/KEY_SCREENLOCK".

Why not add a comment like this, to make it more clear:

// KEYNames maps from EvCode to a string.
// If one EvCode has two string representations, both are seperated by a slash.
// Example: KEY_COFFEE: "KEY_COFFEE/KEY_SCREENLOCK"
var KEYNames = map[EvCode]string{
...

I think this would help new users to understand that.

I could create a PR, but feel free to just do it yourself - whatever is more convenient for you.

from go-evdev.

Related Issues (3)

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.