Skip to content

Commit

Permalink
Sync changes from Master (#30)
Browse files Browse the repository at this point in the history
* Some fixes (#29)

* 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

* Consistency, slight cleanup

---------

Co-authored-by: kikexx <[email protected]>
  • Loading branch information
SeongGino and kikexx authored Sep 27, 2024
1 parent 2f22ba7 commit 4ee6153
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions SamcoEnhanced/SamcoEnhanced.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

Expand Down Expand Up @@ -1420,7 +1422,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(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(dispLifePercentage);
}
else if(OLED.serialDisplayType == ExtDisplay::ScreenSerial_Both) {
OLED.PrintAmmo(serialAmmoCount);
OLED.PrintLife(serialLifeCount);
Expand Down Expand Up @@ -3275,6 +3282,7 @@ void SerialProcessing()
}
if(Serial.read() == 'B') {
OLED.lifeBar = true;
dispMaxLife = 0;
} else { OLED.lifeBar = false; }
// prevent glitching if currently in pause mode
if(gunMode == GunMode_Run) {
Expand Down Expand Up @@ -3586,6 +3594,10 @@ void SerialProcessing()
}
}
serialLifeCount = atoi(serialInputS);
if (OLED.lifeBar){
if (serialLifeCount > dispMaxLife) { dispMaxLife = serialLifeCount; }
dispLifePercentage = (100 * serialLifeCount) / dispMaxLife; // Calculate the Life % to show
}
break;
}
}
Expand Down Expand Up @@ -3775,12 +3787,14 @@ 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) { 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?
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.
}
}
Expand All @@ -3790,10 +3804,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.
}
Expand Down

0 comments on commit 4ee6153

Please sign in to comment.