Skip to content

Commit

Permalink
Set keycode 0x7C03 to a special keycode for restoring default
Browse files Browse the repository at this point in the history
  • Loading branch information
sago35 committed Aug 23, 2023
1 parent 3e468a9 commit 24475a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (d *Device) Tick() error {
for i, x := range d.pressed {
if x&keycodes.ModKeyMask == keycodes.ModKeyMask {
d.layer = int(x) & 0x0F
} else if x == keycodes.KeyRestoreDefaultKeymap {
// restore default keymap for QMK
machine.Flash.EraseBlocks(0, 1)
} else if x&0xF000 == 0xD000 {
switch x & 0x00FF {
case 0x01, 0x02, 0x04, 0x08, 0x10:
Expand Down Expand Up @@ -294,6 +297,9 @@ func (d *Device) KeyVia(layer, kbIndex, index int) Keycode {
case 0xFF00, 0xFF01, 0xFF02, 0xFF03, 0xFF04, 0xFF05:
// MO(x)
kc = 0x5220 | (kc & 0x000F)
case keycodes.KeyRestoreDefaultKeymap:
// restore default keymap for QMK
kc = keycodes.KeyRestoreDefaultKeymap
default:
kc = kc & 0x0FFF
}
Expand Down Expand Up @@ -336,6 +342,8 @@ func (d *Device) SetKeycodeVia(layer, kbIndex, index int, key Keycode) {
case 0x5220, 0x5221, 0x5222, 0x5223, 0x5224, 0x5225:
// MO(x)
kc = 0xFF00 | (kc & 0x000F)
case keycodes.KeyRestoreDefaultKeymap:
kc = keycodes.KeyRestoreDefaultKeymap
default:
}

Expand Down
5 changes: 5 additions & 0 deletions keycodes/keycodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ const (
KeyH = 0xF000 | 0x0B
KeyBackspace = 0xF000 | 0x2A
)

const (
// restore default keymap for QMK
KeyRestoreDefaultKeymap = 0x7C03
)

0 comments on commit 24475a3

Please sign in to comment.