Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Fix "Keycode" within "KeyEvent" object #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ Documentation:

Development:
https://github.com/gvalkov/golang-evdev

*Fork Notes:*
-------------

The only changes between this and the original project (thus far) is
the keycode which is problematic. It works if you assume a particular
layout (maybe). The change is similar to some code in evdev-python.

One of two things needs to happen:

* The keycode is looked up in the keymap. I have no idea how to do
this.
* Keymap is stored as an array of possible codes requiring a compare
function. This is problematic in that any scancode can
theorhetically produce any keycode depending on layout and really
this just then becomes about the meaningful probability of a key
presenting a particular character/keycode.
4 changes: 2 additions & 2 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ const (
type KeyEvent struct {
Event *InputEvent
Scancode uint16
Keycode uint16
Keycode string
State KeyEventState
}

func (kev *KeyEvent) New(ev *InputEvent) {
kev.Event = ev
kev.Keycode = 0 // :todo
kev.Scancode = ev.Code
kev.Keycode = KEY[int(ev.Code)]

switch ev.Value {
case 0:
Expand Down