added half click feature (on BT right click)

This commit is contained in:
demik
2024-06-18 11:54:42 +02:00
parent 78585fda10
commit 53b675040e
3 changed files with 45 additions and 18 deletions

View File

@@ -1,3 +1,7 @@
## v1.4.7
- new feature: half click on right BT click (similar to some ADB devices)
- workarounds for v1.4.6 green led regression
## v1.4.6
- added support for ADB composite devices (Kensignton and some Joysticks)
- fixed ADB start and stop bit times (65 µs vs 70 µs, error in AN591)

View File

@@ -246,7 +246,10 @@ void adb_task_host(void *pvParameters) {
int8_t move = 0;
uint8_t state = ADB_S_PROBE;
/* wait a little for the LED tasks to start on the other core */
/*
* wait a little for the LED tasks to start on the other core
* starting IDF 5.2.2, we need this. Looks like the init is now too fast on app core
*/
vTaskDelay(200 / portTICK_PERIOD_MS);
/* put green led to steady if BT is disabled. Otherwise BT init will do it */

View File

@@ -285,31 +285,48 @@ void blue_h_close(esp_hidh_event_data_t *p) {
}
static void blue_handle_button(uint8_t buttons) {
static bool locked = false;
static bool releasable = true;
static bool status = BLUE_BUTTON_N; // Keep state
buttons = buttons & (BLUE_BUTTON_1 | BLUE_BUTTON_2 | BLUE_BUTTON_3);
if (status && buttons)
return ;
if (status == BLUE_BUTTON_N && buttons == BLUE_BUTTON_N)
if (status == BLUE_BUTTON_N && buttons == BLUE_BUTTON_N && !locked)
return ;
if (buttons == BLUE_BUTTON_2 && locked && !releasable)
return ;
if (status == BLUE_BUTTON_N && buttons == BLUE_BUTTON_N && locked) {
releasable = true;
return ;
}
/* release button */
if (status && buttons == BLUE_BUTTON_N) {
if (status && buttons == BLUE_BUTTON_N && !locked) {
xTaskNotify(t_click, 0, eSetValueWithOverwrite);
status = 0;
ESP_LOGD(TAG, "button released");
return ;
}
/* press button */
/* stick button on right click */
if (status == BLUE_BUTTON_N && buttons == BLUE_BUTTON_2 && !locked) {
xTaskNotify(t_click, 1, eSetValueWithOverwrite);
locked = true;
releasable = false;
ESP_LOGD(TAG, "button locked");
return ;
}
/* press button (simple click) */
if (status == BLUE_BUTTON_N && buttons) {
xTaskNotify(t_click, 1, eSetValueWithOverwrite);
locked = false;
status = 1;
ESP_LOGD(TAG, "button pressed");
return ;
}
}
static void blue_h_init(void) {
@@ -349,8 +366,11 @@ void blue_init(void)
/*
* at this point, everything but bluetooth is started.
* put green steady, start blinking blue and keep scanning until a device is found
*
* starting IDF 5.2.2, sometimes the first xTaskNotify() call may be lost. why ?
*/
xTaskNotify(t_green, LED_ON, eSetValueWithOverwrite);
xTaskNotify(t_green, LED_ON, eSetValueWithOverwrite);
xTaskNotify(t_blue, LED_FAST, eSetValueWithOverwrite);
@@ -384,7 +404,7 @@ void blue_h_input(esp_hidh_dev_t *dev, uint8_t *data, uint16_t length) {
/*
* A friend of mine did this for a beer, it helps a little with high DPI mouses
* This is a precalculated table that looks like a squadhed arctan()
* This is a precalculated table that looks like a squared arctan()
*/
const unsigned char hid2quad[] = {