keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keybrd_3g_shift_pairings.ino 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* keybrd_3g_shift_pairings.ino
  2. This sketch:
  3. is a simple 2-layer keyboard with AutoShift
  4. runs on the first two rows and columns of a breadboard keyboard
  5. | Layout | **0** | **1** |
  6. |:------:|-------|-------|
  7. | **0** | 8 ( | = - |
  8. | **1** | shift | 5 % |
  9. The layout has one shift key in the lower right. The top-row keys are custom pairings.
  10. Characters '8' and '=' are on the normal layer. Characters '(' and '-' are on the shift layer.
  11. Holding the shift key down makes it the active layer.
  12. Releasing the shift key restores the normal layer.
  13. */
  14. // ################## GLOBAL ###################
  15. // ================= INCLUDES ==================
  16. //Keys
  17. #include <Code_Sc.h>
  18. #include <Code_ScNS.h>
  19. #include <Code_Shift.h>
  20. #include <LayerState.h>
  21. #include <Code_LayerHoldShift.h>
  22. #include <Key_LayeredKeys.h>
  23. //Matrix
  24. #include <Row.h>
  25. #include <Scanner_uC.h>
  26. #include <ScanDelay.h>
  27. // ============ SPEED CONFIGURATION ============
  28. ScanDelay scanDelay(9000);
  29. // ================== SCANNER ==================
  30. uint8_t readPins[] = {14, 15};
  31. uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins);
  32. Scanner_uC scanner(LOW, readPins, readPinCount);
  33. // =================== CODES ===================
  34. // ---------------- LAYER CODE -----------------
  35. enum layerIds { NORMAL, SHIFT };
  36. LayerState layerState;
  37. Code_Shift s_shift(MODIFIERKEY_LEFT_SHIFT);
  38. Code_LayerHoldShift l_shift(SHIFT, layerState, s_shift);
  39. /* ----------------- SCANCODES -----------------
  40. The "Sc" in Code_Sc means "scancode".
  41. When a Code_Sc is pressed, it sends its scancode.
  42. */
  43. Code_Sc s_a(KEY_A);
  44. Code_Sc s_5(KEY_5);
  45. Code_Sc s_8(KEY_8);
  46. Code_Sc s_equal(KEY_EQUAL);
  47. Code_Sc s_leftParen(KEY_9);
  48. /* The "ScNS" in Code_ScNS means "scancode not shifted".
  49. When Code_ScNS is pressed, it calls Code_AutoShift before sending its scancode.
  50. */
  51. Code_ScNS ns_minus(KEY_MINUS);
  52. /*
  53. Code_Shift pointers are placed in an array because most keyboards have a left and right shift.
  54. This sketch only has one shift code.
  55. */
  56. Code_Shift* const ptrsS[] = { &s_shift };
  57. Code_Shift* const* const Code_AutoShift::ptrsShifts = ptrsS;
  58. const uint8_t Code_AutoShift::shiftCount = sizeof(ptrsS)/sizeof(*ptrsS);
  59. // =============== LAYERED KEYS ================
  60. Key* const ptrsKeys_00[] = { &s_8, &s_leftParen }; //custom key pairing
  61. Key_LayeredKeys k_00(ptrsKeys_00);
  62. Key* const ptrsKeys_01[] = { &s_equal, &ns_minus }; //custom key pairing
  63. Key_LayeredKeys k_01(ptrsKeys_01);
  64. LayerStateInterface& Key_LayeredKeys::refLayerState = layerState;
  65. // =================== ROWS ====================
  66. Key* const ptrsKeys_0[] = { &k_00, &k_01 };
  67. uint8_t keyCount_0 = sizeof(ptrsKeys_0)/sizeof(*ptrsKeys_0);
  68. Row row_0(scanner, 0, ptrsKeys_0, keyCount_0);
  69. Key* const ptrsKeys_1[] = { &l_shift, &s_5 };
  70. uint8_t keyCount_1 = sizeof(ptrsKeys_1)/sizeof(*ptrsKeys_1);
  71. Row row_1(scanner, 1, ptrsKeys_1, keyCount_1);
  72. // ################### MAIN ####################
  73. void setup()
  74. {
  75. }
  76. void loop()
  77. {
  78. row_0.process();
  79. row_1.process();
  80. scanDelay.delay();
  81. }