22// SPDX-License-Identifier: GPL-2.0-or-later
33
44#include "lotus.h"
5+ #include "raw_hid.h"
56
67#define BOOT_DONE_GPIO GP5
78
@@ -41,4 +42,41 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
4142 default :
4243 return true; // Process all other keycodes normally
4344 }
44- }
45+ }
46+
47+ void handle_hid (uint8_t * data , uint8_t length ) {
48+ uint8_t command_id = data [0 ];
49+ uint8_t * command_data = & (data [1 ]);
50+
51+ uprintf ("raw_hid_receive(command: %u, length: %d)\n" , command_id , length );
52+
53+ switch (command_id ) {
54+ case 0x01 :
55+ print ("protocol_ver\n" );
56+ command_data [0 ] = 0x0B >> 8 ;
57+ command_data [1 ] = 0x0B & 0xFF ;
58+ #ifndef VIA_ENABLE
59+ raw_hid_send (data , length );
60+ #endif
61+ break ;
62+ case 0x0B :
63+ print ("bootloader_jump\n" );
64+ bootloader_jump ();
65+ break ;
66+ default :
67+ print ("Unrecognized command ID\n" );
68+ break ;
69+ }
70+ }
71+
72+ // Add hooks to handle raw HID commands.
73+ // Need add both functions to make it work when
74+ // either RAW_ENABLE or VIA_ENABLE are enabled.
75+ void via_command_kb (uint8_t * data , uint8_t length ) {
76+ handle_hid (data , length );
77+ }
78+ #ifndef VIA_ENABLE
79+ void raw_hid_receive (uint8_t * data , uint8_t length ) {
80+ handle_hid (data , length );
81+ }
82+ #endif
0 commit comments