~technomancy/menelaus

menelaus/keyboardio-dvorak.scm -rw-r--r-- 2.8 KiB
9b59db67Phil Hagelberg Add keyboardio-dvorak.scm layout. 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;;; This is the soft dvorak Kebyoardio layout.

;; It is written with the assumption that the host OS is set to dvorak mode, so
;; it sends keycodes with the assumption that the OS will apply the dvorak
;; mapping; for instance it sends [ as -, which the OS then turns back into [.

;; Currently requires this branch of microscheme:
;; https://github.com/ryansuchocki/microscheme/pull/36

(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 Keyboardio Atreus.
(define row-pins (vector 0 1 2 3))
(define column-pins (vector 4 5 6 7 8 9 10 11 12 13 14 15))

;; We have to declare this up front and set it later because of circularity.
(define layers #f)
(define current-layer #f)
(define momentary-layer #f)

(define (fn on?) (set! momentary-layer (and on? (vector-ref layers 1))))

(define (set-layer n)
  (lambda (_) (set! current-layer (vector-ref layers n))))

;;;; Layers

(define base-layer
 (vector key-q key-w key-e key-r key-t 0
         0 key-y key-u key-i key-o key-p

         key-a key-s key-d key-f key-g 0
         0 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-quote key-left-bracket key-enter))

(define fn-layer
  (vector (sft key-1) (sft key-2) key-up (sft key-4) (sft key-5) 0
          0 key-page-up key-7 key-8 key-9 key-backspace

          (sft key-9) key-left key-down key-right (sft key-0) 0
          0 key-page-down key-4 key-5 key-6 0

          key-dash key-equal (sft key-3) (sft key-dash) (sft key-equal) (sft key-6)
          (sft key-7) (sft key-8) key-1 key-2 key-3 (sft key-right-bracket)

          ;; 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-e key-0 key-right-bracket))

(define l2-layer
  (vector key-insert key-home key-up key-end key-page-up 0
          0 key-up key-f7 key-f8 key-f9 key-f10

          key-delete key-left key-down key-right key-page-down 0
          0 key-down key-f4 key-f5 key-f6 key-f11

          ;; the B key enters the bootloader
          0 key-vol-up 0 0 reset 0
          0 0 key-f1 key-f2 key-f3 key-f12

          (set-layer 0) key-vol-down mod-super mod-shift key-backspace mod-ctrl
          ;; tapping the fn key brings us back to the base layer
          0 0 (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))

(include "menelaus.scm")