From c1a838ab5f5da00888ac8df228b333b252ab7b52 Mon Sep 17 00:00:00 2001 From: f1andrew Date: Mon, 17 Oct 2022 11:00:35 +0300 Subject: [PATCH] controlling volume with consumer keys to support ios --- arduino/arduino_nRF52840/arduino_nRF52840.ino | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arduino/arduino_nRF52840/arduino_nRF52840.ino b/arduino/arduino_nRF52840/arduino_nRF52840.ino index eaf6535..641ed84 100644 --- a/arduino/arduino_nRF52840/arduino_nRF52840.ino +++ b/arduino/arduino_nRF52840/arduino_nRF52840.ino @@ -593,7 +593,27 @@ void sendBLEKeyboardCode(char *myLine) keys[i] = strtoul(p, NULL, 16); p = strtok(NULL, "-"); } - ret = blehid.keyboardReport(target_ble_conn, keys[0], &keys[2]); + switch(keys[2]) { + // MUTE + case 0x7F: + ret = blehid.consumerKeyPress(target_ble_conn, 0xE2); + blehid.consumerKeyRelease(target_ble_conn); + break; + // VOLUME UP + case 0x80: + ret = blehid.consumerKeyPress(target_ble_conn, 0xE9); + blehid.consumerKeyRelease(target_ble_conn); + break; + // VOLUME DOWN + case 0x81: + ret = blehid.consumerKeyPress(target_ble_conn, 0xEA); + blehid.consumerKeyRelease(target_ble_conn); + break; + // Regular keycodes + default: + ret = blehid.keyboardReport(target_ble_conn, keys[0], &keys[2]); + } + if ((int)ret != 1) { snprintf(buff, sizeof(buff), "ERROR %d\n", (int)ret);