cl-rw

Layered streams for Common Lisp
git clone https://logand.com/git/cl-rw.git/
Log | Files | Refs

commit 9c4d267738543fd7e4ab4b4aad906b17b0a43e26
parent ab79d7fbe27d4097ee7f8c87f35a9f22b01924e5
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 20 Sep 2015 18:18:44 +0200

linux mouse experiment

Diffstat:
Alinux/input.lisp | 45+++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+), 0 deletions(-)

diff --git a/linux/input.lisp b/linux/input.lisp @@ -0,0 +1,45 @@ +;;; Copyright (C) 2015 Tomas Hlavaty <tom@logand.com> +;;; +;;; Permission is hereby granted, free of charge, to any person +;;; obtaining a copy of this software and associated documentation +;;; files (the "Software"), to deal in the Software without +;;; restriction, including without limitation the rights to use, copy, +;;; modify, merge, publish, distribute, sublicense, and/or sell copies +;;; of the Software, and to permit persons to whom the Software is +;;; furnished to do so, subject to the following conditions: +;;; +;;; The above copyright notice and this permission notice shall be +;;; included in all copies or substantial portions of the Software. +;;; +;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +;;; DEALINGS IN THE SOFTWARE. + +(defpackage :rw.linux.input + (:use :cl)) + +(in-package :rw.linux.input) + +(defun mouse-event-reader (octet-reader) + (lambda () + (let ((i1 (rw:next octet-reader))) + (when i1 + (let ((i2 (rw:next octet-reader)) + (i3 (rw:next octet-reader))) + ;; left i1 & 1 + ;; middle i1 & 4 + ;; right i1 & 2 + ;; x i2 y i3 + (list i1 i2 i3)))))) + +#+nil +(with-open-file (s "/dev/input/mice" + :element-type '(unsigned-byte 8)) + (let ((r (mouse-event-reader (rw:byte-reader s)))) + (dotimes (i 100) + (print (rw:next r)))))