~technomancy/menelaus

9b59db675487a16925962d04b2dfb36961e66ede — Phil Hagelberg a month ago 71e9817 master
Add keyboardio-dvorak.scm layout.
2 files changed, 80 insertions(+), 1 deletions(-)

M Makefile
A keyboardio-dvorak.scm
M Makefile => Makefile +2 -1
@@ 1,6 1,7 @@
MCU=atmega32u4
F_CPU=16000000

MODEL?=LEO
LAYOUT?=qwerty

USB=/dev/ttyACM0


@@ 25,7 26,7 @@ $(LAYOUT).hex: $(LAYOUT).elf
	avr-objcopy --output-target=ihex $(LAYOUT).elf $(LAYOUT).hex

$(LAYOUT).s: $(LAYOUT).scm menelaus.scm keycodes.scm
	microscheme -m LEO $(LAYOUT).scm
	microscheme -m $(MODEL) $(LAYOUT).scm

%.elf: %.s usb_keyboard.s
	avr-gcc -mmcu=$(MCU) -o $(LAYOUT).elf $(LAYOUT).s usb_keyboard.s

A keyboardio-dvorak.scm => keyboardio-dvorak.scm +78 -0
@@ 0,0 1,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")