Skip to content

Instantly share code, notes, and snippets.

@Daij-Djan
Created January 29, 2020 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daij-Djan/8ee19d82a149e8ff5996fdab5768be03 to your computer and use it in GitHub Desktop.
Save Daij-Djan/8ee19d82a149e8ff5996fdab5768be03 to your computer and use it in GitHub Desktop.
button_mash.gpc is a script for console tuner that implements 'rapid fire'/button mash. Holding down square, cross, circle or triangale button for automatic repetition instead of press (fast button mash)<br>
#pragma METAINFO("button_mash", 1, 1, "daij-djan")
#include <ps4.gph>
/*
<shortdesc>
***** Button mash@l (PS4) *****<br>
AutoCombo : Holding down square, cross, circle or triangale button for automatic repetition instead of press (fast button mash)<br>
On / Off : Press share button : to disabled/enable AutoCombo. (rumbles on activate)<br>
Hold share button 1s for normal options menu
</shortdesc>
*/
//===
//
// settings
//
bool g_autoComboOn=FALSE;
bool g_optionsKeyPressed=FALSE;
//====
//
// globals to hold state as we cant pass params to combo
//
bool g_repeatSquare=FALSE;
bool g_repeatCross=FALSE;
bool g_repeatCircle=FALSE;
bool g_repeatTriangle=FALSE;
//===
//
// load and runloop
//
init {
//load
pmem_load();
g_autoComboOn = pmem_read(0) & 0b1;
UpdateForSetting(g_autoComboOn, g_autoComboOn);
}
main {
// execute repeat if setting on
if (g_autoComboOn) {
g_repeatSquare = shouldRepeatButton(PS4_SQUARE);
g_repeatCross = shouldRepeatButton(PS4_CROSS);
g_repeatCircle = shouldRepeatButton(PS4_CIRCLE);
g_repeatTriangle = shouldRepeatButton(PS4_TRIANGLE);
if (g_repeatSquare ||
g_repeatCross ||
g_repeatCircle ||
g_repeatTriangle) {
combo_run(RepeatButtons);
} else {
combo_stop(RepeatButtons);
}
}
// on/off AutoCombo - with save
if (get_val(PS4_SHARE)) {
inhibit(PS4_SHARE, 500);
g_optionsKeyPressed = TRUE;
}
else if (g_optionsKeyPressed) {
g_optionsKeyPressed = FALSE;
//check if not longpress
if (time_active(PS4_SHARE) < 500) {
//toggle
bool oldAutoComboOn = g_autoComboOn;
g_autoComboOn = !g_autoComboOn;
pmem_write(0,g_autoComboOn);
pmem_save();
UpdateForSetting(oldAutoComboOn, g_autoComboOn);
}
}
}
//===
//
// repeat buttons
//
//Runner for Repetition of Buttons: starts or stops the combo
bool shouldRepeatButton(int button) {
if (get_val(button)) {
if ( time_active(button) > 100 ) {
return TRUE;
}
}
return FALSE;
}
//on repeat
//4x because you cant pass a param to a combos. They are kinda like EPs
//globals work fine somehow :)
combo RepeatButtons {
if (g_repeatSquare) set_val(PS4_SQUARE, 0);
if (g_repeatCross) set_val(PS4_CROSS, 0);
if (g_repeatCircle) set_val(PS4_CIRCLE, 0);
if (g_repeatTriangle) set_val(PS4_TRIANGLE, 0);
wait(75);
if (g_repeatSquare) set_val(PS4_SQUARE, 100);
if (g_repeatCross) set_val(PS4_CROSS, 100);
if (g_repeatCircle) set_val(PS4_CIRCLE, 100);
if (g_repeatTriangle) set_val(PS4_TRIANGLE, 100);
wait(75);
}
//===
//
// Settings update
//
void UpdateForSetting(bool oldAutoComboOn, bool newAutoComboOn) {
led_set(LED_2,(fix32)newAutoComboOn*100f,0); // red
if (oldAutoComboOn != newAutoComboOn) {
combo_run(RumbleController);
}
}
//on confirmation
combo RumbleController {
ffb_set(FFB_1, 100.0, 140);
wait(200);
ffb_set(FFB_1, 0.0, 140);
wait(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment