rev1.c (1795B)
1 /* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <https://github.com/Legonut> wrote this file. As long as you retain this 5 * notice you can do whatever you want with this stuff. If we meet some day, and 6 * you think this stuff is worth it, you can buy me a beer in return. David Rauseo 7 * ---------------------------------------------------------------------------- 8 */ 9 10 #include "rev1.h" 11 #include "touch_encoder.h" 12 #include "common_oled.h" 13 #include "transactions.h" 14 15 #define NUMBER_OF_TOUCH_ENCODERS 2 16 #define TOUCH_ENCODER_OPTIONS TOUCH_SEGMENTS + 2 17 18 typedef struct PACKED { 19 uint8_t r; 20 uint8_t c; 21 } encodermap_t; 22 23 const encodermap_t touch_encoder_map[NUMBER_OF_TOUCH_ENCODERS][TOUCH_ENCODER_OPTIONS] = 24 { 25 { { 6, 0 }, { 6, 1 }, { 6, 2 }, { 6, 3 }, { 6, 4 } }, // Touch Encoder 1 matrix entries 26 { { 13, 0 }, { 13, 1 }, { 13, 2 }, { 13, 3 }, { 13, 4 } } // Touch Encoder 2 matrix entries 27 }; 28 29 static void process_encoder_matrix(encodermap_t pos) { 30 action_exec(MAKE_KEYEVENT(pos.r, pos.c, true)); 31 #if TAP_CODE_DELAY > 0 32 wait_ms(TAP_CODE_DELAY); 33 #endif 34 action_exec(MAKE_KEYEVENT(pos.r, pos.c, false)); 35 } 36 37 bool touch_encoder_tapped_kb(uint8_t index, uint8_t section) { 38 if (!touch_encoder_tapped_user(index, section)) 39 return false; 40 41 process_encoder_matrix(touch_encoder_map[index][section + 2]); 42 return false; 43 } 44 45 void keyboard_post_init_kb(void) { 46 touch_encoder_init(); 47 transaction_register_rpc(TOUCH_ENCODER_SYNC, touch_encoder_slave_sync); 48 transaction_register_rpc(RGB_MENU_SYNC, rgb_menu_slave_sync); 49 keyboard_post_init_user(); 50 } 51 52 void housekeeping_task_kb(void) { 53 touch_encoder_update(TOUCH_ENCODER_SYNC); 54 rgb_menu_update(RGB_MENU_SYNC); 55 }