Skip to content

Instantly share code, notes, and snippets.

@eswai
Last active Dec 10, 2021
Embed
What would you like to do?
PRK firmware keymap for Vpico x Kyuri-Kai
# Initialize a Keyboard
kbd = Keyboard.new
# Initialize GPIO assign
kbd.init_pins(
[ 7, 8, 9, 10 ],
[ 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]
)
# +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------
kbd.add_layer :default, %i[
KC_Q KC_W KC_E KC_R KC_T KC_Y KC_U KC_I KC_O KC_P
KC_A KC_S KC_D KC_F KC_G KC_H KC_J KC_K KC_L KC_SCOLON
KC_Z KC_X KC_C KC_V KC_B KC_N KC_M KC_COMMA KC_DOT KC_SLASH
KC_LCTL KC_LGUI KC_LSFT LOWER SFTSPC SFTENT RAISE KC_LALT KC_TAB KYURI
]
# きゅうり改レイヤー
# +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------
kbd.add_layer :kyuri, %i[
KC_G KC_M KC_N KC_R KC_P KC_V YA YU YO KC_MINS
KC_Y KC_H KC_K KC_S KC_T KC_A KC_U KC_I KC_O KC_E
KC_Z KC_W KC_B KC_D KOGAKI NN XTU KC_COMMA KC_DOT KC_SLASH
KC_LCTL KC_LGUI KC_LSFT LOWER SFTSPC SFTENT RAISE KC_LALT KC_TAB KYURI
]
# +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------
kbd.add_layer :raise, %i[
KC_TILD KC_AT KC_HASH KC_DLR KC_NO KC_NO KC_HOME KC_UP KC_END KC_BSPACE
KC_CIRC KC_AMPR KC_QUES KC_PERC KC_QUOTE KC_NO KC_LEFT KC_DOWN KC_RIGHT KC_DELETE
KC_GRAVE KC_PIPE KC_EXLM KC_UNDS KC_BSLASH KC_NO KC_NO KC_NO KC_NO KC_NO
KC_LCTL KC_GUI KC_LSFT LOWER KC_SPACE KC_ENTER RAISE KC_LALT KC_NO KC_NO
]
# +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------
kbd.add_layer :lower, %i[
KC_ESCAPE KC_NO KC_COLN KC_SCOLON KC_NO KC_SLASH KC_7 KC_8 KC_9 KC_MINUS
KC_NO KC_LBRACKET KC_LCBR KC_LPRN KC_LT KC_ASTER KC_4 KC_5 KC_6 KC_PLUS
KC_NO KC_RBRACKET KC_RCBR KC_RPRN KC_GT KC_0 KC_1 KC_2 KC_3 KC_EQUAL
KC_LCTL KC_LGUI KC_LSFT LOWER KC_SPACE KC_ENTER RAISE KC_LALT KC_NO KC_NO
]
# +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------
# Tip: You can also switch current layer by single click like this:
kbd.define_mode_key :RAISE, [ nil, :raise , nil, nil ]
kbd.define_mode_key :LOWER, [ nil, :lower , nil, nil ]
kbd.define_mode_key :SFTSPC, [ :KC_SPACE, :KC_LSFT, 150, 150 ]
kbd.define_mode_key :SFTENT, [ :KC_ENTER, :KC_LSFT, 150, 150 ]
# モード切り替え
toggle_kyuri = Proc.new {
if kbd.layer == :kyuri
kbd.unlock_layer
kbd.send_key(:KC_LANG2) # Mac
# kbd.send_key(:KC_HENK) # Win
else
kbd.lock_layer :kyuri
kbd.send_key(:KC_LANG1) # Mac
# kbd.send_key(:KC_MHEN) # Win
end
}
# 最後に入力したキー
last_char = nil
# 小書きキーの処理
kogaki = Proc.new {
case last_char
when :KC_H
kbd.send_key :KC_BSPACE
kbd.macro 'f', nil
last_char = nil
else
kbd.macro 'x', nil
end
}
kbd.define_mode_key :KYURI, [ toggle_kyuri, nil, 300, nil ]
kbd.define_mode_key :YA, [ Proc.new {kbd.macro 'ya', nil}, nil , 300, nil ]
kbd.define_mode_key :YU, [ Proc.new {kbd.macro 'yu', nil}, nil , 300, nil ]
kbd.define_mode_key :YO, [ Proc.new {kbd.macro 'yo', nil}, nil , 300, nil ]
kbd.define_mode_key :NN, [ Proc.new {kbd.macro 'nn' , nil}, nil , 300, nil ]
kbd.define_mode_key :XTU, [ Proc.new {kbd.macro 'xtu', nil}, nil , 300, nil ]
kbd.define_mode_key :KOGAKI, [ kogaki, nil, 300, nil ]
# 最後のキーを保存
kbd.before_report do
if kbd.layer == :kyuri
(%i[KC_A KC_B KC_C KC_D KC_E KC_F KC_G KC_H KC_I KC_J KC_K KC_L KC_M KC_N KC_O KC_P KC_Q KC_R KC_S KC_T KC_U KC_V KC_W KC_X KC_Y KC_Z]).each do |k|
if kbd.keys_include?(k)
last_char = k
end
end
else
last_char = nil
end
end
kbd.start!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment