Made separate function for converting keycode to keysym

This commit is contained in:
2022-11-14 15:58:34 -05:00
parent aee4158d2d
commit 820c7d4f6a
3 changed files with 27 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package x
import "github.com/jezek/xgb/xproto"
import "github.com/jezek/xgbutil/keybind"
import "git.tebibyte.media/sashakoshka/stone"
// when making changes to this file, look at keysymdef.h
@@ -54,6 +55,24 @@ var buttonCodeTable = map[xproto.Keysym] stone.Button {
0xFFC9: stone.KeyF12,
}
func (backend *Backend) keycodeToKeysym (
keycode xproto.Keycode,
) (
keysym xproto.Keysym,
) {
keysym = keybind.KeysymGet(backend.connection, keycode, 0)
// TODO: shift isnt working. follow
// https://tronche.com/gui/x/xlib/input/keyboard-encoding.html
println("--")
println(keycode)
println(keysym)
println(stone.EventPress(keysymToButtonCode(keysym)))
return
}
func keysymToButtonCode (keysym xproto.Keysym) (button stone.Button) {
var isControl bool
button, isControl = buttonCodeTable[keysym]