diff --git a/Moozy_firmware.ino b/Moozy_firmware.ino index 0564088..05784b3 100644 --- a/Moozy_firmware.ino +++ b/Moozy_firmware.ino @@ -2,7 +2,6 @@ Moozy_firmware by Laurent CLAUDE 2023-09 Licence GPL v3 or later - */ #include "USB.h" @@ -17,16 +16,17 @@ Preferences moozyPrefs; // ---------------------------------- // set pin numbers for each inputs: -const int PinInput1 = 1; -const int PinInput2 = 2; -const int PinInput3 = 3; +#define PinInput0 0 +#define PinInput1 1 +#define PinInput2 2 +#define PinInput3 3 #define LedMoozy 48 unsigned long debouncetime; bool keypressed = false, doNotRepeat = false; int cursorspeed, speed1, speed2, speed3; int currentspeed = 2; -String todo, fctinput1, fctinput2, fctinput3; +String todo, fctinput0, fctinput1, fctinput2, fctinput3; /* // Interrupt Service Routine @@ -42,6 +42,7 @@ void ISR_Inputs () { void setup() { // initialize the buttons' inputs: + pinMode(PinInput0, INPUT_PULLUP); pinMode(PinInput1, INPUT_PULLUP); pinMode(PinInput2, INPUT_PULLUP); pinMode(PinInput3, INPUT_PULLUP); @@ -52,6 +53,7 @@ void setup() { speed1 = moozyPrefs.getInt("speed1"); speed2 = moozyPrefs.getInt("speed2"); speed3 = moozyPrefs.getInt("speed3"); + fctinput0 = moozyPrefs.getString("input0"); fctinput1 = moozyPrefs.getString("input1"); fctinput2 = moozyPrefs.getString("input2"); fctinput3 = moozyPrefs.getString("input3"); @@ -61,6 +63,12 @@ void setup() { debouncetime = millis(); // 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(); Keyboard.begin(); USB.begin(); @@ -83,11 +91,13 @@ void setup() { // Main loop // ------------- void loop() { + if (!digitalRead(PinInput0)) { todo = fctinput0; } if (!digitalRead(PinInput1)) { todo = fctinput1; } if (!digitalRead(PinInput2)) { todo = fctinput2; } if (!digitalRead(PinInput3)) { todo = fctinput3; } if ((todo != "") & (millis() > debouncetime + 100)) { + digitalWrite(LedMoozy, true); // for debug if ((todo =="LC") & (!doNotRepeat)) {doNotRepeat = true; dolc(); } if ((todo =="LCD") & (!doNotRepeat)) {doNotRepeat = true; dolcd(); } if ((todo =="LCH") & (!doNotRepeat)) {doNotRepeat = true; dolch(); } @@ -97,7 +107,14 @@ void loop() { if (todo =="up") { moveup(); } 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 =="upright") { moveupright(); } if (todo =="upleft") { moveupleft(); } @@ -122,7 +139,7 @@ void loop() { } 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 } diff --git a/README.md b/README.md index 8350f50..6c5a79d 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,14 @@ ESP32-S3 +## Keyboard codes + +Please to see : + + ## 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 @@ -21,8 +26,8 @@ It's the beginning ## Release History -* 0.0.1 - * Work in progress +* 0.0.2 Added exemple media key, and link to keyboard codes +* 0.0.1 Work in progress ## Contributing diff --git a/moozyfeatures.ino b/moozyfeatures.ino index d11b6a7..82ad272 100644 --- a/moozyfeatures.ino +++ b/moozyfeatures.ino @@ -5,7 +5,6 @@ void dolc() { // Do a left click Mouse.release(); Mouse.click(MOUSE_LEFT); Mouse.release(); - todo = ""; } void dolcd() { // Do a double left click Mouse.release(); @@ -18,6 +17,7 @@ void dolcd() { // Do a double left click Mouse.release(); } void dolch() { // Do a left click and hold + Mouse.release(); if (Mouse.isPressed(MOUSE_LEFT)) { Mouse.release(); } @@ -40,7 +40,8 @@ void dorcd() { // Do a double right click delay(50); 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)) { Mouse.release(); } @@ -50,23 +51,15 @@ void dorch() { // Do a left click and hold } void moveup() { // Move the mouse cursor up Mouse.move(0, -cursorspeed); - digitalWrite(LedMoozy, true); - delay(5); } void movedown() { // Move the mouse cursor down Mouse.move(0, cursorspeed); - digitalWrite(LedMoozy, true); - delay(5); } void moveright() { // Move the mouse cursor to the right Mouse.move(cursorspeed, 0); - digitalWrite(LedMoozy, true); - delay(5); } void moveleft() { // Move the mouse cursor to the left Mouse.move(-cursorspeed, 0); - digitalWrite(LedMoozy, true); - delay(5); } void moveupright() { // Move the mouse cursor to the diag up and right Mouse.move(cursorspeed, -cursorspeed); @@ -102,21 +95,21 @@ void incspeed() { // Increase actual speed (max is 100) switch (currentspeed) { case 1: speed1 = speed1 + 10; - if (speed1 >=100) - speed1 = 100; - cursorspeed = speed1 / 10; + if (speed1 >=255) + speed1 = 255; + cursorspeed = speed1 / 20; break; case 2: speed2 = speed2 + 10; - if (speed2 >=100) - speed2 = 100; - cursorspeed = speed2 / 10; + if (speed2 >=255) + speed2 = 255; + cursorspeed = speed2 / 20; break; case 3: speed3 = speed3 + 10; - if (speed3 >=100) - speed3 = 100; - cursorspeed = speed3 / 10; + if (speed3 >=255) + speed3 = 255; + cursorspeed = speed3 / 20; break; default: break; @@ -128,19 +121,19 @@ void decspeed() { // Decrease actual speed (min is 0) speed1 = speed1 - 10; if (speed1 <= 0) speed1 = 0; - cursorspeed = speed1 / 10; + cursorspeed = speed1 / 20; break; case 2: speed2 = speed2 - 10; if (speed2 <= 0) speed2 = 0; - cursorspeed = speed2 / 10; + cursorspeed = speed2 / 20; break; case 3: speed3 = speed3 - 10; if (speed3 <= 0) speed3 = 0; - cursorspeed = speed3 / 10; + cursorspeed = speed3 / 20; break; default: break;