Compare commits
No commits in common. "34de0948dadfb808db37322ff6c6d070d193b2a9" and "b73825843c215d8e404baebf57a7276fc2ebddf9" have entirely different histories.
34de0948da
...
b73825843c
4 changed files with 53 additions and 45 deletions
|
@ -1,8 +1,5 @@
|
|||
;; port of usb_keyboard.h
|
||||
|
||||
; Actually ErrorUndefined
|
||||
(define sticky-modifier 3)
|
||||
|
||||
(define key-a 4)
|
||||
(define key-b 5)
|
||||
(define key-c 6)
|
||||
|
@ -59,8 +56,8 @@
|
|||
(define key-quote 52)
|
||||
(define key-backslash 49)
|
||||
(define key-backtick 53)
|
||||
(define key-left-bracket 47) (define key-lbrack 47)
|
||||
(define key-right-bracket 48) (define key-rbrack 48)
|
||||
(define key-left-bracket 47)
|
||||
(define key-right-bracket 48)
|
||||
|
||||
(define key-period 55) (define key-. 55)
|
||||
(define key-slash 56) (define key-/ 56)
|
||||
|
|
26
menelaus.scm
26
menelaus.scm
|
@ -246,7 +246,6 @@
|
|||
|
||||
;; Vectors to store keycodes for the USB frame we are preparing to send.
|
||||
(define modifiers (vector 0 0 0 0 0))
|
||||
(define sticky-modifiers (vector 0 0 0 0 0))
|
||||
(define keycodes-down (vector 0 0 0 0 0 0))
|
||||
|
||||
;; For each element of the keycodes-down or modifiers vector, which physical
|
||||
|
@ -264,11 +263,6 @@
|
|||
(vector-set! modifiers (- keycode 1) 1)
|
||||
(vector-set! keys-for-modifiers (- keycode 1) key))
|
||||
|
||||
(define (press-sticky-modifier keycode)
|
||||
(vector-set! sticky-modifiers (- keycode 1) 1))
|
||||
(define (release-sticky-modifier keycode)
|
||||
(vector-set! sticky-modifiers (- keycode 1) 0))
|
||||
|
||||
;; Record that a given key resulted in a specific non-modifier press.
|
||||
(define (press-normal-key keycode key)
|
||||
(let ((slot (find keycodes-down 0)))
|
||||
|
@ -277,25 +271,17 @@
|
|||
|
||||
;; Record a key press in the modifiers/keycodes-down vectors for the layout.
|
||||
(define (press-key key)
|
||||
(let ((keycode (lookup key))
|
||||
(sticky (find sticky-modifiers 1)))
|
||||
(let ((keycode (lookup key)))
|
||||
;; Sometimes "keycodes" are procedures; in that case we call them with
|
||||
;; true when the key is pressed and false when it's released.
|
||||
(if (procedure? keycode)
|
||||
(keycode #t)
|
||||
(if (modifier? keycode)
|
||||
(if (uncombo keycode)
|
||||
(if (= (uncombo keycode) sticky-modifier)
|
||||
(press-sticky-modifier (unmodify keycode))
|
||||
(begin
|
||||
(press-modifier (unmodify keycode) key)
|
||||
(press-normal-key (uncombo keycode) key)))
|
||||
(press-modifier (unmodify keycode) key))
|
||||
(if sticky
|
||||
(begin (press-modifier (+ sticky 1) key)
|
||||
(press-normal-key keycode key)
|
||||
(release-sticky-modifier (+ sticky 1)))
|
||||
(press-normal-key keycode key))))))
|
||||
(begin (press-modifier (unmodify keycode) key)
|
||||
(if (uncombo keycode)
|
||||
(press-normal-key (uncombo keycode) key)
|
||||
#f))
|
||||
(press-normal-key keycode key)))))
|
||||
|
||||
;; Record that a given key being released resulted in a modifier release.
|
||||
(define (release-modifier keycode key n)
|
||||
|
|
62
qwerty.scm
62
qwerty.scm
|
@ -1,13 +1,30 @@
|
|||
;;; this is the qwerty layout
|
||||
|
||||
(include "keycodes.scm")
|
||||
|
||||
;; What are the rows and columns we care about?
|
||||
(define rows (list 0 1 2 3))
|
||||
(define columns (list 0 1 2 3 4 5 6 7 8 9 10 11))
|
||||
|
||||
;; Which GPIO pins are responsible for each row or column?
|
||||
;; These are the pins used by the kit-based Atreus; the Keyboardio Atreus uses
|
||||
;; a different set of pins.
|
||||
(define row-pins (vector 5 9 16 10))
|
||||
; +#define MATRIX_ROW_PINS { C6, B5, B2, B6 }
|
||||
(define column-pins (vector 21 19 20 18 15 7 6 4 3 2 0 1))
|
||||
; +#define MATRIX_COL_PINS { F4, F6, F5, F7, B1, E6, D7, D4, D0, D1, D2, D3 }
|
||||
|
||||
;; If you have a kit where the PCB is installed upside-down, uncomment this:
|
||||
;; (set! column-pins (vector 11 12 18 19 10 4 7 8 9 5 6))
|
||||
;; ;; Upside-down PCB makes the columns backwards but also trades ctrl and alt;
|
||||
;; ;; this hack only works for layouts where ctrl and alt are in standard place.
|
||||
;; (set! mod-alt (modify 1))
|
||||
;; (set! mod-ctrl (modify 3))
|
||||
|
||||
;; The above should be handled by a compile-time environment variable but that
|
||||
;; isn't yet part of Microscheme:
|
||||
;; https://github.com/ryansuchocki/microscheme/issues/32
|
||||
|
||||
;; we have to declare this up front and set it later because of circularity
|
||||
(define layers #f)
|
||||
(define current-layer #f)
|
||||
|
@ -18,47 +35,56 @@
|
|||
(define (set-layer n)
|
||||
(lambda (_) (set! current-layer (vector-ref layers n))))
|
||||
|
||||
;; On the Atreus Classic, we need to expose backtick on the fn layer, but on
|
||||
;; the Keyboardio Atreus it has its own key, so we put percent there instead.
|
||||
(define backtick-or-percent
|
||||
(sft key-5)
|
||||
;;key-backtick
|
||||
)
|
||||
|
||||
;;;; layers
|
||||
|
||||
(define noop 0)
|
||||
|
||||
(define base-layer
|
||||
(vector key-q key-w key-e key-r key-t noop noop key-y key-u key-i key-o key-p
|
||||
(vector key-q key-w key-e key-r key-t noop noop key-y key-u key-i key-o key-p
|
||||
|
||||
key-a key-s key-d key-f key-g noop noop key-h key-j key-k key-l key-semicolon
|
||||
key-a key-s key-d key-f key-g noop noop key-h key-j key-k key-l key-semicolon
|
||||
|
||||
key-z key-x key-c key-v key-b key-backtick key-backslash key-n key-m key-comma key-period key-slash
|
||||
|
||||
key-esc key-tab mod-super mod-shift key-backspace mod-ctrl
|
||||
mod-alt key-space fn key-dash key-quote key-enter))
|
||||
key-esc key-tab mod-super mod-shift key-backspace mod-ctrl
|
||||
mod-alt key-space fn key-dash key-quote key-enter))
|
||||
|
||||
(define fn-layer
|
||||
(vector (sft key-1) (sft key-2) key-up (sft key-4) (sft key-5) noop
|
||||
noop key-page-up key-7 key-8 key-9 key-backspace
|
||||
(vector (sft key-1) (sft key-2) key-up (sft key-4) backtick-or-percent noop
|
||||
noop key-page-up key-7 key-8 key-9 key-backspace
|
||||
|
||||
(sft key-9) key-left key-down key-right (sft key-0) noop
|
||||
noop key-page-down key-4 key-5 key-6 (altgr sticky-modifier)
|
||||
(sft key-9) key-left key-down key-right (sft key-0) noop
|
||||
noop key-page-down key-4 key-5 key-6 (altgr key-quote)
|
||||
|
||||
key-lbrack key-rbrack (sft key-3) (sft key-lbrack) (sft key-rbrack) (sft key-6)
|
||||
(sft key-7) (sft key-8) key-1 key-2 key-3 (sft key-equal)
|
||||
key-left-bracket key-right-bracket (sft key-3) (sft key-left-bracket)
|
||||
(sft key-right-bracket) (sft key-6)
|
||||
(sft key-7) (sft key-8) key-1 key-2 key-3 (sft key-equal)
|
||||
|
||||
;; set-layer 2 takes us to l2-layer below; doesn't need to be held
|
||||
(set-layer 2) key-insert mod-super mod-shift key-backspace mod-ctrl
|
||||
mod-alt key-space fn key-period key-0 key-equal))
|
||||
(set-layer 2) key-insert mod-super mod-shift key-backspace mod-ctrl
|
||||
mod-alt key-space fn key-period key-0 key-equal))
|
||||
|
||||
(define l2-layer
|
||||
(vector key-insert key-home key-up key-end key-page-up noop
|
||||
noop key-up key-f7 key-f8 key-f9 key-f10
|
||||
noop key-up key-f7 key-f8 key-f9 key-f10
|
||||
|
||||
key-delete key-left key-down key-right key-page-down noop
|
||||
noop key-down key-f4 key-f5 key-f6 key-f11
|
||||
noop key-down key-f4 key-f5 key-f6 key-f11
|
||||
|
||||
;; the B key enters the bootloader
|
||||
noop key-vol-up noop noop reset noop
|
||||
noop noop key-f1 key-f2 key-f3 key-f12
|
||||
noop key-vol-up noop noop reset noop
|
||||
noop noop key-f1 key-f2 key-f3 key-f12
|
||||
|
||||
noop key-vol-down mod-super mod-shift key-backspace mod-ctrl
|
||||
mod-alt key-space (set-layer 0) key-printscreen key-scroll-lock key-pause))
|
||||
noop key-vol-down mod-super mod-shift key-backspace mod-ctrl
|
||||
;; tapping the fn key brings us back to the base layer
|
||||
mod-alt key-space (set-layer 0) key-printscreen key-scroll-lock key-pause))
|
||||
|
||||
(set! layers (vector base-layer fn-layer l2-layer))
|
||||
(set! current-layer (vector-ref layers 0))
|
||||
|
|
3
test.rkt
3
test.rkt
|
@ -22,8 +22,7 @@
|
|||
(filter symbol? (list (if (positive? (bitwise-and mods 1)) 'ctrl 0)
|
||||
(if (positive? (bitwise-and mods 2)) 'shift 0)
|
||||
(if (positive? (bitwise-and mods 4)) 'alt 0)
|
||||
(if (positive? (bitwise-and mods 8)) 'super 0)
|
||||
(if (positive? (bitwise-and mods 64)) altgr 0))))
|
||||
(if (positive? (bitwise-and mods 8)) 'super 0))))
|
||||
|
||||
(define (usb-save mods . args)
|
||||
(set! last-usb-frame (cons (mods-list mods) args)))
|
||||
|
|
Loading…
Reference in a new issue