scx/scheme/xlib/key.scm

93 lines
2.8 KiB
Scheme
Raw Normal View History

;; Copyright (c) 2001-2003 by David Frese
;; a keysym is a 16-bit protocol ID (see X11/keysymdef.h)
2001-08-22 07:50:05 -04:00
;; a keycode is an integer specifying a single key on the keyboard
;; (hardware depended)
2001-08-22 07:50:05 -04:00
;; *** manipulate keyboard encoding **********************************
2001-08-22 07:50:05 -04:00
;; a keyboard mapping is a list of lists of keysyms
2001-08-22 07:50:05 -04:00
(import-xlib-function change-keyboard-mapping
(display first-keycode keysyms-lists)
"scx_Change_Keyboard_Mapping")
;; returns keycode-count lists of keysyms
(import-xlib-function get-keyboard-mapping
(display first-keycode keycode-count)
"scx_Get_Keyboard_Mapping")
2001-08-22 07:50:05 -04:00
;; returns a pair (min-keycodes . max-keycodes)
(import-xlib-function display-keycodes (display)
"scx_Display_Keycodes")
2001-08-22 07:50:05 -04:00
;; a modmap is an alist mapping a modifier to a list of
;; keycodes. Valid modifiers are (state shift) (state lock) (state
;; control) (state mod1) (state mod2) (state mod3) (state mod4)
;; (state mod5)
(import-xlib-function set-modifier-mapping (display modmap)
"scx_Set_Modifier_Mapping")
2001-08-22 07:50:05 -04:00
(import-xlib-function get-modifier-mapping (display)
"scx_Get_Modifier_Mapping")
2001-08-22 07:50:05 -04:00
;; *** convert keysyms ***********************************************
2001-08-22 07:50:05 -04:00
(import-lambda-definition string->keysym (string)
"scx_String_To_Keysym")
2001-08-22 07:50:05 -04:00
(import-lambda-definition keysym->string (keysym)
"scx_Keysym_To_String")
;; TODO include X11/keysymdef.h ??
2001-08-22 07:50:05 -04:00
(import-xlib-function keycode->keysym (display keycode index)
2001-08-22 07:50:05 -04:00
"scx_Keycode_To_Keysym")
(import-xlib-function keysym->keycode (display keysym)
2001-08-22 07:50:05 -04:00
"scx_Keysym_To_Keycode")
;; returns a pair (lower . upper)
(import-lambda-definition convert-case (keysym)
"scx_Convert_Case")
(define (convert-to-lowercase keysym)
(car (convert-case keysym)))
2001-08-22 07:50:05 -04:00
(define (convert-to-uppercase keysym)
(cdr (convert-case keysym)))
2001-08-22 07:50:05 -04:00
;; *** handle keyboard input events in Latin-1 ***********************
(import-lambda-definition %lookup-keysym (key-event index)
"scx_Lookup_Keysym")
2001-08-22 07:50:05 -04:00
(define (lookup-keysym key-event index)
(call-xlib-function (key-event-display key-event) 'lookup-keysym
(lambda () (%lookup-keysym key-event index))))
(import-lambda-definition %refresh-keyboard-mapping (mapping-event)
"scx_Refresh_Keyboard_Mapping")
2001-08-22 07:50:05 -04:00
(define (refresh-keyboard-mapping mapping-event)
(call-xlib-function (mapping-event-display mapping-event)
'refresh-keyboard-mapping
(lambda () (%refresh-keyboard-mapping mapping-event))))
;; returns a pair (keysym . string)
(import-lambda-definition %lookup-string/keysym (key-event)
"scx_Lookup_String")
(define (lookup-string/keysym key-event)
(call-xlib-function (key-event-display key-event)
'lookup-string/keysym
(lambda () (%lookup-string/keysym key-event))))
(define (lookup-string key-event)
(cdr (lookup-string/keysym key-event)))
2001-08-22 07:50:05 -04:00
(import-xlib-function rebind-keysym (display keysym mod-keysyms string)
"scx_Rebind_Keysym")