key.scm 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ;; Copyright (c) 2001-2003 by David Frese
  2. ;; a keysym is a 16-bit protocol ID (see X11/keysymdef.h)
  3. ;; a keycode is an integer specifying a single key on the keyboard
  4. ;; (hardware depended)
  5. ;; *** manipulate keyboard encoding **********************************
  6. ;; a keyboard mapping is a list of lists of keysyms
  7. (import-xlib-function change-keyboard-mapping
  8. (display first-keycode keysyms-lists)
  9. "scx_Change_Keyboard_Mapping")
  10. ;; returns keycode-count lists of keysyms
  11. (import-xlib-function get-keyboard-mapping
  12. (display first-keycode keycode-count)
  13. "scx_Get_Keyboard_Mapping")
  14. ;; returns a pair (min-keycodes . max-keycodes)
  15. (import-xlib-function display-keycodes (display)
  16. "scx_Display_Keycodes")
  17. ;; a modmap is an alist mapping a modifier to a list of
  18. ;; keycodes. Valid modifiers are (state shift) (state lock) (state
  19. ;; control) (state mod1) (state mod2) (state mod3) (state mod4)
  20. ;; (state mod5)
  21. (import-xlib-function set-modifier-mapping (display modmap)
  22. "scx_Set_Modifier_Mapping")
  23. (import-xlib-function get-modifier-mapping (display)
  24. "scx_Get_Modifier_Mapping")
  25. ;; *** convert keysyms ***********************************************
  26. (import-lambda-definition-2 string->keysym (string)
  27. "scx_String_To_Keysym")
  28. (import-lambda-definition-2 keysym->string (keysym)
  29. "scx_Keysym_To_String")
  30. ;; TODO include X11/keysymdef.h ??
  31. (import-xlib-function keycode->keysym (display keycode index)
  32. "scx_Keycode_To_Keysym")
  33. (import-xlib-function keysym->keycode (display keysym)
  34. "scx_Keysym_To_Keycode")
  35. ;; returns a pair (lower . upper)
  36. (import-lambda-definition-2 convert-case (keysym)
  37. "scx_Convert_Case")
  38. (define (convert-to-lowercase keysym)
  39. (car (convert-case keysym)))
  40. (define (convert-to-uppercase keysym)
  41. (cdr (convert-case keysym)))
  42. ;; *** handle keyboard input events in Latin-1 ***********************
  43. (import-lambda-definition-2 %lookup-keysym (key-event index)
  44. "scx_Lookup_Keysym")
  45. (define (lookup-keysym key-event index)
  46. (call-xlib-function (key-event-display key-event) 'lookup-keysym
  47. (lambda () (%lookup-keysym key-event index))))
  48. (import-lambda-definition-2 %refresh-keyboard-mapping (mapping-event)
  49. "scx_Refresh_Keyboard_Mapping")
  50. (define (refresh-keyboard-mapping mapping-event)
  51. (call-xlib-function (mapping-event-display mapping-event)
  52. 'refresh-keyboard-mapping
  53. (lambda () (%refresh-keyboard-mapping mapping-event))))
  54. ;; returns a pair (keysym . string)
  55. (import-lambda-definition-2 %lookup-string/keysym (key-event)
  56. "scx_Lookup_String")
  57. (define (lookup-string/keysym key-event)
  58. (call-xlib-function (key-event-display key-event)
  59. 'lookup-string/keysym
  60. (lambda () (%lookup-string/keysym key-event))))
  61. (define (lookup-string key-event)
  62. (cdr (lookup-string/keysym key-event)))
  63. (import-xlib-function rebind-keysym (display keysym mod-keysyms string)
  64. "scx_Rebind_Keysym")