Skip to content

Instantly share code, notes, and snippets.

@takkanm
Created Sep 14, 2021
Embed
What would you like to do?
Zinc rev.1
while !$mutex
relinquish
end
kbd = Keyboard.new
kbd.split = true
kbd.init_pins(
[ 27, 26, 22, 20 ],
[ 29, 4, 5, 6, 7, 8 ]
)
class Array
def reverse
ary = self
reverse_ary = []
ary.each do |elm|
reverse_ary.unshift elm
end
reverse_ary
end
def flatten
flat_ary = []
ary = self
ary.each do |elm|
if elm.class == Array
elm.each do |e|
flat_ary.push e
end
else
flat_ary.push e
end
end
flat_ary
end
end
kbd.add_layer :default, [
%i( KC_TAB KC_Q KC_W KC_E KC_R KC_T ), %i( KC_Y KC_U KC_I KC_O KC_P KC_BSPACE ).reverse,
%i( CTL_ESC KC_A KC_S KC_D KC_F KC_G ), %i( KC_H KC_J KC_K KC_L KC_SCOLON KC_QUOTE ).reverse,
%i( KC_LSFT KC_Z KC_X KC_C KC_V KC_B ), %i( KC_N KC_M KC_COMMA KC_DOT KC_SLASH KC_RSFT ).reverse,
%i( KC_ESC ADJUST KC_LALT CMD_LANG2 RAISE KC_SPACE ), %i( KC_ENTER LOWER ALT_LANG1 KC_DOWN KC_UP KC_RGHT ).reverse,
].flatten
kbd.add_layer :lower, [
%i( KC_TAB KC_EXLM KC_AT KC_HASH KC_DLR KC_PERC ), %i( KC_CIRC KC_AMPR KC_ASTER KC_LPRN KC_RPRN KC_BSPACE ).reverse,
%i( CTL_ESC KC_LABK KC_LCBR KC_LBRACKET KC_LPRN KC_QUOTE ), %i( KC_MINUS KC_EQUAL KC_LCBR KC_RCBR KC_PIPE KC_GRAVE ).reverse,
%i( KC_LSFT KC_RABK KC_RCBR KC_RBRACKET KC_RPRN KC_DQUO ), %i( KC_UNDS KC_PLUS KC_LBRACKET KC_RBRACKET KC_BSLS KC_TILD ).reverse,
%i( _______ _______ _______ _______ _______ _______ ), %i( _______ _______ KC_MNXT KC_VOLD KC_VOLU KC_MPLY).reverse,
].flatten
kbd.add_layer :raise, [
%i( KC_GRAVE KC_1 KC_2 KC_3 KC_4 KC_5 ), %i( KC_6 KC_7 KC_8 KC_9 KC_0 KC_DEL ).reverse,
%i( CTL_ESC KC_F2 KC_F10 KC_F12 KC_LPRN KC_QUOTE ), %i( KC_LEFT KC_DOWN KC_UP KC_RIGHT KC_RIGHT XXXXXXX ).reverse,
%i( _______ KC_F7 KC_F8 KC_F9 KC_F10 KC_F11 ), %i( KC_F12 _______ _______ _______ _______ _______ ).reverse,
%i( _______ _______ _______ _______ _______ _______ ), %i( _______ _______ KC_MNXT KC_VOLD KC_VOLU KC_MPLY ).reverse,
].flatten
kbd.define_mode_key :LOWER, [ :KC_NO, :lower, 120, 150 ]
kbd.define_mode_key :RAISE, [ :KC_NO, :raise, 120, 150 ]
kbd.define_mode_key :ALT_LANG1, [ :KC_LANG1, :KC_LALT, 120, 400 ]
kbd.define_mode_key :CMD_LANG2, [ :KC_LANG2, :KC_RGUI, 120, 400 ]
kbd.define_mode_key :CTL_ESC, [ :KC_ESCAPE, :KC_LCTL, 120, 150 ]
kbd.start!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment