Mi teclado & mi layout

This commit is contained in:
Cat /dev/Nulo 2021-12-02 15:22:30 -03:00
parent 9b59db6754
commit b73825843c
3 changed files with 37 additions and 33 deletions

View file

@ -103,8 +103,10 @@
(define mod-shift (modify 2))
(define mod-alt (modify 3))
(define mod-super (modify 4))
(define mod-altgr (modify 5))
(define (sft keycode) (combo mod-shift keycode)) ; shorthand
(define (altgr keycode) (combo mod-altgr keycode)) ; shorthand
;; Enter the bootloader in preparation for flashing.
(define (reset _) (call-c-func "reset"))

View file

@ -245,12 +245,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Vectors to store keycodes for the USB frame we are preparing to send.
(define modifiers (vector 0 0 0 0))
(define 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
;; key caused it to be pressed?
(define keys-for-modifiers (vector #f #f #f #f))
(define keys-for-modifiers (vector #f #f #f #f #f))
(define keys-for-frame (vector #f #f #f #f #f #f))
;; Given a physical key index, what keycode does it map to in the layout?
@ -289,7 +289,7 @@
(begin
(vector-set! modifiers n 0)
(vector-set! keys-for-modifiers n #f))
(and (< n 3) (release-modifier keycode key (+ n 1)))))
(and (< n 4) (release-modifier keycode key (+ n 1)))))
;; Record a key release, clearing it out of the press tracking data.
(define (release-key key)
@ -329,7 +329,7 @@
;; Actually send the USB frame.
(define (usb-send m k0 k1 k2 k3 k4 k5)
(let ((mods (+ (vector-ref m 0) (* (vector-ref m 1) 2)))) ; + isn't variadic
(let ((mods (+ mods (+ (* (vector-ref m 2) 4) (* (vector-ref m 3) 8)))))
(let ((mods (+ mods (+ (+ (* (vector-ref m 2) 4) (* (vector-ref m 3) 8)) (* (vector-ref m 4) 64)))))
;; call-c-func is a special form and cannot be applied
(call-c-func "usb_send" mods k0 k1 k2 k3 k4 k5))))

View file

@ -4,13 +4,15 @@
;; 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))
(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 3 2 1 0))
(define column-pins (vector 6 5 9 8 7 4 10 19 18 12 11))
(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))
@ -36,53 +38,53 @@
;; 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)
(sft key-5)
;;key-backtick
)
;;;; layers
(define noop 0)
(define base-layer
(vector key-q key-w key-e key-r key-t key-backslash
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 key-backtick
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 mod-ctrl
key-n key-m key-comma key-period key-slash
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-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) backtick-or-percent
(sft key-6) 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) (sft key-7)
key-page-down key-4 key-5 key-6 key-backslash
(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-left-bracket key-right-bracket (sft key-3) (sft key-left-bracket)
(sft key-right-bracket) mod-ctrl
(sft key-8) key-1 key-2 key-3 (sft key-equal)
(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-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 0
key-up key-f7 key-f8 key-f9 key-f10
(vector key-insert key-home key-up key-end key-page-up noop
noop key-up key-f7 key-f8 key-f9 key-f10
key-delete key-left key-down key-right key-page-down 0
key-down key-f4 key-f5 key-f6 key-f11
key-delete key-left key-down key-right key-page-down noop
noop key-down key-f4 key-f5 key-f6 key-f11
;; the B key enters the bootloader
0 key-vol-up 0 0 reset mod-ctrl
0 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
0 key-vol-down mod-super mod-shift key-backspace mod-alt
noop key-vol-down mod-super mod-shift key-backspace mod-ctrl
;; tapping the fn key brings us back to the base layer
key-space (set-layer 0) key-printscreen key-scroll-lock key-pause))
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))