Step 3: all the keys (except modifiers)
This commit is contained in:
parent
6833dfbf7c
commit
21d0b631c2
2 changed files with 24 additions and 21 deletions
16
layout.scm
16
layout.scm
|
@ -1,9 +1,9 @@
|
|||
(define layout
|
||||
(list (list key-q key-w key-e key-r key-t 0
|
||||
key-y key-u key-i key-o key-p)
|
||||
(list key-a key-s key-d key-f key-g 0
|
||||
key-h key-j key-k key-l key-semicolon)
|
||||
(list key-z key-x key-c key-v key-b mod-alt
|
||||
key-n key-m key-comma key-period key-slash)
|
||||
(list key-esc key-tab mod-gui mod-shift key-backspace mod-ctrl
|
||||
key-space mod-fn key-dash key-quote key-enter)))
|
||||
(vector key-q key-w key-e key-r key-t 0
|
||||
key-y key-u key-i key-o key-p
|
||||
key-a key-s key-d key-f key-g 0
|
||||
key-h key-j key-k key-l key-semicolon
|
||||
key-z key-x key-c key-v key-b mod-alt
|
||||
key-n key-m key-comma key-period key-slash
|
||||
key-esc key-tab mod-gui mod-shift key-backspace mod-ctrl
|
||||
key-space mod-fn key-dash key-quote key-enter))
|
||||
|
|
29
menelaus.scm
29
menelaus.scm
|
@ -1,28 +1,31 @@
|
|||
(include "keycodes.scm")
|
||||
(include "layout.scm")
|
||||
|
||||
(define columns (list 0 1 2 3 4 5 6 7 8 9))
|
||||
(define column-pins (vector 11 12 18 19
|
||||
10 7 8 9 5 6))
|
||||
(define layout (vector key-a key-s key-d key-f key-g
|
||||
key-h key-j key-k key-l key-semicolon))
|
||||
|
||||
(for-each output (list 0 1 2 3))
|
||||
(for-each high (list 0 1 3))
|
||||
(low 2)
|
||||
(define rows (list 0 1 2 3))
|
||||
(define row-pins (vector 3 2 1 0))
|
||||
(define columns (list 0 1 2 3 4 5 6 7 8 9 10))
|
||||
(define column-pins (vector 11 12 18 19 10 4 7 8 9 5 6))
|
||||
|
||||
(for-each-vector output row-pins)
|
||||
(for-each-vector high row-pins)
|
||||
(for-each-vector input column-pins)
|
||||
(for-each-vector high column-pins) ; activate pullup resistors
|
||||
|
||||
(call-c-func "usb_init")
|
||||
(pause 200)
|
||||
|
||||
(define (scan-column last n)
|
||||
(if (low? (vector-ref column-pins n))
|
||||
(vector-ref layout n)
|
||||
(define (scan-column last offset)
|
||||
(if (low? (vector-ref column-pins (mod offset 11)))
|
||||
(vector-ref layout offset)
|
||||
last))
|
||||
|
||||
(define (scan-row last row)
|
||||
(for-each-vector high row-pins)
|
||||
(low (vector-ref row-pins row))
|
||||
(fold scan-column last (map (lambda (col) (+ col (* row 11))) columns)))
|
||||
|
||||
(define (loop)
|
||||
(let ((pressed (fold scan-column 0 columns)))
|
||||
(let ((pressed (free! (fold scan-row 0 rows))))
|
||||
(call-c-func "usb_send" 0 pressed 0 0 0 0 0))
|
||||
(loop))
|
||||
|
||||
|
|
Loading…
Reference in a new issue