Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Add media keys support over bluetooth and update to 2.04 #41

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions keyboards/annepro2/annepro2_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "hal.h"
#include "host.h"
#include "host_driver.h"
#include "report.h"

/* -------------------- Static Function Prototypes -------------------------- */
static uint8_t ap2_ble_leds(void);
Expand All @@ -39,19 +40,27 @@ static host_driver_t ap2_ble_driver = {
};

static uint8_t bleMcuWakeup[11] = {
0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02
0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02
};

static uint8_t bleMcuStartBroadcast[11] = {
0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3]
0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3]
};

static uint8_t bleMcuConnect[11] = {
0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3]
0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3]
};

static uint8_t bleMcuSendReport[10] = {
0x7b, 0x10, 0x53, 0x10, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04,
0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04,
};

static uint8_t bleMcuSendConsumerReport[10] = {
0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08,
};

static uint8_t bleMcuUnpair[10] = {
0x7b, 0x10, 0x53, 0x10, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05,
0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05,
};

static uint8_t bleMcuBootload[11] = {
Expand Down Expand Up @@ -138,8 +147,25 @@ static void ap2_ble_mouse(report_mouse_t *report){
static void ap2_ble_system(uint16_t data) {
}

static void ap2_ble_consumer(uint16_t data) {


static inline uint16_t CONSUMER2AP2(uint16_t usage) {
switch(usage) {
case AUDIO_VOL_DOWN: return 0x04;
case AUDIO_VOL_UP: return 0x02;
case AUDIO_MUTE: return 0x01;
case TRANSPORT_PLAY_PAUSE: return 0x08;
case TRANSPORT_NEXT_TRACK: return 0x10;
case TRANSPORT_PREV_TRACK: return 0x20;
default: return 0x00;
}
}

static void ap2_ble_consumer(uint16_t data) {
sdPut(&SD1, 0x0);
sdWrite(&SD1, bleMcuSendConsumerReport, 10);
sdPut(&SD1, CONSUMER2AP2(data));
sdWrite(&SD1, 0x0, 3);
}

/*!
Expand Down