Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set keycode 0x7C03 to a special keycode for restoring default #8

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)