testing media key (VOL +)

This commit is contained in:
2025-06-15 10:29:15 +02:00
parent 83e189d187
commit 1a87cd09f1
3 changed files with 48 additions and 33 deletions

View File

@ -2,7 +2,6 @@
Moozy_firmware by Laurent CLAUDE Moozy_firmware by Laurent CLAUDE
2023-09 2023-09
Licence GPL v3 or later Licence GPL v3 or later
*/ */
#include "USB.h" #include "USB.h"
@ -17,16 +16,17 @@ Preferences moozyPrefs;
// ---------------------------------- // ----------------------------------
// set pin numbers for each inputs: // set pin numbers for each inputs:
const int PinInput1 = 1; #define PinInput0 0
const int PinInput2 = 2; #define PinInput1 1
const int PinInput3 = 3; #define PinInput2 2
#define PinInput3 3
#define LedMoozy 48 #define LedMoozy 48
unsigned long debouncetime; unsigned long debouncetime;
bool keypressed = false, doNotRepeat = false; bool keypressed = false, doNotRepeat = false;
int cursorspeed, speed1, speed2, speed3; int cursorspeed, speed1, speed2, speed3;
int currentspeed = 2; int currentspeed = 2;
String todo, fctinput1, fctinput2, fctinput3; String todo, fctinput0, fctinput1, fctinput2, fctinput3;
/* /*
// Interrupt Service Routine // Interrupt Service Routine
@ -42,6 +42,7 @@ void ISR_Inputs () {
void setup() { void setup() {
// initialize the buttons' inputs: // initialize the buttons' inputs:
pinMode(PinInput0, INPUT_PULLUP);
pinMode(PinInput1, INPUT_PULLUP); pinMode(PinInput1, INPUT_PULLUP);
pinMode(PinInput2, INPUT_PULLUP); pinMode(PinInput2, INPUT_PULLUP);
pinMode(PinInput3, INPUT_PULLUP); pinMode(PinInput3, INPUT_PULLUP);
@ -52,6 +53,7 @@ void setup() {
speed1 = moozyPrefs.getInt("speed1"); speed1 = moozyPrefs.getInt("speed1");
speed2 = moozyPrefs.getInt("speed2"); speed2 = moozyPrefs.getInt("speed2");
speed3 = moozyPrefs.getInt("speed3"); speed3 = moozyPrefs.getInt("speed3");
fctinput0 = moozyPrefs.getString("input0");
fctinput1 = moozyPrefs.getString("input1"); fctinput1 = moozyPrefs.getString("input1");
fctinput2 = moozyPrefs.getString("input2"); fctinput2 = moozyPrefs.getString("input2");
fctinput3 = moozyPrefs.getString("input3"); fctinput3 = moozyPrefs.getString("input3");
@ -61,6 +63,12 @@ void setup() {
debouncetime = millis(); debouncetime = millis();
// initialize mouse control: // initialize mouse control:
USB.VID(0x1781);
USB.PID(0x0A62);
USB.manufacturerName("Laurent CLAUDE");
USB.productName("Moozy Nano");
USB.serialNumber("S/N-231112-001");
Mouse.begin(); Mouse.begin();
Keyboard.begin(); Keyboard.begin();
USB.begin(); USB.begin();
@ -83,11 +91,13 @@ void setup() {
// Main loop // Main loop
// ------------- // -------------
void loop() { void loop() {
if (!digitalRead(PinInput0)) { todo = fctinput0; }
if (!digitalRead(PinInput1)) { todo = fctinput1; } if (!digitalRead(PinInput1)) { todo = fctinput1; }
if (!digitalRead(PinInput2)) { todo = fctinput2; } if (!digitalRead(PinInput2)) { todo = fctinput2; }
if (!digitalRead(PinInput3)) { todo = fctinput3; } if (!digitalRead(PinInput3)) { todo = fctinput3; }
if ((todo != "") & (millis() > debouncetime + 100)) { if ((todo != "") & (millis() > debouncetime + 100)) {
digitalWrite(LedMoozy, true); // for debug
if ((todo =="LC") & (!doNotRepeat)) {doNotRepeat = true; dolc(); } if ((todo =="LC") & (!doNotRepeat)) {doNotRepeat = true; dolc(); }
if ((todo =="LCD") & (!doNotRepeat)) {doNotRepeat = true; dolcd(); } if ((todo =="LCD") & (!doNotRepeat)) {doNotRepeat = true; dolcd(); }
if ((todo =="LCH") & (!doNotRepeat)) {doNotRepeat = true; dolch(); } if ((todo =="LCH") & (!doNotRepeat)) {doNotRepeat = true; dolch(); }
@ -97,7 +107,14 @@ void loop() {
if (todo =="up") { moveup(); } if (todo =="up") { moveup(); }
if (todo =="down") { movedown(); } if (todo =="down") { movedown(); }
if (todo =="right") { moveright(); } if (todo =="right") { moveright();
// pour test de clavier
//Keyboard.pressRaw(0xe0);
//Keyboard.pressRaw(0x30);
Keyboard.pressRaw(0x80);
delay(100);
//Keyboard.releaseRaw();
Keyboard.releaseAll();}
if (todo =="left") { moveleft(); } if (todo =="left") { moveleft(); }
if (todo =="upright") { moveupright(); } if (todo =="upright") { moveupright(); }
if (todo =="upleft") { moveupleft(); } if (todo =="upleft") { moveupleft(); }
@ -122,7 +139,7 @@ void loop() {
} }
todo = ""; todo = "";
if ((digitalRead(PinInput1)) & (digitalRead(PinInput2)) & (digitalRead(PinInput3))) { doNotRepeat = false; } if ((digitalRead(PinInput0)) & (digitalRead(PinInput1)) & (digitalRead(PinInput2)) & (digitalRead(PinInput3))) { doNotRepeat = false; }
digitalWrite(LedMoozy, false); digitalWrite(LedMoozy, false); // for debug
} }

View File

@ -9,9 +9,14 @@
ESP32-S3 ESP32-S3
## Keyboard codes
Please to see : <https://github.com/sqrwf/arduino-usbhidkeyboard/blob/main/src/usbhidkeynames.h>
## Usage example ## Usage example
Turns almost any hardware into a USB mouse/keyboard device Turns almost any hardware into a USB mouse/keyboard/media device
## Development setup ## Development setup
@ -21,8 +26,8 @@ It's the beginning
## Release History ## Release History
* 0.0.1 * 0.0.2 Added exemple media key, and link to keyboard codes
* Work in progress * 0.0.1 Work in progress
## Contributing ## Contributing

View File

@ -5,7 +5,6 @@ void dolc() { // Do a left click
Mouse.release(); Mouse.release();
Mouse.click(MOUSE_LEFT); Mouse.click(MOUSE_LEFT);
Mouse.release(); Mouse.release();
todo = "";
} }
void dolcd() { // Do a double left click void dolcd() { // Do a double left click
Mouse.release(); Mouse.release();
@ -18,6 +17,7 @@ void dolcd() { // Do a double left click
Mouse.release(); Mouse.release();
} }
void dolch() { // Do a left click and hold void dolch() { // Do a left click and hold
Mouse.release();
if (Mouse.isPressed(MOUSE_LEFT)) { if (Mouse.isPressed(MOUSE_LEFT)) {
Mouse.release(); Mouse.release();
} }
@ -40,7 +40,8 @@ void dorcd() { // Do a double right click
delay(50); delay(50);
Mouse.release(); Mouse.release();
} }
void dorch() { // Do a left click and hold void dorch() { // Do a right click and hold
Mouse.release();
if (Mouse.isPressed(MOUSE_RIGHT)) { if (Mouse.isPressed(MOUSE_RIGHT)) {
Mouse.release(); Mouse.release();
} }
@ -50,23 +51,15 @@ void dorch() { // Do a left click and hold
} }
void moveup() { // Move the mouse cursor up void moveup() { // Move the mouse cursor up
Mouse.move(0, -cursorspeed); Mouse.move(0, -cursorspeed);
digitalWrite(LedMoozy, true);
delay(5);
} }
void movedown() { // Move the mouse cursor down void movedown() { // Move the mouse cursor down
Mouse.move(0, cursorspeed); Mouse.move(0, cursorspeed);
digitalWrite(LedMoozy, true);
delay(5);
} }
void moveright() { // Move the mouse cursor to the right void moveright() { // Move the mouse cursor to the right
Mouse.move(cursorspeed, 0); Mouse.move(cursorspeed, 0);
digitalWrite(LedMoozy, true);
delay(5);
} }
void moveleft() { // Move the mouse cursor to the left void moveleft() { // Move the mouse cursor to the left
Mouse.move(-cursorspeed, 0); Mouse.move(-cursorspeed, 0);
digitalWrite(LedMoozy, true);
delay(5);
} }
void moveupright() { // Move the mouse cursor to the diag up and right void moveupright() { // Move the mouse cursor to the diag up and right
Mouse.move(cursorspeed, -cursorspeed); Mouse.move(cursorspeed, -cursorspeed);
@ -102,21 +95,21 @@ void incspeed() { // Increase actual speed (max is 100)
switch (currentspeed) { switch (currentspeed) {
case 1: case 1:
speed1 = speed1 + 10; speed1 = speed1 + 10;
if (speed1 >=100) if (speed1 >=255)
speed1 = 100; speed1 = 255;
cursorspeed = speed1 / 10; cursorspeed = speed1 / 20;
break; break;
case 2: case 2:
speed2 = speed2 + 10; speed2 = speed2 + 10;
if (speed2 >=100) if (speed2 >=255)
speed2 = 100; speed2 = 255;
cursorspeed = speed2 / 10; cursorspeed = speed2 / 20;
break; break;
case 3: case 3:
speed3 = speed3 + 10; speed3 = speed3 + 10;
if (speed3 >=100) if (speed3 >=255)
speed3 = 100; speed3 = 255;
cursorspeed = speed3 / 10; cursorspeed = speed3 / 20;
break; break;
default: default:
break; break;
@ -128,19 +121,19 @@ void decspeed() { // Decrease actual speed (min is 0)
speed1 = speed1 - 10; speed1 = speed1 - 10;
if (speed1 <= 0) if (speed1 <= 0)
speed1 = 0; speed1 = 0;
cursorspeed = speed1 / 10; cursorspeed = speed1 / 20;
break; break;
case 2: case 2:
speed2 = speed2 - 10; speed2 = speed2 - 10;
if (speed2 <= 0) if (speed2 <= 0)
speed2 = 0; speed2 = 0;
cursorspeed = speed2 / 10; cursorspeed = speed2 / 20;
break; break;
case 3: case 3:
speed3 = speed3 - 10; speed3 = speed3 - 10;
if (speed3 <= 0) if (speed3 <= 0)
speed3 = 0; speed3 = 0;
cursorspeed = speed3 / 10; cursorspeed = speed3 / 20;
break; break;
default: default:
break; break;