MCPcopy Index your code
hub / github.com/BobdaProgrammer/doWM / getKeycodeForKeysym

Function getKeycodeForKeysym

wm/window_manager.go:360–385  ·  view source on GitHub ↗
(conn *xgb.Conn, keysym uint32)

Source from the content-addressed store, hash-verified

358
359
360func getKeycodeForKeysym(conn *xgb.Conn, keysym uint32) xproto.Keycode {
361 setup := xproto.Setup(conn)
362 firstKeycode := setup.MinKeycode
363 lastKeycode := setup.MaxKeycode
364
365 // Number of keycodes in range:
366 count := lastKeycode - firstKeycode + 1
367
368 keymap, err := xproto.GetKeyboardMapping(conn, firstKeycode, uint8(count)).Reply()
369 if err != nil {
370 slog.Error("failed to get keyboard mapping", "error:", err)
371 return 0
372 }
373
374 targetKeysym := xproto.Keysym(keysym)
375
376 for kc := firstKeycode; kc <= lastKeycode; kc++ {
377 offset := int(kc - firstKeycode) * int(keymap.KeysymsPerKeycode)
378 for i := 0; i < int(keymap.KeysymsPerKeycode); i++ {
379 if keymap.Keysyms[offset+i] == targetKeysym {
380 return kc
381 }
382 }
383 }
384 return 0
385}
386
387
388

Callers 1

getNumLockMaskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected