Переглянути джерело

[Keyboard] Instant60 VIA Support (#5909)

* VIA Support for Instant60

* Backlighting updates

* Update default keymap

* Add Standard layout default VIA supported layout

* Clean up some backslashes

* Add info.json

* Update info json metadata

* add info.json for practice65

* Update keyboards/cannonkeys/instant60/info.json

Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com>

* Update keyboards/cannonkeys/practice65/info.json

Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com>

* Update keyboards/cannonkeys/instant60/keymaps/via/keymap.c

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* Update keyboards/cannonkeys/instant60/keymaps/via_standard/keymap.c

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* Remove unused enum
Andrew Kannan 6 роки тому
батько
коміт
e8372692c5

+ 9 - 3
keyboards/cannonkeys/instant60/config.h

@@ -66,12 +66,18 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // Bump this every time we change what we store
 // This will automatically reset the EEPROM with defaults
 // and avoid loading invalid data from the EEPROM
-#define EEPROM_VERSION 0x01
+#define EEPROM_VERSION 0x02
 #define EEPROM_VERSION_ADDR 34
 
-#define EEPROM_CUSTOM_BACKLIGHT 804
-
 
+#define DYNAMIC_KEYMAP_LAYER_COUNT 4
+// Dynamic macro starts after dynamic keymaps (35+(4*5*15*2)) = (35+600) = 635
+// start + layer * rows * col * 2
+#define DYNAMIC_KEYMAP_EEPROM_ADDR 35
+#define EEPROM_CUSTOM_BACKLIGHT 636
+#define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR 637
+#define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE 200
+#define DYNAMIC_KEYMAP_MACRO_COUNT 16
 
 /*
  * Feature disable options

Різницю між файлами не показано, бо вона завелика
+ 8 - 0
keyboards/cannonkeys/instant60/info.json


+ 4 - 4
keyboards/cannonkeys/instant60/keymaps/tsangan/keymap.c

@@ -31,18 +31,18 @@ enum custom_keycodes {
 
 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   [_BASE] = LAYOUT_tsangan(
-    KC_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,                 KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,   KC_BSPC, KC_DEL, \
-    KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,   KC_U,    KC_I,    KC_O,    KC_P,    KC_LBRC, KC_RBRC,  KC_BSLS, \
+    KC_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,                 KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,   KC_BSLS, KC_DEL, \
+    KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,   KC_U,    KC_I,    KC_O,    KC_P,    KC_LBRC, KC_RBRC,  KC_BSPC, \
     KC_CAPS, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,                 KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,           KC_ENT,  \
     KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,                 KC_M,    KC_COMM, KC_DOT,  KC_SLSH,                    KC_RSFT, MO(_FN1),\
     KC_LCTL, KC_LGUI, KC_LALT,                            KC_SPC,                                          KC_RALT, KC_RGUI, KC_RCTL
   ),
 
   [_FN1] = LAYOUT_tsangan(
-    KC_GESC, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_DEL, _______,\
+    KC_GRV, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_DEL, _______,\
     RGB_TOG, RGB_MOD, KC_UP,   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
     BL_BRTG, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______,          _______, \
     BL_INC,  BL_DEC,  BL_TOGG, _______, _______, _______, _______, _______, _______, _______, _______,                   _______, _______,\
-    KC_GRV,  _______, _______,                            _______,                            _______, _______, RESET
+    _______,  _______, _______,                            _______,                            _______, _______, RESET
   )
 };

+ 43 - 0
keyboards/cannonkeys/instant60/keymaps/via/keymap.c

@@ -0,0 +1,43 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include QMK_KEYBOARD_H
+
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#define _BASE 0
+#define _FN1 1
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+  [_BASE] = LAYOUT_all(
+    KC_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,                 KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,   KC_BSLS, KC_DEL,
+    KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,   KC_U,    KC_I,    KC_O,    KC_P,    KC_LBRC, KC_RBRC,  KC_BSPC,
+    KC_CAPS, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,                 KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,           KC_ENT,
+    KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,                 KC_M,    KC_COMM, KC_DOT,  KC_SLSH,                    KC_RSFT, MO(_FN1),
+    KC_LCTL, KC_LGUI, KC_LALT,                            KC_SPC,                                          KC_RALT, KC_RGUI, MO(_FN1), KC_RCTL
+  ),
+
+  [_FN1] = LAYOUT_all(
+    KC_GRV, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_DEL, _______,
+    RGB_TOG, RGB_MOD, KC_UP,   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+    BL_BRTG, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______,          _______,
+    BL_INC,  BL_DEC,  BL_TOGG, _______, _______, _______, _______, _______, _______, _______, _______,                   _______, _______,
+    _______,  _______, _______,                            _______,                            _______, _______, _______, RESET
+  )
+};

+ 5 - 0
keyboards/cannonkeys/instant60/keymaps/via/rules.mk

@@ -0,0 +1,5 @@
+# rules.mk overrides to enable VIA
+
+RAW_ENABLE = yes
+DYNAMIC_KEYMAP_ENABLE = yes
+

+ 43 - 0
keyboards/cannonkeys/instant60/keymaps/via_standard/keymap.c

@@ -0,0 +1,43 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include QMK_KEYBOARD_H
+
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+#define _BASE 0
+#define _FN1 1
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+  [_BASE] = LAYOUT_all(
+    KC_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,                 KC_7,    KC_8,    KC_9,    KC_0,    KC_MINS, KC_EQL,   KC_BSPC, KC_DEL,
+    KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,   KC_U,    KC_I,    KC_O,    KC_P,    KC_LBRC, KC_RBRC,  KC_BSLS,
+    KC_CAPS, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,                 KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,           KC_ENT,
+    KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,                 KC_M,    KC_COMM, KC_DOT,  KC_SLSH,                    KC_RSFT, MO(_FN1),
+    KC_LCTL, KC_LGUI, KC_LALT,                            KC_SPC,                                          KC_RALT, KC_RGUI, MO(_FN1), KC_RCTL
+  ),
+
+  [_FN1] = LAYOUT_all(
+    KC_GRV, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_DEL, _______,
+    RGB_TOG, RGB_MOD, KC_UP,   _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+    BL_BRTG, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______,          _______,
+    BL_INC,  BL_DEC,  BL_TOGG, _______, _______, _______, _______, _______, _______, _______, _______,                   _______, _______,
+    _______,  _______, _______,                            _______,                            _______, _______, _______, RESET
+  )
+};

+ 5 - 0
keyboards/cannonkeys/instant60/keymaps/via_standard/rules.mk

@@ -0,0 +1,5 @@
+# rules.mk overrides to enable VIA
+
+RAW_ENABLE = yes
+DYNAMIC_KEYMAP_ENABLE = yes
+

Різницю між файлами не показано, бо вона завелика
+ 8 - 0
keyboards/cannonkeys/practice65/info.json


+ 180 - 2
keyboards/cannonkeys/stm32f072/keyboard.c

@@ -5,9 +5,16 @@
 #include "util.h"
 #include "quantum.h"
 
+#include "ws2812.h"
+
+#include "raw_hid.h"
+#include "dynamic_keymap.h"
 #include "tmk_core/common/eeprom.h"
 
-#include "ws2812.h"
+// HACK
+#include "keyboards/zeal60/zeal60_api.h" // Temporary hack
+#include "keyboards/zeal60/zeal60_keycodes.h" // Temporary hack
+
 
 backlight_config_t kb_backlight_config = {
   .enable = true,
@@ -41,6 +48,17 @@ void load_custom_config(){
   kb_backlight_config.raw = eeprom_read_byte((uint8_t*)EEPROM_CUSTOM_BACKLIGHT);
 }
 
+#ifdef DYNAMIC_KEYMAP_ENABLE
+void dynamic_keymap_custom_reset(void){
+    void *p = (void*)(EEPROM_CUSTOM_BACKLIGHT);
+	void *end = (void*)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
+	while ( p != end ) {
+		eeprom_update_byte(p, 0);
+		++p;
+	}
+}
+#endif
+
 void eeprom_init_kb(void)
 {
 	// If the EEPROM has the magic, the data is good.
@@ -48,9 +66,17 @@ void eeprom_init_kb(void)
 	if (eeprom_is_valid()) {
 		load_custom_config();
 	} else	{
+#ifdef DYNAMIC_KEYMAP_ENABLE
+		// This resets the keymaps in EEPROM to what is in flash.
+		dynamic_keymap_reset();
+		// This resets the macros in EEPROM to nothing.
+		dynamic_keymap_macro_reset();
+        // Reset the custom stuff
+        dynamic_keymap_custom_reset();
+#endif
 		// Save the magic number last, in case saving was interrupted
+        save_backlight_config_to_eeprom();
 		eeprom_set_valid(true);
-    save_backlight_config_to_eeprom();
 	}
 }
 
@@ -120,6 +146,158 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
         save_backlight_config_to_eeprom();
       }
       return false;
+    default:
+        break;
   }
+
+  #ifdef DYNAMIC_KEYMAP_ENABLE
+	// Handle macros
+	if (record->event.pressed) {
+		if ( keycode >= MACRO00 && keycode <= MACRO15 )
+		{
+			uint8_t id = keycode - MACRO00;
+			dynamic_keymap_macro_send(id);
+			return false;
+		}
+	}
+    #endif //DYNAMIC_KEYMAP_ENABLE
+
   return true;
 }
+
+
+// Start Dynamic Keymap code
+#ifdef RAW_ENABLE
+
+void raw_hid_receive( uint8_t *data, uint8_t length )
+{
+	uint8_t *command_id = &(data[0]);
+	uint8_t *command_data = &(data[1]);
+	switch ( *command_id )
+	{
+		case id_get_protocol_version:
+		{
+			command_data[0] = PROTOCOL_VERSION >> 8;
+			command_data[1] = PROTOCOL_VERSION & 0xFF;
+			break;
+		}
+		case id_get_keyboard_value:
+		{
+            switch( command_data[0])
+            {
+                case id_uptime:
+                {
+                uint32_t value = timer_read32();
+                command_data[1] = (value >> 24 ) & 0xFF;
+                command_data[2] = (value >> 16 ) & 0xFF;
+                command_data[3] = (value >> 8 ) & 0xFF;
+                command_data[4] = value & 0xFF;
+                break;
+                }
+                default:
+                {
+                *command_id = id_unhandled;
+                break;
+                }
+            }
+            break;
+        }
+#ifdef DYNAMIC_KEYMAP_ENABLE
+
+		case id_dynamic_keymap_get_keycode:
+		{
+			uint16_t keycode = dynamic_keymap_get_keycode( command_data[0], command_data[1], command_data[2] );
+			command_data[3] = keycode >> 8;
+			command_data[4] = keycode & 0xFF;
+			break;
+		}
+		case id_dynamic_keymap_set_keycode:
+		{
+			dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
+			break;
+		}
+		case id_dynamic_keymap_reset:
+		{
+			dynamic_keymap_reset();
+			break;
+		}
+		case id_dynamic_keymap_macro_get_count:
+		{
+			command_data[0] = dynamic_keymap_macro_get_count();
+			break;
+		}
+		case id_dynamic_keymap_macro_get_buffer_size:
+		{
+			uint16_t size = dynamic_keymap_macro_get_buffer_size();
+			command_data[0] = size >> 8;
+			command_data[1] = size & 0xFF;
+			break;
+		}
+		case id_dynamic_keymap_macro_get_buffer:
+		{
+			uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
+			uint16_t size = command_data[2]; // size <= 28
+			dynamic_keymap_macro_get_buffer( offset, size, &command_data[3] );
+			break;
+		}
+		case id_dynamic_keymap_macro_set_buffer:
+		{
+			uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
+			uint16_t size = command_data[2]; // size <= 28
+			dynamic_keymap_macro_set_buffer( offset, size, &command_data[3] );
+			break;
+		}
+		case id_dynamic_keymap_macro_reset:
+		{
+			dynamic_keymap_macro_reset();
+			break;
+		}
+		case id_dynamic_keymap_get_layer_count:
+		{
+			command_data[0] = dynamic_keymap_get_layer_count();
+			break;
+		}
+		case id_dynamic_keymap_get_buffer:
+		{
+			uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
+			uint16_t size = command_data[2]; // size <= 28
+			dynamic_keymap_get_buffer( offset, size, &command_data[3] );
+			break;
+		}
+		case id_dynamic_keymap_set_buffer:
+		{
+			uint16_t offset = ( command_data[0] << 8 ) | command_data[1];
+			uint16_t size = command_data[2]; // size <= 28
+			dynamic_keymap_set_buffer( offset, size, &command_data[3] );
+			break;
+		}
+#endif // DYNAMIC_KEYMAP_ENABLE
+		case id_eeprom_reset:
+		{
+			eeprom_reset();
+			break;
+		}
+		case id_bootloader_jump:
+		{
+			// Need to send data back before the jump
+			// Informs host that the command is handled
+			raw_hid_send( data, length );
+			// Give host time to read it
+			wait_ms(100);
+			bootloader_jump();
+			break;
+		}
+		default:
+		{
+			// Unhandled message.
+			*command_id = id_unhandled;
+			break;
+		}
+	}
+
+	// Return same buffer with values changed
+	raw_hid_send( data, length );
+
+}
+
+#endif

+ 1 - 2
keyboards/cannonkeys/stm32f072/led.c

@@ -77,10 +77,9 @@ void backlight_init_ports(void) {
   pwmStart(&PWMD3, &pwmCFG);
   // pwmEnableChannel(&PWMD3, 0, PWM_FRACTION_TO_WIDTH(&PWMD3, 0xFFFF,cie_lightness(0xFFFF)));
   if(kb_backlight_config.enable){
+    backlight_set(kb_backlight_config.level);
     if(kb_backlight_config.breathing){
       breathing_enable();
-    } else{
-      backlight_set(kb_backlight_config.level);
     }
   } else {
     backlight_set(0);

Деякі файли не було показано, через те що забагато файлів було змінено