2023-03-07 21:58:28 +01:00
|
|
|
#include "STWButtonController.hpp"
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
#include "tx_api.h"
|
|
|
|
#include "ui.h"
|
|
|
|
|
|
|
|
void STWButtonController::init() {}
|
|
|
|
|
|
|
|
bool STWButtonController::sample(uint8_t &key) {
|
|
|
|
ButtonMessage msg;
|
|
|
|
if (tx_queue_receive(&gui_button_queue, &msg, TX_NO_WAIT) == TX_SUCCESS) {
|
|
|
|
switch (msg.kind) {
|
2023-04-11 21:53:36 +02:00
|
|
|
case UMK_BTN_PRESSED:
|
2023-03-07 21:58:28 +01:00
|
|
|
key = KEY_BTN1 + msg.number;
|
|
|
|
break;
|
|
|
|
case UMK_ENC_CW: {
|
|
|
|
if (msg.number == 0) {
|
|
|
|
key = KEY_ENC1_CW;
|
|
|
|
} else {
|
|
|
|
key = KEY_ENC2_CW;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UMK_ENC_CCW:
|
|
|
|
if (msg.number == 0) {
|
|
|
|
key = KEY_ENC1_CCW;
|
|
|
|
} else {
|
|
|
|
key = KEY_ENC2_CCW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|