File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#include <Arduino.h>
44#include "Adafruit_TinyUSB.h"
55#include "globals.h"
6+ extern volatile uint16_t voiceLastReading; // In pdmvoice.cpp
67
78#define UP_BUTTON_KEYCODE_TO_SEND HID_KEY_U
89#define A_BUTTON_KEYCODE_TO_SEND HID_KEY_A
910#define DOWN_BUTTON_KEYCODE_TO_SEND HID_KEY_D
1011#define SHAKE_KEYCODE_TO_SEND HID_KEY_SPACE
12+ // Sound reaction REQUIRES '"voice" : true' in config.eye,
13+ // even if not using sound output...we're using it to steal
14+ // access to the mic here.
15+ #define SOUND_KEYCODE_TO_SEND HID_KEY_SPACE
16+ #define SOUND_THRESHOLD 1000
1117
1218// HID report descriptor using TinyUSB's template
1319// Single Report (no ID) descriptor
@@ -61,6 +67,14 @@ void user_loop(void) {
6167 keycode[3] = SHAKE_KEYCODE_TO_SEND;
6268 }
6369
70+ if(voiceLastReading) { // usu. non-zero if voice changer enabled
71+ int level = abs((int32_t)voiceLastReading - 32768);
72+ if(level > SOUND_THRESHOLD) {
73+ Serial.println("Sound");
74+ keycode[4] = SOUND_KEYCODE_TO_SEND;
75+ }
76+ }
77+
6478 bool anypressed = false;
6579 for (int k=0; k<sizeof(keycode); k++) {
6680 if (keycode[k] != 0) {
You can’t perform that action at this time.
0 commit comments