diff --git a/Controllers/QMKController/QMKKeychronController/QMKKeychronController.cpp b/Controllers/QMKController/QMKKeychronController/QMKKeychronController.cpp index 0ec8318d1..928aedcf3 100644 --- a/Controllers/QMKController/QMKKeychronController/QMKKeychronController.cpp +++ b/Controllers/QMKController/QMKKeychronController/QMKKeychronController.cpp @@ -88,6 +88,11 @@ QMKKeychronController::QMKKeychronController(hid_device* dev_handle, const char \*-----------------------------------------------------*/ CmdGetKeychronProtocolVersion(&kc_protocol_version); + /*-----------------------------------------------------*\ + | Get Keychron firmware version | + \*-----------------------------------------------------*/ + kc_firmware_version = CmdGetKeychronFirmwareVersion(); + /*-----------------------------------------------------*\ | Get supported Keychron features | \*-----------------------------------------------------*/ @@ -172,7 +177,8 @@ std::string QMKKeychronController::GetVersion() \*-----------------------------------------------------*/ return("VIA: " + std::to_string(via_protocol_version) + "\r\n" + "Keychron: " + std::to_string(kc_protocol_version) + "\r\n" + - "Keychron RGB: " + std::to_string(kc_rgb_protocol_version)); + "Keychron RGB: " + std::to_string(kc_rgb_protocol_version) + "\r\n" + + "Keychron FW: " + kc_firmware_version); } bool QMKKeychronController::GetSupported() @@ -256,6 +262,21 @@ unsigned short QMKKeychronController::CmdGetKeycode return(keycode); } + +std::string QMKKeychronController::CmdGetKeychronFirmwareVersion() +{ + char response[30]; + + ViaSendCommand(KC_GET_FIRMWARE_VERSION, NULL, 0, (unsigned char*)response, sizeof(response)); + + /*-----------------------------------------------------*\ + | Ensure response null termination | + \*-----------------------------------------------------*/ + response[29] = 0; + + return(std::string(response)); +} + void QMKKeychronController::CmdGetKeychronProtocolVersion ( unsigned char* kc_protocol_version diff --git a/Controllers/QMKController/QMKKeychronController/QMKKeychronController.h b/Controllers/QMKController/QMKKeychronController/QMKKeychronController.h index e8f7c8795..8260efa21 100644 --- a/Controllers/QMKController/QMKKeychronController/QMKKeychronController.h +++ b/Controllers/QMKController/QMKKeychronController/QMKKeychronController.h @@ -392,6 +392,7 @@ public: private: hid_device* dev; + std::string kc_firmware_version; unsigned char kc_protocol_version; unsigned short kc_rgb_protocol_version; std::vector keycodes; @@ -405,6 +406,7 @@ private: unsigned short via_protocol_version; unsigned short CmdGetKeycode(unsigned char layer, unsigned char row, unsigned char col); + std::string CmdGetKeychronFirmwareVersion(); void CmdGetKeychronProtocolVersion(unsigned char* kc_protocol_version); void CmdGetKeychronRGBProtocolVersion(unsigned short* kc_rgb_protocol_version); std::vector CmdGetLEDIndexByRow(unsigned char row);