git clone https://github.com/hasumikin/mrubyc-template-posix.git 02
cd 02
- create
mrblib/loops/master.rb
- create
mrblib/models/greeter.rb
- edit
main.c
(you can replace whole of the file with code below)
# This example assumes to use "meishi2" which has 2x2 matrix circuit. | |
# | |
# If you use a larger one, let's say 40% keyboard, the code will look like: | |
# (Note that GPIO pin numbers in this example are written at random. They are fishy) | |
# ``` | |
# kbd = Keyboard.new( | |
# [ 2, 3, 4, 5 ], # row0, row1,... respectively | |
# [ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ] # col0, col1,... respectively | |
# ) | |
# kbd.add_layer :default, [ |
kbd = Keyboard.new | |
kbd.init_pins( | |
[ 11, 12, 13, 14, 15 ], # row0, row1,... respectively | |
[ 9, 8, 7, 6 ] # col0, col1,... respectively | |
) | |
kbd.add_layer :default, %i[ | |
RGB_TOG KC_ESC KC_NO KC_BSPACE | |
RGB_MOD KC_7 KC_8 KC_9 |
kbd = Keyboard.new | |
c1 = 29 | |
c2 = 28 | |
c3 = 27 | |
c4 = 26 | |
c5 = 22 | |
c6 = 20 | |
c7 = 23 | |
c8 = 21 |
class Keyboard | |
def grave_escape | |
index = @keycodes.index(KEYCODE.index(:KC_ESCAPE).chr) | |
if index | |
if (@modifier & 0b00010001) > 0 # CTRL | |
# Do nothing so that "SHIFT+CTRL+ESCAPE" opens Task Manager | |
elsif (@modifier & 0b00100010) > 0 # SHIFT | |
@keycodes[index] = KEYCODE.index(:KC_GRAVE).chr | |
elsif (@modifier & 0b10001000) > 0 # GUI | |
@keycodes[index] = KEYCODE.index(:KC_GRAVE).chr |