キーボードをカスタムしてプログラミング環境を良くした話 / Improved programming environment with customizing keybords

キーボードをカスタムしてプログラミング環境を良くした話 / Improved programming environment with customizing keybords

2018/09/08 builderscon tokyo 2018 の LT スライドです。
Elixir の `|>` 演算子を1キー押すだけで入力できるようにする話です。

509e5167fdb3871d6b6e045e34a3e019?s=128

Takayuki Matsubara

September 08, 2018
Tweet

Transcript

  1. ΩʔϘʔυΛΧελϜ͠ ͯϓϩάϥϛϯά؀ڥΛ ྑͨ͘͠࿩ builderscon tokyo 2018 @ma2ge

  2. PowerAssertEx ⭐ 160+ github.com/ma2gedev/power_assert_ex

  3. ! Elixir

  4. |> ύΠϓԋࢉࢠ https://elixir-lang.org/getting-started/enumerables-and-streams.html#the-pipe-operator

  5. ύΠϓԋࢉࢠͷ࢖ΘΕํ # without pipe Enum.sum(Enum.map(1..100_000, &(&1 * 3))) # with

    pipe 1..100_000 |> Enum.map(&(&1 * 3)) |> Enum.sum
  6. ͔͍͍ͬ͜ɻɻɻ͕ͩ |> ͸࠷ߴʹଧͪʹ͍͘

  7. None
  8. 3

  9. 3 to 1

  10. !

  11. QMK https://github.com/qmk/qmk_firmware

  12. ࣄલʹඞཁͳ෺ Firmware Λॻ͖ࠐΊΔΩʔϘʔυ

  13. ۩ମతʹ͸ ErgoDox EZ, Infinity ErgoDox, Planck, Helix ͳͲͷࣗ࡞Ω ʔϘʔυք۾ͰΑ͘ݟΔΩʔϘʔυ https://github.com/qmk/qmk_firmware/blob/master/keyboards/readme.md

  14. ! ͜ΕΒΛপ1ʹམͪͳ͍Α͏ʹؾ Λ͚ͭͭͭखʹೖΕ·͢(ࣗݾ੹೚) 1 ΩʔΩϟοϓ͔Β࢝·ΓɺΩʔεΠον΍έʔεΛม͑ͨ͘ͳͬͨΓɺଞͷΩʔϘʔυ΋ཉ͘͠ͳͬͨΓɻ͔ͳ ΓͷপͰ͢ɻ

  15. QMK ͰಠࣗΩʔϚοϓ࡞Δ४උ # fork ͨ͠΋ͷΛ clone ͢Δͷ͕ΦεεϝͰ͢ $ git clone

    git@github.com:qmk/qmk_firmware.git $ cd qmk_firmware # ରԠ͢ΔΩʔϘʔυͷ keymap.c Λมߋ͢Δײ͡ɻ # ҎԼ͸ Infinity ErgoDox ͷྫ $ cp -r keyboards/ergodox_infinity/keymaps/{default,your_own} $ vi keyboards/ergodox_infinity/keymaps/your_own/keymap.c
  16. QMK Λ࢖͏͜ͱͰΩʔϚοϓม͑ΒΕΔ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Keymap

    0: Basic layer * * ,--------------------------------------------------. ,--------------------------------------------------. * | Esc | 1 | 2 | 3 | 4 | 5 | Del | | |> | 6 | 7 | 8 | 9 | 0 | - | * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| * | Tab | Q | W | E | R | T | ` | | ' | Y | U | I | O | P | BkSp | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| * | LCtrl | A | S | D | F | G |------| |------| H | J | K | L |; / L1| Enter | * |--------+------+------+------+------+------| Hyper| | B |------+------+------+------+------+--------| * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' * |Grv/L1| Meh |AltShf| LALT | LGui| | \ | = | [ | ] | ~L1 | * `----------------------------------' `----------------------------------' * ,-------------. ,-------------. * | Up | Down | | Left | Right | * ,------|------|------| |------+--------+------. * | | | Home | | PgUp | | | * | Space| LANG1|------| |------| LANG2 |Enter | * | | | End | | PgDn | | /L2 | * `--------------------' `----------------------' */ https://github.com/ma2gedev/qmk_firmware/blob/ma2gedev/keyboards/ergodox/keymaps/ma2gedev/keymap.c
  17. ͞ΒʹϚΫϩͷػೳ͕͋Γ·͢ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {

    switch(id) { case 0: if (record->event.pressed) { SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); } break; /* লུ */ } return MACRO_NONE; };
  18. keycode ͷ୅ΘΓʹϚΫϩΛݺͼग़͢ /* ௨ৗΩʔίʔυΛॻ͘ͱ͜Ζ΁ */ KEYMAP(..., KC_1, ...) /* action_get_macro

    Λݺͼग़ͨ͢Ίͷ M ϚΫϩΛઃఆ͢Δ */ KEYMAP(..., M(0), ...)
  19. ϚΫϩΛ௥Ճ͢Δ͜ͱͰύΠϓԋࢉࢠΛ ࣮ݱͯ͠Έ·͠ΐ͏ /* @action_get_macro ʹҎԼΛ௥Ճ */ case 2: if (record->event.pressed)

    { // For Elixir pipe operator SEND_STRING ("|>"); } break; /* keymaps ͷ഑ྻͰΧελϚΠζ͍ͨ͠ΩʔͷϚοϐϯάΛҎԼʹมߋ */ KEYMAP(..., M(2), ...)
  20. ϑΝʔϜ΢ΣΞͷॻ͖ࠐΈํ๏ # ҎԼͷΩʔϘʔυ͝ͱͷσΟϨΫτϦʹ readme.md ͕͍͍ͩͨೖ͍ͬͯΔͷͰͦΕݟΔ https://github.com/qmk/qmk_firmware/tree/master/keyboards/ # Infinity ErgoDox ͷ৔߹

    https://github.com/qmk/qmk_firmware/blob/master/keyboards/ergodox_infinity/readme.md
  21. None
  22. !!!

  23. 3 to 1

  24. twitter: @ma2ge M3, Inc. / ΤϜεϦʔגࣜձࣾ https://www.m3tech.blog