不能使用键盘小键盘输入数字

时间:2012-11-01 09:29:19

标签: common-lisp xlib

使用stumpwm,我无法使用numpad在Evaling窗口中输入数字(NumLock已经打开)。通过黑客入侵input.lisp,我发现了以下结果:

#'读取键和选择将为主键区和小键盘返回不同的值。

             1         2         3         4         5         6         7         8          9
primary pad  (10 . 16) (11 . 16) (12 . 16) (13 . 16) (14 . 16) (15 . 16) (16 . 16) (17 . 16) (18 . 16)
numpad       (87 . 16) (88 . 16) (89 . 16) (83 . 16) (84 . 16) (85 . 16) (79 . 16) (80 . 16) (81 . 16)

它导致#'进程输入将小键盘输入视为:错误。

(defun read-key-or-selection ()
    (loop for ev = (xlib:process-event *display* :handler #'read-key-or-selection-handle-event :timeout nil) do
        (cond ((stringp ev)
            (return ev))
         ((and (consp ev)
               (eq (first ev) :key-press))
           (return (cdr ev))))))

(defun read-key-or-selection-handle-event (&rest event-slots &key display event-key &allow-other-keys)
    (declare (ignore display))
    (case event-key
        ((or :key-release :key-press)
         (apply 'input-handle-key-press-event event-slots))
        (:selection-notify
         (apply 'input-handle-selection-event event-slots))
        (t nil)))

(defun input-handle-key-press-event (&rest event-slots &key event-key root code state &allow-other-keys)
    (declare (ignore event-slots root))
    (list* event-key code state))

从上面的代码来看,#xlib:process-event似乎存在问题。但我不知道如何解决它?

请点亮我,谢谢!

1 个答案:

答案 0 :(得分:1)

找到一种不规范的方式,但它有效。 https://github.com/sw2wolf/stumpwm/blob/master/input.lisp