From f0d79c3a90b7351f4c6ba8cf553842b56331a793 Mon Sep 17 00:00:00 2001 From: kikexx <55745394+kikexx@users.noreply.github.com> Date: Fri, 27 Sep 2024 17:47:56 +0200 Subject: [PATCH 1/4] Some fixes (#29) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Mapeadas flechas del teclado y añadida pulsacion del gatillo en modo serie -Se han mapeado las flechas del teclado y se han asignado al Dpad mientras la pistola está en modo Ratón+Teclado -Se ha añadido el botón "trigger" en modo mando mientras está activa la comunicación serie (mamehook) ya que anteriormente si se activaba la comunicación serie mientras la pistola estaba en modo "mando" dejaba de funcionar el gatillo * Algunas correcciones de como se muestra la vida (barra de vida) en la pantalla oled -Ahora calcula el porcentaje de "vida" y lo muestra correctamente. -Cambiado el tipo de variable usada para leer la "vida" de uint8_t cuyo valor máximo es 255 a uint16_t para mostrar correctamente la "vida en juegos que usen un valor mayor como Aliens Armageddon que usa de valor máximo 1000 * Reset SamcoEnhanced.ino Reset file to begin PR * Fix trigger in Gamepad mode + Serial -Added trigger button to work when serial comunication is enabled and gun is in Gamepad mode * Fix for life% shown in lifebar - Fix for life% shown in lifebar - Changed "serialLifeCount" from uint8_t to uint16_t, for handle life values higher than 255 * Translated some variable to maintain language consistency - Translated some variable to maintain language consistency --- SamcoEnhanced/SamcoEnhanced.ino | 40 ++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/SamcoEnhanced/SamcoEnhanced.ino b/SamcoEnhanced/SamcoEnhanced.ino index 20c676c..bc60b10 100644 --- a/SamcoEnhanced/SamcoEnhanced.ino +++ b/SamcoEnhanced/SamcoEnhanced.ino @@ -368,8 +368,10 @@ bool buttonPressed = false; // Sanity check. #endif // USES_SOLENOID #ifdef USES_DISPLAY bool serialDisplayChange = false; // Signal of pending display update, sent by Core 2 to be used by Core 1 in dual core configs - uint8_t serialLifeCount = 0; + uint16_t serialLifeCount = 0;//Changed from uint16_t for games with life values > 255 uint8_t serialAmmoCount = 0; + uint16_t MaxLife = 0; //Max value for life in lifebar mode (100%) + uint16_t LifePercentage = 0; //Actual value to show in lifebar mode #% #endif // USES_DISPLAY #endif // MAMEHOOKER @@ -1423,7 +1425,12 @@ void ExecRunMode() // so just do it here using the signal sent by it. if(serialDisplayChange) { if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Ammo) { OLED.PrintAmmo(serialAmmoCount); } + else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Life && OLED.lifeBar){ OLED.PrintLife(LifePercentage); } else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Life) { OLED.PrintLife(serialLifeCount); } + else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Both && OLED.lifeBar) { + OLED.PrintAmmo(serialAmmoCount); + OLED.PrintLife(LifePercentage); + } else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Both) { OLED.PrintAmmo(serialAmmoCount); OLED.PrintLife(serialLifeCount); @@ -3259,6 +3266,7 @@ void SerialProcessing() } if(Serial.read() == 'B') { OLED.lifeBar = true; + MaxLife = 0; //Reset Max life } else { OLED.lifeBar = false; } // prevent glitching if currently in pause mode if(gunMode == GunMode_Run) { @@ -3570,6 +3578,10 @@ void SerialProcessing() } } serialLifeCount = atoi(serialInputS); + if (OLED.lifeBar){ + if (serialLifeCount > MaxLife) { MaxLife = serialLifeCount; } + LifePercentage = (100 * serialLifeCount) / MaxLife; //Calculate the Life % to show + } break; } } @@ -3759,12 +3771,20 @@ void SerialHandling() void TriggerFireSimple() { if(!buttonPressed && // Have we not fired the last cycle, - offscreenButtonSerial && buttons.offScreen) { // and are pointing the gun off screen WITH the offScreen button mode set? - AbsMouse5.press(MOUSE_RIGHT); // Press the right mouse button + offscreenButtonSerial && buttons.offScreen) { // and are pointing the gun off screen WITH the offScreen button mode set? + if(buttons.analogOutput) { //Check if gamepad mode is enabled + Gamepad16.press(LightgunButtons::ButtonDesc[BtnIdx_A].reportCode3); //If gamepad mode is enabled Press A Button + } else { + AbsMouse5.press(MOUSE_RIGHT); // Press the right mouse button + } offscreenBShot = true; // Mark we pressed the right button via offscreen shot mode, buttonPressed = true; // Mark so we're not spamming these press events. } else if(!buttonPressed) { // Else, have we simply not fired the last cycle? - AbsMouse5.press(MOUSE_LEFT); // We're handling the trigger button press ourselves for a reason. + if(buttons.analogOutput) { //Check if gamepad mode is enabled + Gamepad16.press(LightgunButtons::ButtonDesc[BtnIdx_Trigger].reportCode3); //If gamepad mode is enabled Press Trigger Button + } else { + AbsMouse5.press(MOUSE_LEFT); // We're handling the trigger button press ourselves for a reason. + } buttonPressed = true; // Set this so we won't spam a repeat press event again. } } @@ -3774,10 +3794,18 @@ void TriggerNotFireSimple() { if(buttonPressed) { // Just to make sure we aren't spamming mouse button events. if(offscreenBShot) { // if it was marked as an offscreen button shot, - AbsMouse5.release(MOUSE_RIGHT); // Release the right mouse, + if(buttons.analogOutput) { //Check if gamepad mode is enabled + Gamepad16.release(LightgunButtons::ButtonDesc[BtnIdx_A].reportCode3); //If gamepad mode is enabled release A Button + } else { + AbsMouse5.release(MOUSE_RIGHT); // Release the right mouse, + } offscreenBShot = false; // And set it off. } else { // Else, - AbsMouse5.release(MOUSE_LEFT); // It was a normal shot, so just release the left mouse button. + if(buttons.analogOutput) { //Check if gamepad mode is enabled + Gamepad16.release(LightgunButtons::ButtonDesc[BtnIdx_Trigger].reportCode3); // If gamepad mode is enabled release the Trigger button + } else { + AbsMouse5.release(MOUSE_LEFT); // It was a normal shot, so just release the left mouse button. + } } buttonPressed = false; // Unset the button pressed bit. } From 21092e13c619969b0d9c163fc07aca498abb43bf Mon Sep 17 00:00:00 2001 From: That One Seong Date: Fri, 27 Sep 2024 11:58:19 -0400 Subject: [PATCH 2/4] Consistency, slight cleanup --- SamcoEnhanced/SamcoEnhanced.ino | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/SamcoEnhanced/SamcoEnhanced.ino b/SamcoEnhanced/SamcoEnhanced.ino index bc60b10..486427f 100644 --- a/SamcoEnhanced/SamcoEnhanced.ino +++ b/SamcoEnhanced/SamcoEnhanced.ino @@ -368,10 +368,10 @@ bool buttonPressed = false; // Sanity check. #endif // USES_SOLENOID #ifdef USES_DISPLAY bool serialDisplayChange = false; // Signal of pending display update, sent by Core 2 to be used by Core 1 in dual core configs - uint16_t serialLifeCount = 0;//Changed from uint16_t for games with life values > 255 + uint16_t serialLifeCount = 0; // Changed from uint16_t for games with life values > 255 uint8_t serialAmmoCount = 0; - uint16_t MaxLife = 0; //Max value for life in lifebar mode (100%) - uint16_t LifePercentage = 0; //Actual value to show in lifebar mode #% + uint16_t dispMaxLife = 0; // Max value for life in lifebar mode (100%) + uint16_t dispLifePercentage = 0; // Actual value to show in lifebar mode #% #endif // USES_DISPLAY #endif // MAMEHOOKER @@ -1425,11 +1425,11 @@ void ExecRunMode() // so just do it here using the signal sent by it. if(serialDisplayChange) { if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Ammo) { OLED.PrintAmmo(serialAmmoCount); } - else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Life && OLED.lifeBar){ OLED.PrintLife(LifePercentage); } + else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Life && OLED.lifeBar) { OLED.PrintLife(dispLifePercentage); } else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Life) { OLED.PrintLife(serialLifeCount); } else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Both && OLED.lifeBar) { OLED.PrintAmmo(serialAmmoCount); - OLED.PrintLife(LifePercentage); + OLED.PrintLife(dispLifePercentage); } else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Both) { OLED.PrintAmmo(serialAmmoCount); @@ -3266,7 +3266,7 @@ void SerialProcessing() } if(Serial.read() == 'B') { OLED.lifeBar = true; - MaxLife = 0; //Reset Max life + dispMaxLife = 0; } else { OLED.lifeBar = false; } // prevent glitching if currently in pause mode if(gunMode == GunMode_Run) { @@ -3579,8 +3579,8 @@ void SerialProcessing() } serialLifeCount = atoi(serialInputS); if (OLED.lifeBar){ - if (serialLifeCount > MaxLife) { MaxLife = serialLifeCount; } - LifePercentage = (100 * serialLifeCount) / MaxLife; //Calculate the Life % to show + if (serialLifeCount > dispMaxLife) { dispMaxLife = serialLifeCount; } + dispLifePercentage = (100 * serialLifeCount) / dispMaxLife; // Calculate the Life % to show } break; } @@ -3772,19 +3772,13 @@ void TriggerFireSimple() { if(!buttonPressed && // Have we not fired the last cycle, offscreenButtonSerial && buttons.offScreen) { // and are pointing the gun off screen WITH the offScreen button mode set? - if(buttons.analogOutput) { //Check if gamepad mode is enabled - Gamepad16.press(LightgunButtons::ButtonDesc[BtnIdx_A].reportCode3); //If gamepad mode is enabled Press A Button - } else { - AbsMouse5.press(MOUSE_RIGHT); // Press the right mouse button - } + if(buttons.analogOutput) { Gamepad16.press(LightgunButtons::ButtonDesc[BtnIdx_A].reportCode3); } + else { AbsMouse5.press(MOUSE_RIGHT); } offscreenBShot = true; // Mark we pressed the right button via offscreen shot mode, buttonPressed = true; // Mark so we're not spamming these press events. } else if(!buttonPressed) { // Else, have we simply not fired the last cycle? - if(buttons.analogOutput) { //Check if gamepad mode is enabled - Gamepad16.press(LightgunButtons::ButtonDesc[BtnIdx_Trigger].reportCode3); //If gamepad mode is enabled Press Trigger Button - } else { - AbsMouse5.press(MOUSE_LEFT); // We're handling the trigger button press ourselves for a reason. - } + if(buttons.analogOutput) { Gamepad16.press(LightgunButtons::ButtonDesc[BtnIdx_Trigger].reportCode3); } + else { AbsMouse5.press(MOUSE_LEFT); } buttonPressed = true; // Set this so we won't spam a repeat press event again. } } From 2de17e72b7fd9850de34aea2a529f7ac0aac270e Mon Sep 17 00:00:00 2001 From: That One Seong Date: Fri, 27 Sep 2024 15:00:38 -0400 Subject: [PATCH 3/4] Bump Arduino-cli --- .github/workflows/arduino-cli-builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/arduino-cli-builds.yml b/.github/workflows/arduino-cli-builds.yml index 4a7d44b..7d635bf 100644 --- a/.github/workflows/arduino-cli-builds.yml +++ b/.github/workflows/arduino-cli-builds.yml @@ -62,7 +62,7 @@ jobs: submodules: true - name: Install Arduino-cli - uses: arduino/setup-arduino-cli@v1 + uses: arduino/setup-arduino-cli@v2 # arduino nano uses this just to access LEDs, grr... - name: Install Arduino Nano Connect library From 7aad7bdc8f78380b70128bad2f5a4d2e42a5eaa5 Mon Sep 17 00:00:00 2001 From: That One Seong Date: Fri, 27 Sep 2024 15:05:20 -0400 Subject: [PATCH 4/4] Forgot this one. --- SamcoEnhanced/SamcoEnhanced.ino | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/SamcoEnhanced/SamcoEnhanced.ino b/SamcoEnhanced/SamcoEnhanced.ino index 486427f..28b0051 100644 --- a/SamcoEnhanced/SamcoEnhanced.ino +++ b/SamcoEnhanced/SamcoEnhanced.ino @@ -3788,18 +3788,12 @@ void TriggerNotFireSimple() { if(buttonPressed) { // Just to make sure we aren't spamming mouse button events. if(offscreenBShot) { // if it was marked as an offscreen button shot, - if(buttons.analogOutput) { //Check if gamepad mode is enabled - Gamepad16.release(LightgunButtons::ButtonDesc[BtnIdx_A].reportCode3); //If gamepad mode is enabled release A Button - } else { - AbsMouse5.release(MOUSE_RIGHT); // Release the right mouse, - } + if(buttons.analogOutput) { Gamepad16.release(LightgunButtons::ButtonDesc[BtnIdx_A].reportCode3); } + else { AbsMouse5.release(MOUSE_RIGHT); } offscreenBShot = false; // And set it off. } else { // Else, - if(buttons.analogOutput) { //Check if gamepad mode is enabled - Gamepad16.release(LightgunButtons::ButtonDesc[BtnIdx_Trigger].reportCode3); // If gamepad mode is enabled release the Trigger button - } else { - AbsMouse5.release(MOUSE_LEFT); // It was a normal shot, so just release the left mouse button. - } + if(buttons.analogOutput) { Gamepad16.release(LightgunButtons::ButtonDesc[BtnIdx_Trigger].reportCode3); } + else { AbsMouse5.release(MOUSE_LEFT); } } buttonPressed = false; // Unset the button pressed bit. }