diff --git a/CMakeLists.txt b/CMakeLists.txt index 2723aea..78d7cd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,10 @@ add_library( chaos-engine src/interface.cpp src/joystick.cpp src/chaosEngine.cpp src/modifier.cpp + include/modifier.h src/sequence.cpp - src/menuing.cpp + include/sequence.h +# src/menuing.cpp src/chaos-uhid.cpp include/interface.h include/device.h @@ -49,7 +51,7 @@ add_library( chaos-engine src/interface.cpp set(LIBS ${LIBS} chaos-engine sniffify) -add_executable( chaos src/main.cpp ) +#add_executable( chaos src/main.cpp ) add_executable( passthrough-hid src/passthroughHID.cpp ) add_executable( hid-example src/hid-example.c ) @@ -77,7 +79,7 @@ if( NOT APPLE ) set(LIBS ${LIBS} crypt rt ) endif() -target_link_libraries( chaos ${LIBS} zmqpp zmq ) +#target_link_libraries( chaos ${LIBS} zmqpp zmq ) target_link_libraries( passthrough-hid ${LIBS} zmqpp zmq ) #add_executable( zmq_client src/zmq_client.cpp ) @@ -85,3 +87,4 @@ target_link_libraries( passthrough-hid ${LIBS} zmqpp zmq ) #target_link_libraries( zmq_client zmqpp zmq ) #target_link_libraries( zmq_server zmqpp zmq ) +add_subdirectory(examples) diff --git a/README.md b/README.md index 8e89af8..52f4e4f 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,8 @@ Implemented: - - Controller Flip - [gabemusic](https://www.twitch.tv/gabemusic) - - Max Sensitivity + -[carnalgasyeah](https://www.twitch.tv/carnalgasyeah) +- - Zoolander TBD: diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..c9b16fb --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(TLOU2) diff --git a/examples/TLOU2/CMakeLists.txt b/examples/TLOU2/CMakeLists.txt new file mode 100644 index 0000000..4519dcf --- /dev/null +++ b/examples/TLOU2/CMakeLists.txt @@ -0,0 +1,13 @@ + +project( tlou2 ) + +include_directories( include ) + +add_executable( tlou2 src/main.cpp + src/menuing.cpp + include/menuing.h ) + +target_link_libraries( tlou2 ${LIBS} zmqpp zmq ) + + + diff --git a/examples/TLOU2/include/menuing.h b/examples/TLOU2/include/menuing.h new file mode 100644 index 0000000..cc32343 --- /dev/null +++ b/examples/TLOU2/include/menuing.h @@ -0,0 +1,217 @@ +#ifndef MENUING_H +#define MENUING_H + +#include "sequence.h" + +enum OptionsMainMenu { + MENU_OPTIONS = 0, + MENU_PHOTOMODE = 1, + MENU_EXTRAS = 2, + MENU_TUTORIALS = 3, + MENU_SAVE = 4, + MENU_LOAD = 5, + MENU_RESTART1 = -3, + MENU_RESTART2 = -2, + MENU_QUIT = -1 +}; + +enum OptionsOptions { + OPTIONS_DIFFICULTY = 0, + OPTIONS_CONTROLS = 1, + OPTIONS_HUD = 2, + OPTIONS_ACCESSIBILITY = -1, +}; + +enum OptionsHUD { + HUD_RETICLE = 0, + HUD_WEAPON_CROSS_DISABLE = 1 +}; + +enum OptionsExtras { + EXTRA_RENDER = 0, + EXTRA_GAMEPLAY = 1 +}; + +enum OptionsRender { + RENDER_NONE = 0, + RENDER_GRAPHIC = 1, + RENDER_HEADHACHE = 2, + RENDER_AFTERLIFE = 3, + RENDER_EIGHTBIT = 4, + RENDER_WATERCOLOR = 5, + RENDER_DUNGEON = 6, + RENDER_VOID = 7, + RENDER_POPPOSTER = 8, + RENDER_NINETEENSIXTY = 9, + RENDER_COOL = 10, + RENDER_WARM = 11, + RENDER_VIBRANT = 12, + RENDER_NOIR = 13, + RENDER_BLORANGE = 14, + RENDER_SEPIA = 15, + RENDER_VINTAGE = -14, + RENDER_BEASTS = -13, + RENDER_TERMINATED = -12, + RENDER_GRIDLOCKED = -11, + RENDER_BLACKLIGHT = -10, + RENDER_DESERT_FOG = -9, + RENDER_BLOOD = -8, + RENDER_INFERNO = -7, + RENDER_FIRE = -6, + RENDER_TRINITY = -5, + RENDER_PUSHER = -4, + RENDER_DEMONS = -3, + RENDER_DRUGZONE = -2, + RENDER_MOONLIGHT = -1, +}; + +enum OptionsGameplay { + GAMEPLAY_MIRROR = 0, + GAMEPLAY_MIRROR_ON_DEATH = 1, + GAMEPLAY_SLOW_MOTION = 2, + GAMEPLAY_BULLET_SPEED = 3, + GAMEPLAY_INFINITE_AMMO = 4, + GAMEPLAY_INFINITE_CRAFT = 5, + GAMEPLAY_INFINITE_MELEE_DURABILITY = 6, + GAMEPLAY_INFINITE_LISTEN_RANGE = 7, +// GAMEPLAY_INFINITE_MELEE = 8, // ???? + GAMEPLAY_ONE_SHOT = -6, + GAMEPLAY_TOUCH_OF_DEATH = -5, + GAMEPLAY_AUDIO_EIGHT_BIT = -4, + GAMEPLAY_AUDIO_FOUR_BIT = -3, + GAMEPLAY_AUDIO_HELIUM = -2, + GAMEPLAY_AUDIO_XENON = -1, +}; + +enum ReticleOptions { + RETICLE_OFF = 0, + RETICLE_SIMPLE = 1, + RETICLE_DEFAULT = 2 +}; + +enum OptionsAccessibility { // options/accessibility + ACCESSIBILITY_ALTERNATE_CONTROLS = 0, + ACCESSIBILITY_MAGNIFICATION_AND_VISUAL_AIDS = 1, + ACCESSIBILITY_MOTION_SICKNESS = 2, + ACCESSIBILITY_NAVIGATION_AND_TRAVERSAL = 3, + ACCESSIBILITY_TTS_AND_AUDIO_CUES = -2, + ACCESSIBILITY_COMBAT_ACCESSIBILITY = -1, +}; + +enum OptionsAternateControls { // options/accessibility/alternate controls + ALTERNATE_CUSTOMIZE_CONTROLS = 0, + ALTERNATE_LOCK_ON_AIM = -6, + ALTERNATE_AUTO_PICK_UP = -1 +}; + +enum OptionsMagnificationAndAids { // options/accessibility/Magnification + MAGNIFICATION_HUD_SCALE = 0, // for larger HUD + MAGNIFICATION_HIGH_CONTRAST = -3, +}; + +enum OptionsNavigation { // options/accessibility/Navigation + NAVIGATION_ASSISTANCE = 0, + NAVIGATION_TRAVERSAL_ASSISTANCE = 1, + NAVIGATION_LEDGE_GUARD = 2, + NAVIGATION_ENHANCED_LISTEN_MODE = 3, + NAVIGATION_SCAN_RANGE = 4, + NAVIGATION_SCAN_TIME = -3, + NAVIGATION_INFINITE_BREATH = -2, + NAVIGATION_SKIP_PUZZLE = -1 +}; + +enum OptionsTTS { // options/accessibility/TTS + TTS_TTS = 0, + TTS_TRAVERSAL_CUES = 1, + TTS_COMBAT_CUES = 2 +}; + +enum OptionsCombat { // options/accessibility/Combat + COMBAT_ENABLE = 0, + COMBAT_HOSTAGES_DONT_ESCAPE = 1, + COMBAT_ALLIES_DONT_GET_GRABBED = 2, + COMBAT_ENEMIES_DONT_FLANK = 3, + COMBAT_REDUCED_ENEMY_PERCEPTION = 4, + COMBAT_REDUCED_ENEMY_ACCURACY = 5, + COMBAT_ENHANCED_DODGE = -4, + COMBAT_INVISBLE_WHILE_PRONE = -3, // use d-pad, right twitce to sleect + COMBAT_WEAPON_SWAY = -2, + COMBAT_SLOW_MOTION = -1 // d-pad, but cannot use this. have slowmo elsewhere +}; + + +class Menuing { +private: + Menuing(); + + Chaos::Sequence sequence; + + int mainMenu; + int extras; + int render; + int gameplay; + int options; + int hud; + + int accessibility = ACCESSIBILITY_ALTERNATE_CONTROLS; + int alternateControls = ALTERNATE_CUSTOMIZE_CONTROLS; + int magnification = MAGNIFICATION_HUD_SCALE; + int navigation = NAVIGATION_ASSISTANCE; + int tts = TTS_TTS; + int numberAudioCuesEnabled = 0; + int combat = COMBAT_ENABLE; + +#define AUDIO_DEFAULT (0) +#define AUDIO_FOUR_BIT (1) +#define AUDIO_EIGHT_BIT (2) +#define AUDIO_HELIUM (3) +#define AUDIO_XENON (4) + + int audioCrappifier; + int audioPitch; + + int renderModesApplied; + + void moveToMenuItem( int difference ); + + void enterMainMenu(); + void exitMainMenu(); + void selectMainMenuItem( int selection ); + void deselectMainMenu(); + + void sendSequence( Chaos::Controller* dualshock ); + + // Options: + void selectExtraItem( int selection ); + void deselectExtra(); + //void selectRenderMode( int selection ); + //void selectGameplayMode( int selection ); + + void selectOptionItem( int selection ); // HUD, ACCESSIBILITIES + void deselectOption(); + void selectHudItem( int selection ); + void deselectHud(); + + void selectAccessibilityItem( int item ); + void deselectAccessibility(); + // void setCombatAccessibility( int item, bool onOrOff ); + +public: + static Menuing* getInstance(); + + void selectRenderMode( int renderMode, Chaos::Controller* dualshock ); + void teardownRenderMode( Chaos::Controller* dualshock ); + void teardownAudio( int whatToTeardown, Chaos::Controller* dualshock ); + void selectGameplayMode( int gameplayMode, Chaos::Controller* dualshock ); + void selectHudMode( int hudOption, int option, Chaos::Controller* dualshock ); + + + void setAlternateControls( int item, bool enable, Chaos::Controller* dualshock ); + void setMagnificationAndAids( int item, bool enable, Chaos::Controller* dualshock ); + void setNavigationAndTraversal( int item, bool enable, Chaos::Controller* dualshock ); + void setTtsAndAudioCues( int item, bool enable, Chaos::Controller* dualshock ); + void setCombatAccessibility( int item, bool enable, Chaos::Controller* dualshock ); +}; + + +#endif diff --git a/examples/TLOU2/src/main.cpp b/examples/TLOU2/src/main.cpp new file mode 100644 index 0000000..9fa13c2 --- /dev/null +++ b/examples/TLOU2/src/main.cpp @@ -0,0 +1,3164 @@ +#include +#include +#include +#include + +#include "chaos.h" +#include "menuing.h" + +#define JOYSTICK_MIN (-128) +#define JOYSTICK_MAX (127) + +using namespace Chaos; + +inline short joystickLimit( int input ) { + return fmin( fmax( input, JOYSTICK_MIN), JOYSTICK_MAX); +} + +class Inverted : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Inverted"] = [](){return new Inverted();}; }; + const char* description() { return "Inverts the Y-axis on the right joystick (aim inversion)"; }; + + bool tweak( DeviceEvent* event ) { + if ((event->id == AXIS_RY ) && event->type == TYPE_AXIS) { + event->value = -((int)event->value+1) ; + } + return true; + } +}; + +// Suggestion from protoxin: +class Moonwalk : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Moonwalk"] = [](){return new Moonwalk();}; }; + const char* description() { return "Be like Michael Jackson! Trying to walk forward will actually make you go backward"; }; + + bool tweak( DeviceEvent* event ) { + if ((event->id == AXIS_LY ) && event->type == TYPE_AXIS) { + event->value = -((int)event->value+1) ; + } + return true; + } +}; + +class MeleeOnly : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Melee Only"] = [](){return new MeleeOnly();}; }; + const char* description() { return "No shooting and no throwables"; }; + + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_R2 && event->type == TYPE_BUTTON) { + event->value = 0; + } + if (event->id == AXIS_R2 && event->type == TYPE_AXIS) { + event->value = JOYSTICK_MIN; + } + return true; + } +}; + +class NoMelee : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Melee"] = [](){return new NoMelee();}; }; + const char* description() { return "Square presses are feeble"; }; + + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_SQUARE && event->type == TYPE_BUTTON) { + event->value = 0; + } + return true; + } +}; + +class Pacifist: public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Pacifist%"] = [](){return new Pacifist();}; }; + const char* description() { return "No shooting, throwing, nor melee. Good luck NPC friends!"; }; + bool tweak( DeviceEvent* event ) { + if (event->type == TYPE_BUTTON && + (event->id == BUTTON_SQUARE || // disable Melee + event->id == BUTTON_R2) ) { // Disable Shooting, blind fire + event->value = 0; + } else if(event->type == TYPE_AXIS && + event->id == AXIS_R2) { + event->value = JOYSTICK_MIN; + } + return true; + } +}; + +class NoTriangle : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Triangle"] = [](){return new NoTriangle();}; }; + const char* description() { return "No looting, stealth grabbing, opening doors. Say goodbye to the everything button"; }; + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_TRIANGLE && event->type == TYPE_BUTTON) { + event->value = 0; + } + return true; + } +}; + +class NoClimbJump : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Climbing/Jumping"] = [](){return new NoClimbJump();}; }; + const char* description() { return "No X presses"; }; + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_X && event->type == TYPE_BUTTON) { + event->value = 0; + } + return true; + } +}; + +class NoAiming : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Aiming"] = [](){return new NoAiming();}; }; + const char* description() { return "At least reloading is still possible, along with throwables and melee"; }; + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_L2 && event->type == TYPE_BUTTON) { + event->value = 0; + } + return true; + } +}; + +class NoScoping : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Scoping"] = [](){return new NoScoping();}; }; + const char* description() { return "No scopes! Aiming is still allowed"; }; + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_X && event->type == TYPE_BUTTON) { + if (dualshock->getState(BUTTON_L2, TYPE_BUTTON)) { // only disable X when aiming + event->value = 0; + } + } + return true; + } +}; + +class NoShoulderSwap : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Shoulder Swap"] = [](){return new NoShoulderSwap();}; }; + const char* description() { return "While aiming, Square is disabled"; }; + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_SQUARE && event->type == TYPE_BUTTON) { + if (dualshock->getState(BUTTON_L2, TYPE_BUTTON)) { // only disable X when aiming + event->value = 0; + } + } + return true; + } +}; + +class NoReloading : public Chaos::Modifier { + bool dxLastPessed = true; + bool aimHeld = false; +public: + static void regist() { Chaos::Modifier::factory["No Reloading"] = [](){return new NoReloading();}; }; + const char* description() { return "If guns were last selected, R2 is disabled without L2"; }; + bool tweak( DeviceEvent* event ) { + if (event->id == AXIS_DX && event->type == TYPE_AXIS && event->id != 0) { + dxLastPessed = true; + } else if (event->id == AXIS_DY && event->type == TYPE_AXIS && event->id != 0) { + dxLastPessed = false; + } else if (event->id == BUTTON_L2 && event->type == TYPE_BUTTON ) { + aimHeld = event->value; + } else if (!aimHeld && event->id == BUTTON_R2 && event->type == TYPE_BUTTON && dxLastPessed) { + event->value = 0; + } + return true; + } +}; + +class DisableCircle : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Crouch/Prone"] = [](){return new DisableCircle();}; }; + const char* description() { return "Circle is disabled"; }; + void begin() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_CIRCLE && event->type == TYPE_BUTTON) { + //return false; + event->value = 0; + } + return true; + } +}; + +class ForceProne : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Keep Proning"] = [](){return new ForceProne();}; }; + const char* description() { return "Proning at inconvenient times"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + pressTime = 0; + } + void update() { + pressTime += timer.dTime(); + if ( pressTime > 2.0 && dualshock->getState(BUTTON_CIRCLE, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if( pressTime > 2.0 && !dualshock->getState(BUTTON_CIRCLE, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_CIRCLE && event->type == TYPE_BUTTON) { + //event->value = 1; + } + return true; + } +}; + +class FactionsPro : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Factions Pro"] = [](){return new FactionsPro();}; }; + const char* description() { return "Keeping things toxic with teabagging"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + pressTime = 0; + } + void update() { + pressTime += timer.dTime(); + if ( pressTime > 0.1 && dualshock->getState(BUTTON_CIRCLE, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if( pressTime > 0.7 && !dualshock->getState(BUTTON_CIRCLE, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_CIRCLE && event->type == TYPE_BUTTON) { + //event->value = 1; + } + return true; + } +}; + +class Disco : public Chaos::Modifier { + // Rename/tuning from HeHathYought +public: + static void regist() { Chaos::Modifier::factory["Anthony Caliber"] = [](){return new Disco();}; }; + const char* description() { return "Flashlight flickering"; }; + double pressTime; + int toggleCount; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_R3}; + dualshock->applyEvent(&event); + pressTime = 0; + toggleCount = 0; + } + void update() { + pressTime += timer.dTime(); + if (toggleCount < 8) { + if ( pressTime > 0.2/3.0 && dualshock->getState(BUTTON_R3, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_R3}; + dualshock->applyEvent(&event); + pressTime = 0; + toggleCount++; + } else if( pressTime > 0.26875/3.0 && !dualshock->getState(BUTTON_R3, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_R3}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } else if (pressTime > 4.0) { + toggleCount = 0; + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_R3}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + return true; + } +}; + +class KeepJumping : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Keep Jumping"] = [](){return new KeepJumping();}; }; + const char* description() { return "Repeated presses of X"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_X}; + dualshock->applyEvent(&event); + pressTime = 0; + } + void update() { + pressTime += timer.dTime(); + if ( pressTime > 0.1 && dualshock->getState(BUTTON_X, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_X}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if( pressTime > 2.0 && !dualshock->getState(BUTTON_X, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_X}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_X}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + return true; + } +}; + +class RachyFlail : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Rachy Flail"] = [](){return new RachyFlail();}; }; + const char* description() { return "The only way to melee is to follow the master techniques of RachyMonster"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_SQUARE}; + dualshock->applyEvent(&event); + pressTime = 0; + } + void update() { + pressTime += timer.dTime(); + if ( pressTime > 0.1 && dualshock->getState(BUTTON_SQUARE, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_SQUARE}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if( pressTime > 1.1 && !dualshock->getState(BUTTON_SQUARE, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_SQUARE}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_SQUARE}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + return true; + } +}; + +class KeepDodging : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Keep Dodging"] = [](){return new KeepDodging();}; }; + const char* description() { return "Repeated presses of Circle"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } + void update() { + pressTime += timer.dTime(); + if ( pressTime > 0.1 && dualshock->getState(BUTTON_L1, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if( pressTime > 2.0 && !dualshock->getState(BUTTON_L1, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + return true; + } +}; + +class PeriodicListenMode : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Periodic Listen Mode"] = [](){return new PeriodicListenMode();}; }; + const char* description() { return "Repeated holds of R1"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_R1}; + dualshock->applyEvent(&event); + pressTime = 0; + } + void update() { + pressTime += timer.dTime(); + if ( pressTime > 3.0 && dualshock->getState(BUTTON_R1, TYPE_BUTTON) ) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_R1}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if( pressTime > 8.0 && !dualshock->getState(BUTTON_R1, TYPE_BUTTON) ) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_R1}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_R1}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + return true; + } +}; + +class NoRun : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Run/Dodge"] = [](){return new NoRun();}; }; + const char* description() { return "L1 is disabled"; }; + void begin() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_L1 && event->type == TYPE_BUTTON) { + //return false; + event->value = 0; + } + return true; + } +}; + +class ForceRun : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Force Running"] = [](){return new ForceRun();}; }; + const char* description() { return "L1 is held down (mostly)"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + } + void update() { + pressTime += timer.dTime(); + if (pressTime > 4 && dualshock->getState(BUTTON_L1, TYPE_BUTTON)) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if ( pressTime > 0.1 && !dualshock->getState(BUTTON_L1, TYPE_BUTTON)) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_L1 && event->type == TYPE_BUTTON) { + event->value = 1; + } + return true; + } +}; + +class LeeroyJenkins : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Leeroy Jenkins"] = [](){return new LeeroyJenkins();}; }; + const char* description() { return "Alright let's do this! LEEEEROOOOOY NNNJEEEENNKIINNS!!!"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + event = {0,JOYSTICK_MIN,TYPE_AXIS, AXIS_LY}; + dualshock->applyEvent(&event); + } + void update() { + pressTime += timer.dTime(); + DeviceEvent event = {0,JOYSTICK_MIN,TYPE_AXIS, AXIS_LY}; + dualshock->applyEvent(&event); + if (pressTime > 4 && dualshock->getState(BUTTON_L1, TYPE_BUTTON)) { + event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if ( pressTime > 0.1 && !dualshock->getState(BUTTON_L1, TYPE_BUTTON)) { + event = {0,1,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L1}; + dualshock->applyEvent(&event); + event = {0,0,TYPE_AXIS, AXIS_LY}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_L1 && event->type == TYPE_BUTTON) { + event->value = 1; + } + if (event->id == AXIS_LY && event->type == TYPE_AXIS) { +// event->value = JOYSTICK_MIN; + return false; + } + return true; + } +}; + +class ForceAim : public Chaos::Modifier { + //Prototoxin187 +public: + static void regist() { Chaos::Modifier::factory["Force Aiming"] = [](){return new ForceAim();}; }; + const char* description() { return "L2 is held"; }; + double pressTime; + void begin() { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L2}; + dualshock->applyEvent(&event); + } + void update() { + pressTime += timer.dTime(); + if (pressTime > 4 && dualshock->getState(BUTTON_L2, TYPE_BUTTON)) { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L2}; + dualshock->applyEvent(&event); + event = {0,JOYSTICK_MIN,TYPE_AXIS, AXIS_L2}; + dualshock->applyEvent(&event); + pressTime = 0; + } else if ( pressTime > 0.1 && !dualshock->getState(BUTTON_L2, TYPE_BUTTON)) { + DeviceEvent event = {0,1,TYPE_BUTTON, BUTTON_L2}; + dualshock->applyEvent(&event); + event = {0,JOYSTICK_MAX,TYPE_AXIS, AXIS_L2}; + dualshock->applyEvent(&event); + pressTime = 0; + } + } + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON, BUTTON_L2}; + dualshock->applyEvent(&event); + event = {0,JOYSTICK_MIN,TYPE_AXIS, AXIS_L2}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if (event->id == BUTTON_L2 && event->type == TYPE_BUTTON) { + event->value = 1; + } else if (event->id == AXIS_L2 && event->type == TYPE_AXIS) { + event->value = JOYSTICK_MAX; + } + return true; + } +}; + +class DisableJoystick : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Disable Right Joystick"] = [](){return new DisableJoystick();}; }; + const char* description() { return "Good luck with aiming and looking around!"; }; + bool tweak( DeviceEvent* event ) { + if ( (event->id == AXIS_RX || event->id == AXIS_RY) && event->type == TYPE_AXIS) { + event->value = 0; + } + return true; + } +}; + +class StrafeOnly : public Chaos::Modifier { + //Prototoxin187 +public: + static void regist() { Chaos::Modifier::factory["Only Strafe Movement"] = [](){return new StrafeOnly();}; }; + const char* description() { return "X-axis on the left joystick is disabled. Only forward/back motion is allowed."; }; + bool tweak( DeviceEvent* event ) { + if ( event->id == AXIS_LY && event->type == TYPE_AXIS) { + event->value = 0; + } + return true; + } +}; + +class NoStrafe : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Strafing"] = [](){return new NoStrafe();}; }; + const char* description() { return "Y-axis on the left joystick is disabled. Only left/right motion is allowed."; }; + bool tweak( DeviceEvent* event ) { + if ( event->id == AXIS_LX && event->type == TYPE_AXIS) { + event->value = 0; + } + return true; + } +}; + +class SwapSticks : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Swap Joysticks"] = [](){return new SwapSticks();}; }; + const char* description() { return "You may want to cross your thumbs to work with your muscle memory"; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + switch (event->id) { + case AXIS_RX: event->id = AXIS_LX; break; + case AXIS_RY: event->id = AXIS_LY; break; + case AXIS_LX: event->id = AXIS_RX; break; + case AXIS_LY: event->id = AXIS_RY; break; + default: break; + } + } + return true; + } +}; + +class SwapStickDpad : public Chaos::Modifier { + //JustForSaft, joshuatimes7 +public: + static void regist() { Chaos::Modifier::factory["Swap D-Pad/Left Joystick"] = [](){return new SwapStickDpad();}; }; + const char* description() { return "Retro style motion, and an odd analog inventory selector"; }; + void begin() { + DeviceEvent event = {0,0,TYPE_AXIS, AXIS_LY}; + dualshock->applyEvent(&event); + event = {0,0,TYPE_AXIS, AXIS_LX}; + dualshock->applyEvent(&event); + } + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + switch (event->id) { + case AXIS_DX: event->id = AXIS_LX; event->value = joystickLimit(JOYSTICK_MAX*event->value); break; + case AXIS_DY: event->id = AXIS_LY; event->value = joystickLimit(JOYSTICK_MAX*event->value); break; + case AXIS_LX: + event->id = AXIS_DX; + event->value = event->value > JOYSTICK_MAX/2 ? 1 : event->value < JOYSTICK_MIN/2 ? -1 : 0; + break; + case AXIS_LY: + event->id = AXIS_DY; + event->value = event->value > JOYSTICK_MAX/2 ? 1 : event->value < JOYSTICK_MIN/2 ? -1 : 0; + break; + default: break; + } + } + return true; + } +}; + +class MotionControls : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Motion Control Movement"] = [](){return new MotionControls();}; }; + const char* description() { return "No more left joystick, tilt the controller to move instead"; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + DeviceEvent newEvent; + switch (event->id) { + case AXIS_ACCX: + newEvent = *event; + newEvent.id = AXIS_LX; + newEvent.value = joystickLimit(-event->value/20); + chaosEngine->fakePipelinedEvent(&newEvent, this); + break; + case AXIS_ACCZ: + newEvent = *event; + newEvent.id = AXIS_LY; + newEvent.value = joystickLimit(-event->value/20); + chaosEngine->fakePipelinedEvent(&newEvent, this); + break; + case AXIS_LX: return false; + case AXIS_LY: return false; + default: break; + } + } + return true; + } +}; + +class MotionControlAiming : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Motion Control Aiming"] = [](){return new MotionControlAiming();}; }; + const char* description() { return "No more right joystick, tilt the controller to aim/look instead"; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + DeviceEvent newEvent; + switch (event->id) { + case AXIS_ACCX: + newEvent = *event; + newEvent.id = AXIS_RX; + newEvent.value = joystickLimit(-event->value/24); + chaosEngine->fakePipelinedEvent(&newEvent, this); + break; + case AXIS_ACCZ: + newEvent = *event; + newEvent.id = AXIS_RY; + newEvent.value = joystickLimit(event->value/24); // This makes sense to be inverted + chaosEngine->fakePipelinedEvent(&newEvent, this); + break; + case AXIS_RX: return false; + case AXIS_RY: return false; + default: break; + } + } + return true; + } +}; + +class TouchpadAiming : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Touchpad Aiming"] = [](){return new TouchpadAiming();}; }; + const char* description() { return "No more right joystick, finally making use of the touchpad!"; }; + + short priorX[5]; + short priorY[5]; + double timestampPriorX[5]; + double timestampPriorY[5]; + bool priorActiveX; + bool priorActiveY; + + bool activeTouch; + + void begin() { + priorActiveX = false; + priorActiveY = false; + activeTouch = false; + } + + double derivativeX(short currentX, double timestampX) { + double ret = 0; + if (priorActiveX) { + if(timestampX != timestampPriorX[0]) { + ret = ((double)(currentX - priorX[0]))/(timestampX-timestampPriorX[0]); + } + } else { + priorActiveX = true; + priorX[1] = priorX[2] = priorX[3] = priorX[4] = currentX; + timestampPriorX[1] = timestampPriorX[2] = timestampPriorX[3] = timestampPriorX[4] = timestampX; + } + priorX[0] = priorX[1]; + priorX[1] = priorX[2]; + priorX[2] = priorX[3]; + priorX[3] = priorX[4]; + priorX[4] = currentX; + timestampPriorX[0] = timestampPriorX[1]; + timestampPriorX[1] = timestampPriorX[2]; + timestampPriorX[2] = timestampPriorX[3]; + timestampPriorX[3] = timestampPriorX[4]; + timestampPriorX[4] = timestampX; + return ret; + } + double derivativeY(short currentY, double timestampY) { + double ret = 0; + if (priorActiveY) { + if(timestampY != timestampPriorY[0]) { + ret = ((double)(currentY - priorY[0]))/(timestampY-timestampPriorY[0]); + } + } else { + priorActiveY = true; + priorY[1] = priorY[2] = priorY[3] = priorY[4] = currentY; + timestampPriorY[1] = timestampPriorY[2] = timestampPriorY[3] = timestampPriorY[4] = timestampY; + } + priorY[0] = priorY[1]; + priorY[1] = priorY[2]; + priorY[2] = priorY[3]; + priorY[3] = priorY[4]; + priorY[4] = currentY; + timestampPriorY[0] = timestampPriorY[1]; + timestampPriorY[1] = timestampPriorY[2]; + timestampPriorY[2] = timestampPriorY[3]; + timestampPriorY[3] = timestampPriorY[4]; + timestampPriorY[4] = timestampY; + return ret; + } + + bool tweak( DeviceEvent* event ) { + if ( event->type == TYPE_BUTTON && event->id == BUTTON_TOUCHPAD_ACTIVE) { + + //printf("Touchpad activity: %d\n", event->value); + if (activeTouch == false && event->value == false) { // rising edge + priorActiveX = false; + priorActiveY = false; + //printf("Rising Edge TOuch\n"); + } else if (activeTouch == true && event->value == true) { // falling edge + DeviceEvent newEvent; + newEvent.id = AXIS_RX; + newEvent.type = TYPE_AXIS; + newEvent.value = 0; + chaosEngine->fakePipelinedEvent(&newEvent, this); + newEvent.id = AXIS_RY; + newEvent.type = TYPE_AXIS; + newEvent.value = 0; + chaosEngine->fakePipelinedEvent(&newEvent, this); + // printf("Falling Edge TOuch\n"); + } + + activeTouch = !event->value; + } + if( event->type == TYPE_AXIS ) { + DeviceEvent newEvent; + double derivativeValue; + switch (event->id) { + case AXIS_TOUCHPAD_X: + if(activeTouch ) { + newEvent.id = AXIS_RX; + newEvent.type = TYPE_AXIS; + derivativeValue = (dualshock->getState(BUTTON_L2, TYPE_BUTTON) ? 0.04 : 0.12) * derivativeX(event->value, timer.runningTime()); + if (derivativeValue > 0) { + newEvent.value = joystickLimit(derivativeValue + 30); + } else if(derivativeValue < 0) { + newEvent.value = joystickLimit(derivativeValue - 30); + } else { + newEvent.value = 0; + } + chaosEngine->fakePipelinedEvent(&newEvent, this); + } + //printf("x derivative: %d\n", newEvent.value); + break; + case AXIS_TOUCHPAD_Y: + if(activeTouch ) { + newEvent.id = AXIS_RY; + newEvent.type = TYPE_AXIS; + derivativeValue = (dualshock->getState(BUTTON_L2, TYPE_BUTTON) ? 0.04 : 0.12) * derivativeY(event->value, timer.runningTime()); + if (derivativeValue > 0) { + newEvent.value = joystickLimit(derivativeValue + 30); + } else if(derivativeValue < 0 ) { + newEvent.value = joystickLimit(derivativeValue - 30); + } else { + newEvent.value = 0; + } + chaosEngine->fakePipelinedEvent(&newEvent, this); + } + break; + case AXIS_RX: + return false; + case AXIS_RY: + return false; + default: break; + } + } + + // This is a positional method, not very good: + // if( event->type == TYPE_AXIS ) { + // DeviceEvent newEvent; + // switch (event->id) { + // case AXIS_TOUCHPAD_X: + // newEvent = *event; + // newEvent.id = AXIS_RX; + // newEvent.value = joystickLimit(((double)event->value/1000 - 1) * JOYSTICK_MAX * 2 * 1.1 ); + // chaosEngine->fakePipelinedEvent(&newEvent, this); + // break; + // case AXIS_TOUCHPAD_Y: + // newEvent = *event; + // newEvent.id = AXIS_RY; + // newEvent.value = joystickLimit(((double)event->value/500 - 1) * JOYSTICK_MAX * 1.1 ); + // chaosEngine->fakePipelinedEvent(&newEvent, this); + // break; + // case AXIS_RX: return false; + // case AXIS_RY: return false; + // default: break; + // } + // } + return true; + } +}; + +class Nascar : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Nascar"] = [](){return new Nascar();}; }; + const char* description() { return "There is no going right in Nascar. Right movement/camera disabled"; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + if (event->id == AXIS_RX || event->id == AXIS_LX) { + event->value = event->value <= 0 ? event->value : 0; + } + } + return true; + } +}; + + +class Zoolander : public Chaos::Modifier { + // carnalgasyeah +public: + static void regist() { Chaos::Modifier::factory["Zoolander"] = [](){return new Zoolander();}; }; + const char* description() { return "We are not an ambiturner, but at least we can look right. Left movement/camera disabled."; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + if (event->id == AXIS_RX || event->id == AXIS_LX) { + event->value = event->value >= 0 ? event->value : 0; + } + } + return true; + } +}; + +class NoBackward : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Backward Movement"] = [](){return new NoBackward();}; }; + const char* description() { return "Moving backwards is not allowed"; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + if (event->id == AXIS_LY) { + event->value = event->value <= 0 ? event->value : 0; + } + } + return true; + } +}; + +class NoForward : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Forward Movement"] = [](){return new NoForward();}; }; + const char* description() { return "Moving forward is not allowed"; }; + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + if (event->id == AXIS_LY) { + event->value = event->value >= 0 ? event->value : 0; + } + } + return true; + } +}; + +class Drunk : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Drunk"] = [](){return new Drunk();}; }; + const char* description() { return "Random joystick motion. Also don't push things too far, you may stumble (go prone)"; }; + + std::map axisToValue; + std::map offsetValue; + double buttonPressTime; + + void begin() { + axisToValue[AXIS_RX] = dualshock->getState(AXIS_RX, TYPE_AXIS); + axisToValue[AXIS_RY] = dualshock->getState(AXIS_RY, TYPE_AXIS); + axisToValue[AXIS_LX] = dualshock->getState(AXIS_LX, TYPE_AXIS); + axisToValue[AXIS_LY] = dualshock->getState(AXIS_LY, TYPE_AXIS); + offsetValue[AXIS_RX] = 0; + offsetValue[AXIS_RY] = 0; + offsetValue[AXIS_LX] = 0; + offsetValue[AXIS_LY] = 0; + } + + void update() { + DeviceEvent event; // Event to inject + event.type = TYPE_AXIS; + + double i = 0.0; + double newValue; + double t = timer.runningTime()*2.0; + for (std::map::iterator it = axisToValue.begin(); it != axisToValue.end(); it++) { + event.id = it->first; + //newValue = it->second + JOYSTICK_MAX/3.0 * cos((t+i)/4.0)*sin(t*i/4.0); + //newValue = it->second + JOYSTICK_MAX/2.0 * (pow((cos(t+i) + cos(2*t)/2) * sin((t+i)*0.2), 3)/3); + offsetValue[event.id] = 78 * ( (cos(t+i) + cos(2*t)/2) * sin((t+i)*0.2)/2.0 ); + + event.value = joystickLimit(offsetValue[event.id] + it->second); + if (event.value == JOYSTICK_MIN || event.value == JOYSTICK_MAX) { + DeviceEvent fallDown = {0,1,TYPE_BUTTON,BUTTON_CIRCLE}; + dualshock->applyEvent(&fallDown); + buttonPressTime = timer.runningTime(); + } + i += 4; + + // dualshock->applyEvent(&event); + chaosEngine->fakePipelinedEvent(&event, this); + + } + if (timer.runningTime()-buttonPressTime > 1.0) { + DeviceEvent fallDown = {0,0,TYPE_BUTTON,BUTTON_CIRCLE}; + dualshock->applyEvent(&fallDown); + buttonPressTime += 10000; + } + } + + void finish() { + DeviceEvent event = {0,(short)axisToValue[AXIS_LX],TYPE_AXIS,AXIS_LX}; + chaosEngine->fakePipelinedEvent( &event, this); + event = {0,(short)axisToValue[AXIS_LY],TYPE_AXIS,AXIS_LY}; + chaosEngine->fakePipelinedEvent( &event, this); + event = {0,(short)axisToValue[AXIS_RX],TYPE_AXIS,AXIS_RX}; + chaosEngine->fakePipelinedEvent( &event, this); + event = {0,(short)axisToValue[AXIS_RY],TYPE_AXIS,AXIS_RY}; + chaosEngine->fakePipelinedEvent( &event, this); + } + + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + if (axisToValue.count(event->id) > 0) { + axisToValue[event->id] = event->value; // save the value for update() to use + event->value = joystickLimit( event->value + offsetValue[event->id] ); // apply the drunk offset + } + } + return true; + } +}; + +class SpeedrunGlitch : public Chaos::Modifier { + // HeHathYought +public: + static void regist() { Chaos::Modifier::factory["TLOU1 Run Glitch"] = [](){return new SpeedrunGlitch();}; }; + const char* description() { return "Is this an Any% speedrun of TLOU1? Rapid D-pad circular presses"; }; + + void update() { + DeviceEvent event; // Event to inject + event.type = TYPE_AXIS; + + double i = 0.0; + double newValue; + double t = timer.runningTime()*8.0*MOGI_PI; + + event.value = 1.5*cos(t); + event.id = AXIS_DX; + chaosEngine->fakePipelinedEvent( &event, this); + + event.value = 1.5*sin(t); + event.id = AXIS_DY; + chaosEngine->fakePipelinedEvent( &event, this); + + } + + void finish() { + DeviceEvent event = {0,0,TYPE_AXIS,AXIS_DX}; + chaosEngine->fakePipelinedEvent( &event, this); + event = {0,0,TYPE_AXIS,AXIS_DY}; + chaosEngine->fakePipelinedEvent( &event, this); + } + + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS && + (event->id == AXIS_DY || event->id == AXIS_DX)) { + return false; + } + return true; + } +}; + +class MegaScopeSway : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Mega Scope Sway"] = [](){ return new MegaScopeSway();}; }; + const char* description() { return "Good luck landing shots"; }; + + std::map axisToValue; + std::map offsetValue; + + void begin() { + axisToValue[AXIS_RX] = dualshock->getState(AXIS_RX, TYPE_AXIS); + axisToValue[AXIS_RY] = dualshock->getState(AXIS_RY, TYPE_AXIS); + offsetValue[AXIS_RX] = 0; + offsetValue[AXIS_RY] = 0; + } + + void update() { + DeviceEvent event; // Event to inject + event.type = TYPE_AXIS; + + bool applySway = dualshock->getState( BUTTON_L2, TYPE_BUTTON) != 0; + + double t = timer.runningTime()*3.0; + double i = 1.0; + + for (std::map::iterator it = axisToValue.begin(); it != axisToValue.end(); it++) { + event.id = it->first; + if (applySway) { + offsetValue[event.id] = sin(((t+1.6)*i )*4.0) * JOYSTICK_MAX ; + event.value = joystickLimit( it->second + offsetValue[event.id] ); + chaosEngine->fakePipelinedEvent(&event, this); + i += 1; + } else { + offsetValue[event.id] = 0; + } + + } + + } + + void finish() { + DeviceEvent event = {0,(short)axisToValue[AXIS_RX],TYPE_AXIS,AXIS_RX}; + chaosEngine->fakePipelinedEvent( &event, this); + event = {0,(short)axisToValue[AXIS_RY],TYPE_AXIS,AXIS_RY}; + chaosEngine->fakePipelinedEvent( &event, this); + } + + bool tweak( DeviceEvent* event ) { + if( event->type == TYPE_AXIS ) { + if ( axisToValue.count(event->id) > 0) { + axisToValue[event->id] = event->value; + event->value = joystickLimit( event->value + offsetValue[event->id] ); + } + } + return true; + } +}; + +class ProneDive : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Only Prone Diving"] = [](){ return new ProneDive();}; }; + const char* description() { return "RIP elbows and knees. Any movement results in a prone dive"; } + + // std::map axisToValue; + //std::map offsetValue; + double sequenceTime; + bool inSequence; + double magnitudeSquared; + + double activeThreshold; + + void begin() { + // axisToValue[AXIS_LX] = dualshock->getState(AXIS_LX, TYPE_AXIS); + // axisToValue[AXIS_LY] = dualshock->getState(AXIS_LY, TYPE_AXIS); + + sequenceTime = 0; + inSequence = false; + + activeThreshold = pow( JOYSTICK_MAX*0.2, 2); + } + + void update() { + DeviceEvent event; // Event to inject + //event.type = TYPE_AXIS; + if (!inSequence) { + magnitudeSquared = pow(dualshock->getState(AXIS_LX, TYPE_AXIS), 2) + pow(dualshock->getState(AXIS_LY, TYPE_AXIS), 2); + //printf("magnitude = %02f\n", sqrt(magnitudeSquared)); + if (magnitudeSquared > activeThreshold) { // magnitude of 9 & max 127 + inSequence = true; + } + } + + if (inSequence) { + sequenceTime += timer.dTime(); + if (sequenceTime >= 0 && + sequenceTime <= 0.1 && + dualshock->getState(BUTTON_L1, TYPE_BUTTON) == 0) { + event.id = BUTTON_L1; + event.type = TYPE_BUTTON; + event.value = 1; + dualshock->applyEvent(&event); + //printf("Dodge!\n"); + } else if (sequenceTime > 0.1 && + sequenceTime <= 0.9 && + dualshock->getState(BUTTON_CIRCLE, TYPE_BUTTON) == 0) { + event.id = BUTTON_CIRCLE; + event.type = TYPE_BUTTON; + event.value = 1; + dualshock->applyEvent(&event); + //printf("Dive!\n"); + } else if (sequenceTime > 0.9 && + sequenceTime < 1.4 && + dualshock->getState(BUTTON_CIRCLE, TYPE_BUTTON) == 1) { + event.id = BUTTON_L1; + event.type = TYPE_BUTTON; + event.value = 0; + dualshock->applyEvent(&event); + event.id = BUTTON_CIRCLE; + event.type = TYPE_BUTTON; + event.value = 0; + dualshock->applyEvent(&event); + //printf("Release!\n"); + } else if (sequenceTime > 1.4) { + inSequence = false; + sequenceTime = 0; + //printf("Done.\n"); + } + } + + //bool applySway = dualshock->getState( BUTTON_L2, TYPE_BUTTON) != 0; + + //double t = timer.runningTime()*3.0; + + + } + + void finish() { + DeviceEvent event = {0,0,TYPE_BUTTON,BUTTON_CIRCLE}; + dualshock->applyEvent(&event); + event = {0,0,TYPE_BUTTON,BUTTON_L1}; + dualshock->applyEvent(&event); + // chaosEngine->fakePipelinedEvent( &event, this); + // event = {0,(short)axisToValue[AXIS_RY],TYPE_AXIS,AXIS_RY}; + // chaosEngine->fakePipelinedEvent( &event, this); + } + + bool tweak( DeviceEvent* event ) { + // if( event->type == TYPE_AXIS ) { + // if ( axisToValue.count(event->id) > 0) { + // axisToValue[event->id] = event->value; // We only sample the left stick + // } + // } + + if ( event->type == TYPE_BUTTON) { + if (inSequence) { + return false; + } + if ( event->id == BUTTON_L1 ) { + return false; + } + if (event->id == BUTTON_CIRCLE && + magnitudeSquared > activeThreshold) { + return false; + } + } + + return true; + } +}; + +class Rubbernecking : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Rubbernecking"] = [](){ return new Rubbernecking();}; }; + const char* description() { return "Woah! What's behind you? Invokes perioding 180 quick turn"; } + + // std::map axisToValue; + //std::map offsetValue; + double sequenceTime; + bool inSequence; + double magnitudeSquared; + + // double activeThreshold; + + void begin() { + // axisToValue[AXIS_LX] = dualshock->getState(AXIS_LX, TYPE_AXIS); + // axisToValue[AXIS_LY] = dualshock->getState(AXIS_LY, TYPE_AXIS); + + sequenceTime = 0; + inSequence = false; + + // activeThreshold = pow( JOYSTICK_MAX*0.2, 2); + } + + void update() { + DeviceEvent event; // Event to inject + //event.type = TYPE_AXIS; + sequenceTime += timer.dTime(); + if (!inSequence) { + if (sequenceTime > 6) { // magnitude of 9 & max 127 + inSequence = true; + } + } + + if (inSequence) { + if (sequenceTime >= 6 && + sequenceTime <= 6.1 ) { + event.id = BUTTON_X; + event.type = TYPE_BUTTON; + event.value = 0; + dualshock->applyEvent(&event); + event.id = BUTTON_L2; // stop aiming + dualshock->applyEvent(&event); + event.id = AXIS_LY; + event.type = TYPE_AXIS; + event.value = JOYSTICK_MAX; + dualshock->applyEvent(&event); + event.id = AXIS_LX; + event.value = 0; + dualshock->applyEvent(&event); + event.id = AXIS_L2; + event.value = JOYSTICK_MIN; + dualshock->applyEvent(&event); + } else if (sequenceTime > 6.1 && + sequenceTime <= 6.2 ) { + event.id = BUTTON_X; + event.type = TYPE_BUTTON; + event.value = 1; + dualshock->applyEvent(&event); + //printf("Dive!\n"); + } else if (sequenceTime > 6.2) { + event.id = BUTTON_X; + event.type = TYPE_BUTTON; + event.value = 0; + dualshock->applyEvent(&event); + inSequence = false; + sequenceTime = 0; + //printf("Release!\n"); + } + } + } + + void finish() { + if (inSequence) { + DeviceEvent event = {0,0,TYPE_BUTTON,BUTTON_X}; + dualshock->applyEvent(&event); + event = {0,0,TYPE_BUTTON,BUTTON_L2}; + dualshock->applyEvent(&event); + event = {0,0,TYPE_AXIS,AXIS_LY}; + dualshock->applyEvent(&event); + } + // chaosEngine->fakePipelinedEvent( &event, this); + // event = {0,(short)axisToValue[AXIS_RY],TYPE_AXIS,AXIS_RY}; + // chaosEngine->fakePipelinedEvent( &event, this); + } + + bool tweak( DeviceEvent* event ) { + + if (inSequence) { + if ( event->type == TYPE_BUTTON && + (event->id == BUTTON_X || + event->id == BUTTON_L2) ){ + return false; + } + if ( event->type == TYPE_AXIS && + (event->id == AXIS_LY || + event->id == AXIS_LX || + event->id == AXIS_L2) ){ + return false; + } + } + + return true; + } +}; + +class NoGuns : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Guns"] = [](){ return new NoGuns();}; }; + const char* description() { return "D-Pad Left/Right Disabled"; }; + + void begin() { + DeviceEvent event = {0,0,TYPE_AXIS, AXIS_DX}; + dualshock->applyEvent(&event); + + Chaos::Sequence sequence; + sequence.addAxisPress( AXIS_DY, 1); // select a non-gun + sequence.send(dualshock); + } + + bool tweak( DeviceEvent* event ) { + if (event->type == TYPE_AXIS && event->id == AXIS_DX) { + return false; + } + return true; + } +}; + +class NoThrows : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Throwables"] = [](){return new NoThrows();}; }; + const char* description() { return "D-Pad Up/Down Disabled"; }; + + void begin() { + DeviceEvent event = {0,0,TYPE_AXIS, AXIS_DY}; + dualshock->applyEvent(&event); + + Chaos::Sequence sequence; + sequence.addAxisPress( AXIS_DX, 1); // select a non-gun + sequence.send(dualshock); + } + + bool tweak( DeviceEvent* event ) { + if (event->type == TYPE_AXIS && + event->id == AXIS_DY) { + return false; + } + return true; + } +}; + +class MaxSensitivity : public Chaos::Modifier { + // gabemusic +public: + static void regist() { Chaos::Modifier::factory["Max Sensitivity"] = [](){return new MaxSensitivity();}; }; + const char* description() { return "Goodbye precision aiming"; }; + + bool tweak( DeviceEvent* event ) { + if (event->type == TYPE_AXIS) { + switch (event->id) { + case AXIS_LX: + case AXIS_LY: + case AXIS_RX: + case AXIS_RY: + event->value = joystickLimit( (int)event->value * 5 ); + + default: + break; + } + } + return true; + } +}; + +class ControllerMirror : public Chaos::Modifier { + // PrincessDiodes, cloverfieldmel, DJ_Squall_808 +public: + static void regist() { Chaos::Modifier::factory["Controller Mirror"] = [](){return new ControllerMirror();}; }; + const char* description() { return "Left Joystick swapped with Right Joystick, R2 is now L2. Circle is D-Pad Left, etc."; }; + + bool tweak( DeviceEvent* event ) { + if(event->type == TYPE_AXIS) { + switch (event->id) { + case AXIS_LX: event->id = AXIS_RX; break; + case AXIS_LY: event->id = AXIS_RY; break; + case AXIS_RX: event->id = AXIS_LX; break; + case AXIS_RY: event->id = AXIS_LY; break; + case AXIS_L2: event->id = AXIS_R2; break; + case AXIS_R2: event->id = AXIS_L2; break; + case AXIS_DX: + event->type = TYPE_BUTTON; + if (event->value > 0) { + event->id = BUTTON_SQUARE; + event->value = 1; + } else if(event->value < 0) { + event->id = BUTTON_CIRCLE; + event->value = 1; + } else { + event->id = BUTTON_CIRCLE; + event->value = 0; + + + DeviceEvent event2; + event2.id = BUTTON_SQUARE; + event2.value = 0; + event2.type = TYPE_BUTTON; + dualshock->applyEvent(&event2); + } + break; + case AXIS_DY: + event->type = TYPE_BUTTON; + if (event->value > 0) { + event->id = BUTTON_X; + event->value = 1; + } else if(event->value < 0) { + event->id = BUTTON_TRIANGLE; + event->value = 1; + } else { + event->id = BUTTON_TRIANGLE; + event->value = 0; + + + DeviceEvent event2; + event2.id = BUTTON_X; + event2.value = 0; + event2.type = TYPE_BUTTON; + dualshock->applyEvent(&event2); + } + break; + default: + break; + } + return true; + } + if(event->type == TYPE_BUTTON) { + switch (event->id) { + case BUTTON_R1: event->id = BUTTON_L1; break; + case BUTTON_L1: event->id = BUTTON_R1; break; + case BUTTON_R2: event->id = BUTTON_L2; break; + case BUTTON_L2: event->id = BUTTON_R2; break; + + case BUTTON_TRIANGLE: + event->type = TYPE_AXIS; + event->value *= -1; + event->id = AXIS_DY; + break; + case BUTTON_X: + event->type = TYPE_AXIS; + event->value *= 1; + event->id = AXIS_DY; + break; + case BUTTON_SQUARE: + event->type = TYPE_AXIS; + event->value *= 1; + event->id = AXIS_DX; + break; + case BUTTON_CIRCLE: + event->type = TYPE_AXIS; + event->value *= -1; + event->id = AXIS_DX; + break; + default: + break; + } + } + + return true; + } +}; + +class ControllerFlip : public Chaos::Modifier { + // Hipsterobot +public: + static void regist() { Chaos::Modifier::factory["Controller Flip"] = [](){return new ControllerFlip();}; }; + const char* description() { return "Double joystick inverted, L1 swapped with L2, Triangle swapped with X, etc."; }; + + bool tweak( DeviceEvent* event ) { + DeviceEvent newEvent; + if(event->type == TYPE_AXIS) { + switch (event->id) { + case AXIS_DY: + case AXIS_LY: + case AXIS_RY: + event->value = joystickLimit(-event->value); + break; + case AXIS_L2: + case AXIS_R2: + return false; + default: + break; + } + return true; + } + if(event->type == TYPE_BUTTON) { + switch (event->id) { + case BUTTON_R1: + event->id = BUTTON_R2; + newEvent.id = AXIS_R2; + newEvent.type = TYPE_AXIS; + newEvent.value = event->value ? JOYSTICK_MAX : JOYSTICK_MIN; + chaosEngine->fakePipelinedEvent(&newEvent, this); + break; + case BUTTON_L1: + event->id = BUTTON_L2; + newEvent.id = AXIS_L2; + newEvent.type = TYPE_AXIS; + newEvent.value = event->value ? JOYSTICK_MAX : JOYSTICK_MIN; + chaosEngine->fakePipelinedEvent(&newEvent, this); + break; + case BUTTON_R2: event->id = BUTTON_R1; break; + case BUTTON_L2: event->id = BUTTON_L1; break; + + case BUTTON_TRIANGLE: + event->id = BUTTON_X; + break; + case BUTTON_X: + event->id = BUTTON_TRIANGLE; + break; + default: + break; + } + } + + return true; + } +}; + +/* + Main Menu Operation: + */ +class RestartCheckpoint : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Restart Checkpoint"] = [](){return new RestartCheckpoint();}; }; + const char* description() { return "Best served prior to the end of a long encounter"; }; + + bool busy; + + void begin() { + busy = true; + + Chaos::Sequence sequence; + sequence.disablejoysticks(); + sequence.addButtonPress( BUTTON_OPTIONS); + sequence.addAxisPress( AXIS_DY, -1); + sequence.addAxisPress( AXIS_DY, -1); + sequence.addButtonPress( BUTTON_X); + sequence.addAxisPress( AXIS_DX, -1); + sequence.addButtonPress( BUTTON_X); + sequence.addTimeDelay(2000); + sequence.send(dualshock); + + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +/* + HUD settings: + */ +class NoReticle : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["No Reticle"] = [](){return new NoReticle();}; }; + const char* description() { return "Headshots just got trickier"; }; + + bool busy; + + void begin() { + busy = true; + Menuing::getInstance()->selectHudMode(HUD_RETICLE, RETICLE_OFF, dualshock); + busy = false; + } + + void finish() { + busy = true; + Menuing::getInstance()->selectHudMode(HUD_RETICLE, RETICLE_SIMPLE, dualshock); + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +/* + Render Modes: + */ +class Graphic : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Graphic"] = [](){return new Graphic();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_GRAPHIC, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; +class Headache : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Headache"] = [](){return new Headache();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_HEADHACHE, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Afterlife : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Afterlife"] = [](){return new Afterlife();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_AFTERLIFE, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class EightBit : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["8-Bit"] = [](){return new EightBit();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_EIGHTBIT, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class WaterColor : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Water Color"] = [](){return new WaterColor();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_WATERCOLOR, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Dungeon : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Dungeon"] = [](){return new Dungeon();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_DUNGEON, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Void : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Void"] = [](){return new Void();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_VOID, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class PopPoster : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Pop Poster"] = [](){return new PopPoster();}; }; + const char* description() { return "Stream Destroyer. This kills the bitrate"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_POPPOSTER, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class NineteenSixty : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["1960"] = [](){return new NineteenSixty();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_NINETEENSIXTY, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Cool : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Cool"] = [](){return new Cool();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_COOL, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Warm : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Warm"] = [](){return new Warm();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_WARM, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Vibrant : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Vibrant"] = [](){return new Vibrant();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_VIBRANT, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Noir : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Noir"] = [](){return new Noir();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_NOIR, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Blorange : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Blorange"] = [](){return new Blorange();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_BLORANGE, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Sepia : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Sepia"] = [](){return new Sepia();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_SEPIA, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Vintage : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Vintage"] = [](){return new Vintage();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_VINTAGE, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Beasts : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Beasts"] = [](){return new Beasts();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_BEASTS, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Terminated : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Terminated"] = [](){return new Terminated();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_TERMINATED, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; +class GridLocked : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Gridlocked"] = [](){return new GridLocked();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_GRIDLOCKED, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Blacklight : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Blacklight"] = [](){return new Blacklight();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_BLACKLIGHT, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class DesertFog : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Desert Fog"] = [](){return new DesertFog();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_DESERT_FOG, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Blood : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Blood"] = [](){return new Blood();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_BLOOD, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Inferno : public Chaos::Modifier { // Working + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Inferno"] = [](){return new Inferno();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_INFERNO, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Fire : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Fire"] = [](){return new Fire();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_FIRE, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Trinity : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Trinity"] = [](){return new Trinity();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_TRINITY, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Pusher : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Pusher"] = [](){return new Pusher();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_PUSHER, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Demons : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Demons"] = [](){return new Demons();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_DEMONS, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class DrugZone : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Drug Zone"] = [](){return new DrugZone();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_DRUGZONE, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; +class Moonlight : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Moonlight"] = [](){return new Moonlight();}; }; + const char* description() { return "Render Mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectRenderMode(RENDER_MOONLIGHT, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownRenderMode(dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +/* + Gameplay Modes: + */ +class Mirror : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Mirror World"] = [](){return new Mirror();}; }; + const char* description() { return "Wait, where do we go?"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_MIRROR, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class MirrorOnDeath : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Mirror On Death"] = [](){return new MirrorOnDeath();}; }; + const char* description() { return "Mirror World on Death. Can result in permanent Mirror World."; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_MIRROR_ON_DEATH, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + + +class SlowMotion : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Slow Motion"] = [](){return new SlowMotion();}; }; + const char* description() { return "The speed run killer"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_SLOW_MOTION, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class BulletSpeed : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Bullet Speed"] = [](){return new BulletSpeed();}; }; + const char* description() { return "Slow motion when aiming"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_BULLET_SPEED, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class InfiniteAmmo : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Infinite Ammo"] = [](){return new InfiniteAmmo();}; }; + const char* description() { return "The strimmer responds with <3"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_INFINITE_AMMO, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class InfiniteCrafting : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Infinite Crafting"] = [](){return new InfiniteCrafting();}; }; + const char* description() { return "Molotovs for everyone!"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_INFINITE_CRAFT, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class InfiniteMeleeDurability : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Infinite Melee Durability"] = [](){return new InfiniteMeleeDurability();}; }; + const char* description() { return "Finally realistic durability"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_INFINITE_MELEE_DURABILITY, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class InfiniteListenRange : public Chaos::Modifier { // working + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Infinite Listen Range"] = [](){return new InfiniteListenRange();}; }; + const char* description() { return "There used to be a limit?"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_INFINITE_LISTEN_RANGE, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class OneShot : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["One Shot"] = [](){return new OneShot();}; }; + const char* description() { return "Golden guns activated"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_ONE_SHOT, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class TouchOfDeath : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Touch Of Death"] = [](){return new TouchOfDeath();}; }; + const char* description() { return "Golden fists activated"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_TOUCH_OF_DEATH, dualshock); + busy = false; + } + void finish() { + begin(); + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class EightBitAudio : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["8-Bit Audio"] = [](){return new EightBitAudio();}; }; + const char* description() { return "Audio mode. Incompatible with 4-bit"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_AUDIO_EIGHT_BIT, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownAudio(GAMEPLAY_AUDIO_EIGHT_BIT, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class FourBitAudio : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["4-Bit Audio"] = [](){return new FourBitAudio();}; }; + const char* description() { return "Audio mode. Incompatible with 8-bit"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_AUDIO_FOUR_BIT, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownAudio(GAMEPLAY_AUDIO_FOUR_BIT, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class HeliumAudio : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Helium Audio"] = [](){return new HeliumAudio();}; }; + const char* description() { return "Audio mode. Incompatible with Xenon"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_AUDIO_HELIUM, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownAudio(GAMEPLAY_AUDIO_HELIUM, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class XenonAudio : public Chaos::Modifier { // Working! + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Xenon Audio"] = [](){return new XenonAudio();}; }; + const char* description() { return "Audio mode. Incompatible with Helium"; }; + + void begin() { + busy = true; + Menuing::getInstance()->selectGameplayMode(GAMEPLAY_AUDIO_XENON, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->teardownAudio(GAMEPLAY_AUDIO_XENON, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class DeskPop : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Desk Pop"] = [](){return new DeskPop();}; }; + const char* description() { return "We honor the flag, and you crap on it when you don't shoot your gun https://www.youtube.com/watch?v=wWZTTtE5_zQ"; }; + + bool busy; + + void begin() { + busy = true; + + Chaos::Sequence sequence; + + sequence.addAxisPress(AXIS_DX, 1); + sequence.addTimeDelay(1000); + sequence.addButtonHold(BUTTON_L2); + sequence.addTimeDelay(1000); + sequence.addButtonHold(BUTTON_R2); + sequence.addAxisHold(AXIS_R2, JOYSTICK_MAX); + sequence.addTimeDelay(200); + sequence.addButtonRelease(BUTTON_L2); + sequence.addButtonRelease(BUTTON_R2); + sequence.addAxisHold(AXIS_R2, JOYSTICK_MIN); + + sequence.send(dualshock); + + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class TossMolly : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Toss A Molly"] = [](){return new TossMolly();}; }; + const char* description() { return "Time to riot"; }; + + bool busy; + + void begin() { + busy = true; + + Chaos::Sequence sequence; + + sequence.disablejoysticks(); + sequence.addAxisPress(AXIS_DY, 1); + sequence.addAxisPress(AXIS_DY, 1); + // sequence.addTimeDelay(1000); + // sequence.addButtonHold(BUTTON_L2); + sequence.addTimeDelay(2500); + sequence.addButtonHold(BUTTON_R2); + sequence.addTimeDelay(500); + // sequence.addButtonRelease(BUTTON_L2); + sequence.addButtonRelease(BUTTON_R2); + + sequence.send(dualshock); + + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class CtgStrat : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["CTG Strat"] = [](){return new CtgStrat();}; }; + const char* description() { return "Self immolation resulting in death, at least 7/11 times"; }; + + bool busy; + + void begin() { + busy = true; + + Chaos::Sequence sequence; + + sequence.disablejoysticks(); + sequence.addAxisHold(AXIS_RY, JOYSTICK_MAX); + sequence.addAxisHold(AXIS_RX, 0); + sequence.addAxisPress(AXIS_DY, 1); + sequence.addAxisPress(AXIS_DY, 1); + // sequence.addTimeDelay(1000); + // sequence.addButtonHold(BUTTON_L2); + sequence.addTimeDelay(2500); + sequence.addButtonHold(BUTTON_R2); + sequence.addTimeDelay(500); + // sequence.addButtonRelease(BUTTON_L2); + sequence.addButtonRelease(BUTTON_R2); + + sequence.addAxisHold(AXIS_RY, 0); + sequence.addAxisHold(AXIS_RX, 0); + + sequence.send(dualshock); + + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class PdubIt : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Pdub It"] = [](){return new PdubIt();}; }; + const char* description() { return "RIP bricks and bottles"; }; + + bool busy; + + void begin() { + busy = true; + + Chaos::Sequence sequence; + + sequence.disablejoysticks(); + sequence.addAxisPress(AXIS_DY, 1); + sequence.addTimeDelay(2500); + // sequence.addButtonHold(BUTTON_L2); + // sequence.addTimeDelay(1000); + sequence.addButtonHold(BUTTON_R2); + sequence.addTimeDelay(200); + // sequence.addButtonRelease(BUTTON_L2); + sequence.addButtonRelease(BUTTON_R2); + + sequence.send(dualshock); + + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class ChuckStun : public Chaos::Modifier { +public: + static void regist() { Chaos::Modifier::factory["Chuck Smoke Bomb"] = [](){return new ChuckStun();}; }; + const char* description() { return "It was taking up space anyway"; }; + + bool busy; + + void begin() { + busy = true; + + Chaos::Sequence sequence; + + sequence.disablejoysticks(); + sequence.addAxisPress(AXIS_DY, -1); + sequence.addAxisPress(AXIS_DY, -1); + sequence.addTimeDelay(2000); + // sequence.addButtonHold(BUTTON_L2); + // sequence.addTimeDelay(1000); + sequence.addButtonHold(BUTTON_R2); + sequence.addTimeDelay(200); + // sequence.addButtonRelease(BUTTON_L2); + sequence.addButtonRelease(BUTTON_R2); + + sequence.send(dualshock); + + busy = false; + } + + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + + +class HostagesDontEscape : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Hostages Do Not Escape"] = [](){return new HostagesDontEscape();}; }; + const char* description() { return "Hugging enemies from behind forever <3"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_HOSTAGES_DONT_ESCAPE, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_HOSTAGES_DONT_ESCAPE, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class EnemiesDontFlank : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Enemies Do Not Flank"] = [](){return new EnemiesDontFlank();}; }; + const char* description() { return "Very effective on infected"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_ENEMIES_DONT_FLANK, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_ENEMIES_DONT_FLANK, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class ReducedEnemyPerception : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Reduced Enemy Perception"] = [](){return new ReducedEnemyPerception();}; }; + const char* description() { return "Finally clickers are truly blind"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_REDUCED_ENEMY_PERCEPTION, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_REDUCED_ENEMY_PERCEPTION, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class ReducedEnemyAccuracy : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Reduced Enemy Accuracy"] = [](){return new ReducedEnemyAccuracy();}; }; + const char* description() { return "Does not work on melee"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_REDUCED_ENEMY_ACCURACY, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_REDUCED_ENEMY_ACCURACY, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class EnhancedDodge : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Enhanced Dodge"] = [](){return new EnhancedDodge();}; }; + const char* description() { return "I wish I knew what this does (built-in)"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_ENHANCED_DODGE, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_ENHANCED_DODGE, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class InvisibleWhileProne : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Invisible While Prone"] = [](){return new InvisibleWhileProne();}; }; + const char* description() { return "Proning is now even more OP"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_INVISBLE_WHILE_PRONE, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setCombatAccessibility(COMBAT_INVISBLE_WHILE_PRONE, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class LockOnAim : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Lock On Aim"] = [](){return new LockOnAim();}; }; + const char* description() { return "Aimbot... but like a detuned aimbot"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setAlternateControls(ALTERNATE_LOCK_ON_AIM, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setAlternateControls(ALTERNATE_LOCK_ON_AIM, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; +class AutoPickUp : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Auto Pick-Up"] = [](){return new AutoPickUp();}; }; + const char* description() { return "Picking up items at inconvenient times"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setAlternateControls(ALTERNATE_AUTO_PICK_UP, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setAlternateControls(ALTERNATE_AUTO_PICK_UP, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class LargeHud : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Large HUD"] = [](){return new LargeHud();}; }; + const char* description() { return "HUD like in a game from the 1990s"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setMagnificationAndAids(MAGNIFICATION_HUD_SCALE, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setMagnificationAndAids(MAGNIFICATION_HUD_SCALE, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class HighContrastDisplay : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["High Contrast Display"] = [](){return new HighContrastDisplay();}; }; + const char* description() { return "Render mode, but overrides any other render mode"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setMagnificationAndAids(MAGNIFICATION_HIGH_CONTRAST, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setMagnificationAndAids(MAGNIFICATION_HIGH_CONTRAST, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class TraversalAudioCues : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Traversal Audio Cues"] = [](){return new TraversalAudioCues();}; }; + const char* description() { return "Add some music to climbable objects"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setTtsAndAudioCues(TTS_TRAVERSAL_CUES, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setTtsAndAudioCues(TTS_TRAVERSAL_CUES, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class CombatAudioCues : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Combat Audio Cues"] = [](){return new CombatAudioCues();}; }; + const char* description() { return "Add some music to combat prompts"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setTtsAndAudioCues(TTS_COMBAT_CUES, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setTtsAndAudioCues(TTS_COMBAT_CUES, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class TraversalAssistance : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Traversal Assistance"] = [](){return new TraversalAssistance();}; }; + const char* description() { return "Climb when you really do not want to"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setNavigationAndTraversal(NAVIGATION_TRAVERSAL_ASSISTANCE, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setNavigationAndTraversal(NAVIGATION_TRAVERSAL_ASSISTANCE, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class EnhancedListenMode : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Enhanced Listen Mode"] = [](){return new EnhancedListenMode();}; }; + const char* description() { return "Press some buttons while in listen mode to find loot"; }; + + void begin() { + busy = true; + Menuing::getInstance()->setNavigationAndTraversal(NAVIGATION_ENHANCED_LISTEN_MODE, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setNavigationAndTraversal(NAVIGATION_ENHANCED_LISTEN_MODE, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class InfiniteBreath : public Chaos::Modifier { + bool busy; +public: + static void regist() { Chaos::Modifier::factory["Infinite Breath"] = [](){return new InfiniteBreath();}; }; + const char* description() { return "Yup, very useful and is the most OP perk..."; }; + + void begin() { + busy = true; + Menuing::getInstance()->setNavigationAndTraversal(NAVIGATION_INFINITE_BREATH, 1, dualshock); + busy = false; + } + void finish() { + busy = true; + Menuing::getInstance()->setNavigationAndTraversal(NAVIGATION_INFINITE_BREATH, 0, dualshock); + busy = false; + } + bool tweak( DeviceEvent* event ) { + return !busy; + } +}; + +class Mystery : public Chaos::Modifier { + // Prototoxin + bool dummy; +public: + static void regist() { + Chaos::Modifier::factory["Mystery"] = []() { + Mogi::Math::Random rng; + int selection = rng.uniform(0, Chaos::Modifier::factory.size()-1); + printf("Selection = %d out of %d\n", selection, Chaos::Modifier::factory.size()); + int count = 0; + std::map>:: iterator it; + for (it = Chaos::Modifier::factory.begin(); + it != Chaos::Modifier::factory.end(); + it++) { + count++; + if (count >= selection) { + printf("Mystery: %s\n", it->first.c_str()); + if (it->first.compare("Mystery") == 0) { + continue; + } + return it->second(); + } + } + return (--it)->second(); + //return new InfiniteBreath(); + //return new Mystery(); // will do nothing + }; + + }; + const char* description() { return "Applies any random mod"; }; +}; + + + +int main(int argc, char** argv) { + std::cout << "Welcome to Chaos" << std::endl; + + ControllerRaw dualshock; + dualshock.initialize(); + dualshock.start(); + + // Custom: + Inverted::regist(); + Moonwalk::regist(); + MeleeOnly::regist(); + NoMelee::regist(); + Pacifist::regist(); + NoTriangle::regist(); + NoClimbJump::regist(); + NoAiming::regist(); + NoScoping::regist(); + NoShoulderSwap::regist(); + NoReloading::regist(); + DisableCircle::regist(); + ForceProne::regist(); + FactionsPro::regist(); + Disco::regist(); + KeepJumping::regist(); + RachyFlail::regist(); + KeepDodging::regist(); + + PeriodicListenMode::regist(); + NoRun::regist(); + ForceRun::regist(); + DisableJoystick::regist(); + SwapSticks::regist(); + SwapStickDpad::regist(); + MotionControls::regist(); + MotionControlAiming::regist(); + TouchpadAiming::regist(); + + Nascar::regist(); + Zoolander::regist(); + NoBackward::regist(); + NoForward::regist(); + Drunk::regist(); + MegaScopeSway::regist(); + ProneDive::regist(); + Rubbernecking::regist(); + + NoGuns::regist(); + NoThrows::regist(); + MaxSensitivity::regist(); + ControllerMirror::regist(); + ControllerFlip::regist(); + + DeskPop::regist(); + TossMolly::regist(); + CtgStrat::regist(); + PdubIt::regist(); + ChuckStun::regist(); + + + // Main menu: + RestartCheckpoint::regist(); + + // HUD settings: + NoReticle::regist(); + + // Render modes: + Graphic::regist(); + Headache::regist(); + Afterlife::regist(); + EightBit::regist(); + WaterColor::regist(); + Dungeon::regist(); + Void::regist(); + PopPoster::regist(); + NineteenSixty::regist(); + Cool::regist(); + Warm::regist(); + Vibrant::regist(); + Noir::regist(); + Blorange::regist(); + Sepia::regist(); + Vintage::regist(); + Beasts::regist(); + Terminated::regist(); + GridLocked::regist(); // Working + Blacklight::regist(); + DesertFog::regist(); + Blood::regist(); + Inferno::regist(); // Working + Fire::regist(); + Trinity::regist(); + Pusher::regist(); + Demons::regist(); + DrugZone::regist(); + Moonlight::regist(); + + // Gameplay Modes: + Mirror::regist(); // Render mode + MirrorOnDeath::regist(); + SlowMotion::regist(); + BulletSpeed::regist(); + InfiniteAmmo::regist(); + InfiniteCrafting::regist(); + InfiniteMeleeDurability::regist(); + InfiniteListenRange::regist(); + OneShot::regist(); + TouchOfDeath::regist(); + + // Gameplay audio: + EightBitAudio::regist(); + FourBitAudio::regist(); + HeliumAudio::regist(); + XenonAudio::regist(); + + // Alternative Controls: + LockOnAim::regist(); + AutoPickUp::regist(); + + // Magnification: + LargeHud::regist(); + HighContrastDisplay::regist(); // Render mode + + // Navigation And Traversal + TraversalAssistance::regist(); + EnhancedListenMode::regist(); + InfiniteBreath::regist(); + + // TTS: + TraversalAudioCues::regist(); // audio + CombatAudioCues::regist(); //audio + + // Combat Accessibilities: + HostagesDontEscape::regist(); + EnemiesDontFlank::regist(); + ReducedEnemyPerception::regist(); + ReducedEnemyAccuracy::regist(); + EnhancedDodge::regist(); + InvisibleWhileProne::regist(); +// + StrafeOnly::regist(); + NoStrafe::regist(); + LeeroyJenkins::regist(); + ForceAim::regist(); + SpeedrunGlitch::regist(); + + Mystery::regist(); + + // Custom: 48 + // Audio: 6 + // Render: 31 + // Gameplay: 23 + + int i = 1; + printf("Registered Modfiers: \n"); + for (auto const& it : Chaos::Modifier::factory) { + //std::cout << "Registered Mod: " << it.first << std::endl; + printf("%3d: %s\n", i++, it.first.c_str()); + } + + Chaos::Engine chaosEngine(&dualshock); + chaosEngine.start(); + + double timePerModifier = 30.0; + chaosEngine.setTimePerModifier(timePerModifier); + + std::string reply = Chaos::Modifier::getModList(timePerModifier); + while(1) { + chaosEngine.setInterfaceReply( reply ); + usleep(10000000); + } + + return 0; +} diff --git a/examples/TLOU2/src/menuing.cpp b/examples/TLOU2/src/menuing.cpp new file mode 100644 index 0000000..8e18594 --- /dev/null +++ b/examples/TLOU2/src/menuing.cpp @@ -0,0 +1,437 @@ + +#include "menuing.h" + +using namespace Chaos; + +Menuing::Menuing() { + mainMenu = MENU_OPTIONS; + extras = EXTRA_RENDER; + render = RENDER_NONE; + gameplay = GAMEPLAY_MIRROR; + renderModesApplied = 0; + audioCrappifier = AUDIO_DEFAULT; + audioPitch = AUDIO_DEFAULT; +} + + +Menuing* Menuing::getInstance() { + static Menuing menu; + + return &menu; +} + +void Menuing::sendSequence( Controller* dualshock ) { + // send sequence + sequence.send( dualshock ); + + // destory sequence + sequence.clear(); +} + +void Menuing::selectRenderMode( int renderMode, Controller* dualshock ) { + + // build sequence + //enterMainMenu(); + //selectMainMenuItem( MENU_EXTRAS ); + //selectExtraItem( EXTRA_RENDER ); + //selectRenderMode( renderMode ); + //sequence.addButtonPress( BUTTON_OPTIONS ); + + selectExtraItem( EXTRA_RENDER ); + + sequence.addTimeDelay(MENU_SELECT_DELAY); // may another delay for render modes + + int difference = renderMode - render; + moveToMenuItem( difference ); + sequence.addButtonPress( BUTTON_X ); +// sequence.addTimeDelay(MENU_SELECT_DELAY); // + // Reset: + moveToMenuItem( -difference ); + //sequence.addButtonPress( BUTTON_X ); + + deselectExtra(); + // Reset: + //moveToMenuItem( 0 ); + //sequence.addButtonPress( BUTTON_CIRCLE ); + //selectExtraItem( 0 ); + + //sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + render = 0;//renderMode; + + renderModesApplied++; + + + + sendSequence( dualshock ); +} + +void Menuing::teardownRenderMode( Controller* dualshock ) { + renderModesApplied--; + if (renderModesApplied == 0) { + selectRenderMode( RENDER_NONE, dualshock ); + renderModesApplied = 0; + } +} + +void Menuing::teardownAudio( int whatToTeardown, Controller* dualshock ) { + if (whatToTeardown == audioPitch) { + selectGameplayMode(whatToTeardown, dualshock); + audioPitch = AUDIO_DEFAULT; + } else if (whatToTeardown == audioCrappifier) { + selectGameplayMode(whatToTeardown, dualshock); + audioCrappifier = AUDIO_DEFAULT; + } +} + +void Menuing::selectGameplayMode( int gameplayMode, Controller* dualshock ) { + + // build sequence + //enterMainMenu(); + // selectMainMenuItem( MENU_EXTRAS ); + // selectExtraItem( EXTRA_GAMEPLAY ); + // selectGameplayMode( gameplayMode ); + //sequence.addButtonPress( BUTTON_OPTIONS ); + + selectExtraItem( EXTRA_GAMEPLAY ); + + int difference = gameplayMode - gameplay; + moveToMenuItem( difference ); + sequence.addButtonPress( BUTTON_X ); + sequence.addTimeDelay(MENU_SELECT_DELAY); + + // reset: + moveToMenuItem( -difference ); + + deselectExtra(); + + // Reset: + //moveToMenuItem( 0 ); + //sequence.addButtonPress( BUTTON_CIRCLE ); + //selectExtraItem( 0 ); + + //sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + gameplay = 0;//gameplayMode; + + sendSequence( dualshock ); + + if (gameplayMode == GAMEPLAY_AUDIO_XENON || + gameplayMode == GAMEPLAY_AUDIO_HELIUM) { + audioPitch = gameplayMode; + } else if ( + gameplayMode == GAMEPLAY_AUDIO_FOUR_BIT || + gameplayMode == GAMEPLAY_AUDIO_EIGHT_BIT ) { + audioCrappifier = gameplayMode; + } +} + +void Menuing::selectHudMode( int hudOption, int option, Controller* dualshock ) { + // build sequence + //enterMainMenu(); + //selectMainMenuItem( MENU_OPTIONS ); + //selectOptionItem( OPTIONS_HUD ); + selectHudItem( hudOption ); + + if (hudOption == HUD_RETICLE) { + sequence.addAxisPress( AXIS_DX, -1); + sequence.addAxisPress( AXIS_DX, -1); + for (int i = 0; i < option; i++) { + sequence.addAxisPress( AXIS_DX, 1); + } + } + + deselectHud(); +// selectHudItem( 0 ); + + //sequence.addButtonPress( BUTTON_OPTIONS ); + + sendSequence( dualshock ); +} + +void Menuing::moveToMenuItem( int difference ) { + for (int i = 0; i < difference; i++) { + sequence.addAxisPress( AXIS_DY, 1); + } + for (int i = 0; i > difference; i--) { + sequence.addAxisPress( AXIS_DY, -1); + } +} + +void Menuing::enterMainMenu() { + sequence.disablejoysticks(); + sequence.addButtonPress( BUTTON_OPTIONS ); + sequence.addTimeDelay(MENU_SELECT_DELAY); +} + +void Menuing::selectMainMenuItem( int selection ) { + enterMainMenu(); + + int difference = selection - mainMenu + ( (numberAudioCuesEnabled > 0 && selection >= MENU_EXTRAS) ? 1 : 0 ); + moveToMenuItem( difference ); + sequence.addButtonPress( BUTTON_X ); + + sequence.addTimeDelay(MENU_SELECT_DELAY); + + mainMenu = MENU_OPTIONS;// selection; +} + +void Menuing::selectExtraItem( int selection ) { + selectMainMenuItem( MENU_EXTRAS ); + + int difference = selection - extras; + moveToMenuItem( difference ); + sequence.addButtonPress( BUTTON_X ); + sequence.addTimeDelay(MENU_SELECT_DELAY); + + extras = selection; +} + +//void Menuing::selectRenderMode( int selection ) { +// selectExtraItem( EXTRA_RENDER ); +// +// int difference = selection - render; +// moveToMenuItem( difference ); +// sequence.addButtonPress( BUTTON_X ); +// +// sequence.addButtonPress( BUTTON_OPTIONS ); // exit +// +// render = selection; +//} +// +// +//void Menuing::selectGameplayMode( int selection ) { +// selectExtraItem( EXTRA_GAMEPLAY ); +// +// int difference = selection - gameplay; +// moveToMenuItem( difference ); +// sequence.addButtonPress( BUTTON_X ); +// +// sequence.addButtonPress( BUTTON_OPTIONS ); // exit +// +// gameplay = selection; +// +//} + +void Menuing::selectOptionItem( int selection ) { + selectMainMenuItem( MENU_OPTIONS ); + + int difference = selection - options; + moveToMenuItem( difference ); + sequence.addButtonPress( BUTTON_X ); + sequence.addTimeDelay(MENU_SELECT_DELAY); + + options = selection; + +} + +void Menuing::selectHudItem( int selection ) { + selectOptionItem( OPTIONS_HUD ); + + int difference = selection - hud; + moveToMenuItem( difference ); +// sequence.addButtonPress( BUTTON_X ); + + hud = selection; + +} + + +void Menuing::selectAccessibilityItem( int item ) { + selectOptionItem( OPTIONS_ACCESSIBILITY ); + + moveToMenuItem(item - accessibility); + sequence.addButtonPress( BUTTON_X ); + + sequence.addTimeDelay(MENU_SELECT_DELAY); + + accessibility = item; +} + +void Menuing::setMagnificationAndAids( int item, bool turnOn, Controller* dualshock ) { + selectAccessibilityItem( ACCESSIBILITY_MAGNIFICATION_AND_VISUAL_AIDS ); + moveToMenuItem( item - magnification ); + + // Right now only HCD and Scale are supported, so only one press is needed + if (turnOn) { + sequence.addAxisPress( AXIS_DX, 1); + } else { + sequence.addAxisPress( AXIS_DX, -1); + sequence.addAxisPress( AXIS_DX, -1); + } + + moveToMenuItem( -(item - magnification) ); + deselectAccessibility(); + //sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + this->magnification = 0;//item; + + sendSequence( dualshock ); +} + +void Menuing::setAlternateControls( int item, bool turnOn, Controller* dualshock ) { + selectAccessibilityItem( ACCESSIBILITY_ALTERNATE_CONTROLS ); + moveToMenuItem( item - alternateControls ); + + if (turnOn) { + sequence.addAxisPress( AXIS_DX, 1); + sequence.addAxisPress( AXIS_DX, 1); + } else { + sequence.addAxisPress( AXIS_DX, -1); + sequence.addAxisPress( AXIS_DX, -1); + } + + moveToMenuItem( -(item - alternateControls) ); + deselectAccessibility(); +// sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + this->alternateControls = 0;//item; + + sendSequence( dualshock ); +} + +void Menuing::setNavigationAndTraversal( int item, bool turnOn, Controller* dualshock ) { + selectAccessibilityItem( ACCESSIBILITY_NAVIGATION_AND_TRAVERSAL ); + + moveToMenuItem( item - navigation ); + + if (turnOn) { + sequence.addAxisPress( AXIS_DX, 1); + } else { + sequence.addAxisPress( AXIS_DX, -1); + } + + moveToMenuItem( -(item - navigation) ); + deselectAccessibility(); + //sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + this->navigation = 0;//item; + + sendSequence( dualshock ); + +} + +void Menuing::setTtsAndAudioCues( int item, bool turnOn, Controller* dualshock ) { + selectAccessibilityItem( ACCESSIBILITY_TTS_AND_AUDIO_CUES ); + + moveToMenuItem( item - tts ); + + if (turnOn) { + sequence.addAxisPress( AXIS_DX, 1); + numberAudioCuesEnabled++; + } else { + numberAudioCuesEnabled--; + sequence.addAxisPress( AXIS_DX, -1); + } + + moveToMenuItem( -(item - tts) ); + deselectAccessibility(); + //sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + this->tts = 0;//item; + + sendSequence( dualshock ); + +} + +void Menuing::setCombatAccessibility( int item, bool turnOn, Controller* dualshock ) { + selectAccessibilityItem( ACCESSIBILITY_COMBAT_ACCESSIBILITY ); + + moveToMenuItem( item - combat ); + + // All combat accessibilities have either 1 or 2 options, pressing right enables them + if (turnOn) { + sequence.addAxisPress( AXIS_DX, 1); + sequence.addAxisPress( AXIS_DX, 1); + } else { + sequence.addAxisPress( AXIS_DX, -1); + sequence.addAxisPress( AXIS_DX, -1); + } + +// this->combat = item; + moveToMenuItem( -(item - combat) ); + deselectAccessibility(); + //sequence.addButtonPress( BUTTON_OPTIONS ); // exit + + this->combat = 0; + + sendSequence( dualshock ); + +} + +void Menuing::exitMainMenu() { +// sequence.addButtonPress( BUTTON_CIRCLE ); // no need fo rhtis here since it's not peristent +// sequence.addTimeDelay(MENU_SELECT_DELAY); + + sequence.addTimeDelay(MENU_SELECT_DELAY); + sequence.addButtonPress( BUTTON_OPTIONS ); + sequence.addTimeDelay(MENU_SELECT_DELAY); + //sequence.addTimeDelay(MENU_SELECT_DELAY); +} + +void Menuing::deselectMainMenu() { +// sequence.addButtonPress( BUTTON_CIRCLE ); +// sequence.addTimeDelay(MENU_SELECT_DELAY); +// +// int selection = 0; +// int difference = selection - mainMenu + ( (numberAudioCuesEnabled > 0 && selection >= MENU_EXTRAS) ? 1 : 0 ); +// moveToMenuItem( difference ); +// +// mainMenu = MENU_OPTIONS;// selection; + sequence.addTimeDelay(MENU_SELECT_DELAY); + exitMainMenu(); +} + + + +void Menuing::deselectExtra() { + sequence.addButtonPress( BUTTON_CIRCLE ); + sequence.addTimeDelay(MENU_SELECT_DELAY); + +// selectMainMenuItem( MENU_EXTRAS ); + + int selection = 0; + int difference = selection - extras; + moveToMenuItem( difference ); + + deselectMainMenu(); + + extras = selection; +} + +void Menuing::deselectOption() { + sequence.addButtonPress( BUTTON_CIRCLE ); + sequence.addTimeDelay(MENU_SELECT_DELAY); + + int selection = 0; +// int difference = selection - options; + moveToMenuItem( selection - options ); + + options = selection; + + deselectMainMenu( ); +} + +void Menuing::deselectHud() { + int selection = 0; + moveToMenuItem( selection - hud ); + hud = selection; + + deselectOption(); + +// sequence.addButtonPress( BUTTON_X ); + + + +} + +void Menuing::deselectAccessibility() { + sequence.addButtonPress( BUTTON_CIRCLE ); // + sequence.addTimeDelay(MENU_SELECT_DELAY); + + int item = 0; + moveToMenuItem(item - accessibility); + accessibility = item; + + deselectOption(); +} diff --git a/include/chaos-uhid.h b/include/chaos-uhid.h index 33c797d..8a07050 100644 --- a/include/chaos-uhid.h +++ b/include/chaos-uhid.h @@ -17,6 +17,10 @@ #include "deviceTypes.h" // This follows: https://github.com/torvalds/linux/blob/master/samples/uhid/uhid-example.c +namespace Chaos { + + + class ChaosUhid : public Mogi::Thread { private: int fd; @@ -36,4 +40,6 @@ class ChaosUhid : public Mogi::Thread { void sendUpdate(void* data); }; +}; + #endif diff --git a/include/chaos.h b/include/chaos.h index cf511bc..0f4394c 100644 --- a/include/chaos.h +++ b/include/chaos.h @@ -1,298 +1,24 @@ #ifndef CHAOS_H #define CHAOS_H -#include +//#include #include -#include +//#include #include #include -#include -#include -#include +//#include +//#include +//#include #include #include "interface.h" // for CommandListener #include "controller.h" -//#define TIME_PER_MODIFIER (30) +#include "modifier.h" -#define TIME_AFTER_JOYSTICK_DISABLE ((unsigned int)(1000000/3)) // in us -//#define TIME_PER_BUTTON_PRESS (50000) // in us -//#define TIME_PER_BUTTON_RELEASE (50000) // in us -#define TIME_PER_BUTTON_PRESS ((unsigned int)(50000*1.25)) // in us -#define TIME_PER_BUTTON_RELEASE ((unsigned int)(50000*1.25)) // in us -#define MENU_SELECT_DELAY ((unsigned int)(50)) // in ms +namespace Chaos { -enum OptionsMainMenu { - MENU_OPTIONS = 0, - MENU_PHOTOMODE = 1, - MENU_EXTRAS = 2, - MENU_TUTORIALS = 3, - MENU_SAVE = 4, - MENU_LOAD = 5, - MENU_RESTART1 = -3, - MENU_RESTART2 = -2, - MENU_QUIT = -1 -}; - -enum OptionsOptions { - OPTIONS_DIFFICULTY = 0, - OPTIONS_CONTROLS = 1, - OPTIONS_HUD = 2, - OPTIONS_ACCESSIBILITY = -1, -}; - -enum OptionsHUD { - HUD_RETICLE = 0, - HUD_WEAPON_CROSS_DISABLE = 1 -}; - -enum OptionsExtras { - EXTRA_RENDER = 0, - EXTRA_GAMEPLAY = 1 -}; - -enum OptionsRender { - RENDER_NONE = 0, - RENDER_GRAPHIC = 1, - RENDER_HEADHACHE = 2, - RENDER_AFTERLIFE = 3, - RENDER_EIGHTBIT = 4, - RENDER_WATERCOLOR = 5, - RENDER_DUNGEON = 6, - RENDER_VOID = 7, - RENDER_POPPOSTER = 8, - RENDER_NINETEENSIXTY = 9, - RENDER_COOL = 10, - RENDER_WARM = 11, - RENDER_VIBRANT = 12, - RENDER_NOIR = 13, - RENDER_BLORANGE = 14, - RENDER_SEPIA = 15, - RENDER_VINTAGE = -14, - RENDER_BEASTS = -13, - RENDER_TERMINATED = -12, - RENDER_GRIDLOCKED = -11, - RENDER_BLACKLIGHT = -10, - RENDER_DESERT_FOG = -9, - RENDER_BLOOD = -8, - RENDER_INFERNO = -7, - RENDER_FIRE = -6, - RENDER_TRINITY = -5, - RENDER_PUSHER = -4, - RENDER_DEMONS = -3, - RENDER_DRUGZONE = -2, - RENDER_MOONLIGHT = -1, -}; - -enum OptionsGameplay { - GAMEPLAY_MIRROR = 0, - GAMEPLAY_MIRROR_ON_DEATH = 1, - GAMEPLAY_SLOW_MOTION = 2, - GAMEPLAY_BULLET_SPEED = 3, - GAMEPLAY_INFINITE_AMMO = 4, - GAMEPLAY_INFINITE_CRAFT = 5, - GAMEPLAY_INFINITE_MELEE_DURABILITY = 6, - GAMEPLAY_INFINITE_LISTEN_RANGE = 7, -// GAMEPLAY_INFINITE_MELEE = 8, // ???? - GAMEPLAY_ONE_SHOT = -6, - GAMEPLAY_TOUCH_OF_DEATH = -5, - GAMEPLAY_AUDIO_EIGHT_BIT = -4, - GAMEPLAY_AUDIO_FOUR_BIT = -3, - GAMEPLAY_AUDIO_HELIUM = -2, - GAMEPLAY_AUDIO_XENON = -1, -}; - -enum ReticleOptions { - RETICLE_OFF = 0, - RETICLE_SIMPLE = 1, - RETICLE_DEFAULT = 2 -}; - -enum OptionsAccessibility { // options/accessibility - ACCESSIBILITY_ALTERNATE_CONTROLS = 0, - ACCESSIBILITY_MAGNIFICATION_AND_VISUAL_AIDS = 1, - ACCESSIBILITY_MOTION_SICKNESS = 2, - ACCESSIBILITY_NAVIGATION_AND_TRAVERSAL = 3, - ACCESSIBILITY_TTS_AND_AUDIO_CUES = -2, - ACCESSIBILITY_COMBAT_ACCESSIBILITY = -1, -}; - -enum OptionsAternateControls { // options/accessibility/alternate controls - ALTERNATE_CUSTOMIZE_CONTROLS = 0, - ALTERNATE_LOCK_ON_AIM = -6, - ALTERNATE_AUTO_PICK_UP = -1 -}; - -enum OptionsMagnificationAndAids { // options/accessibility/Magnification - MAGNIFICATION_HUD_SCALE = 0, // for larger HUD - MAGNIFICATION_HIGH_CONTRAST = -3, -}; - -enum OptionsNavigation { // options/accessibility/Navigation - NAVIGATION_ASSISTANCE = 0, - NAVIGATION_TRAVERSAL_ASSISTANCE = 1, - NAVIGATION_LEDGE_GUARD = 2, - NAVIGATION_ENHANCED_LISTEN_MODE = 3, - NAVIGATION_SCAN_RANGE = 4, - NAVIGATION_SCAN_TIME = -3, - NAVIGATION_INFINITE_BREATH = -2, - NAVIGATION_SKIP_PUZZLE = -1 -}; - -enum OptionsTTS { // options/accessibility/TTS - TTS_TTS = 0, - TTS_TRAVERSAL_CUES = 1, - TTS_COMBAT_CUES = 2 -}; - -enum OptionsCombat { // options/accessibility/Combat - COMBAT_ENABLE = 0, - COMBAT_HOSTAGES_DONT_ESCAPE = 1, - COMBAT_ALLIES_DONT_GET_GRABBED = 2, - COMBAT_ENEMIES_DONT_FLANK = 3, - COMBAT_REDUCED_ENEMY_PERCEPTION = 4, - COMBAT_REDUCED_ENEMY_ACCURACY = 5, - COMBAT_ENHANCED_DODGE = -4, - COMBAT_INVISBLE_WHILE_PRONE = -3, // use d-pad, right twitce to sleect - COMBAT_WEAPON_SWAY = -2, - COMBAT_SLOW_MOTION = -1 // d-pad, but cannot use this. have slowmo elsewhere -}; - - - - - -class Sequence { -private: - std::vector events; - -public: - Sequence(); - void disablejoysticks(); // Needed for proper menuing, probably - void addButtonPress( ButtonID id ); - void addButtonHold( ButtonID id ); - void addButtonRelease( ButtonID id ); - void addTimeDelay( unsigned int timeInMilliseconds ); - void addAxisPress( AxisID id, short value ); - void addAxisHold( AxisID id, short value ); - void send(Controller* dualshock); - - void clear(); - // For building a sequence: - //void changeMenuOption(); -}; - -class Menuing { -private: - Menuing(); - - Sequence sequence; - - int mainMenu; - int extras; - int render; - int gameplay; - int options; - int hud; - - int accessibility = ACCESSIBILITY_ALTERNATE_CONTROLS; - int alternateControls = ALTERNATE_CUSTOMIZE_CONTROLS; - int magnification = MAGNIFICATION_HUD_SCALE; - int navigation = NAVIGATION_ASSISTANCE; - int tts = TTS_TTS; - int numberAudioCuesEnabled = 0; - int combat = COMBAT_ENABLE; - -#define AUDIO_DEFAULT (0) -#define AUDIO_FOUR_BIT (1) -#define AUDIO_EIGHT_BIT (2) -#define AUDIO_HELIUM (3) -#define AUDIO_XENON (4) - - int audioCrappifier; - int audioPitch; - - int renderModesApplied; - - void moveToMenuItem( int difference ); - - void enterMainMenu(); - void exitMainMenu(); - void selectMainMenuItem( int selection ); - void deselectMainMenu(); - - void sendSequence( Controller* dualshock ); - - // Options: - void selectExtraItem( int selection ); - void deselectExtra(); - //void selectRenderMode( int selection ); - //void selectGameplayMode( int selection ); - - void selectOptionItem( int selection ); // HUD, ACCESSIBILITIES - void deselectOption(); - void selectHudItem( int selection ); - void deselectHud(); - - void selectAccessibilityItem( int item ); - void deselectAccessibility(); - // void setCombatAccessibility( int item, bool onOrOff ); - -public: - static Menuing* getInstance(); - - void selectRenderMode( int renderMode, Controller* dualshock ); - void teardownRenderMode( Controller* dualshock ); - void teardownAudio( int whatToTeardown, Controller* dualshock ); - void selectGameplayMode( int gameplayMode, Controller* dualshock ); - void selectHudMode( int hudOption, int option, Controller* dualshock ); - - - void setAlternateControls( int item, bool enable, Controller* dualshock ); - void setMagnificationAndAids( int item, bool enable, Controller* dualshock ); - void setNavigationAndTraversal( int item, bool enable, Controller* dualshock ); - void setTtsAndAudioCues( int item, bool enable, Controller* dualshock ); - void setCombatAccessibility( int item, bool enable, Controller* dualshock ); -}; - - -class ChaosEngine; - -class Modifier { -friend ChaosEngine; -protected: - Modifier(); - - Mogi::Math::Time timer; - Controller* dualshock; - ChaosEngine* chaosEngine; - - double pauseTimeAccumulator; - - void _update(bool isPaused); // ChaosEngine call this, which then calls virtual update(); - -public: - - static std::map> factory; - static Modifier* build( const std::string& name ); - static std::string getModList( double timePerModifier ); - - void setDualshock(Controller* dualshock); - void setChaosEngine(ChaosEngine* chaosEngine); - - virtual void begin(); // called when first instantiated - virtual void update(); // called regularly - virtual void finish(); // called just - virtual const char* description(); // A short description of this mod, for Twitch bot response - - double lifetime(); - - virtual bool tweak( DeviceEvent* event ); -}; - - -class ChaosEngine : public CommandListenerObserver, public ControllerInjector, public Mogi::Thread { +class Engine : public CommandListenerObserver, public ControllerInjector, public Mogi::Thread { private: ChaosInterface chaosInterface; Controller* dualshock; @@ -315,12 +41,13 @@ class ChaosEngine : public CommandListenerObserver, public ControllerInjector, p void doAction(); // override from Mogi::Thread public: - ChaosEngine(Controller* dualshock); + Engine(Controller* dualshock); void setInterfaceReply(const std::string& reply); void setTimePerModifier(double time); void fakePipelinedEvent(DeviceEvent* fakeEvent, Modifier* modifierThatSentTheFakeEvent); }; +}; #endif diff --git a/include/controller-state.h b/include/controller-state.h index 0ba0cff..117eaae 100644 --- a/include/controller-state.h +++ b/include/controller-state.h @@ -6,6 +6,10 @@ #include "deviceTypes.h" +namespace Chaos { + + + // Helper functions for raw interpretation: short int unpackJoystick(uint8_t& input); uint8_t packJoystick(short int& input); @@ -76,4 +80,6 @@ friend ControllerState; ~ControllerStateDualshock(); }; +}; + #endif diff --git a/include/controller.h b/include/controller.h index 5dde7e4..3a4c519 100644 --- a/include/controller.h +++ b/include/controller.h @@ -13,6 +13,10 @@ #define PWM_RANGE (11) +namespace Chaos { + + + #ifdef __APPLE__ // Dummy functions just so I can compile crap on a non-pi void wiringPiSetup() {} @@ -156,7 +160,7 @@ class ControllerRaw : public Controller, public EndpointObserver, public Mogi::T }; - +}; #endif diff --git a/include/device.h b/include/device.h index f065f79..157a0f8 100644 --- a/include/device.h +++ b/include/device.h @@ -9,6 +9,10 @@ // Classes +namespace Chaos { + + + class DeviceObserver { public: virtual void newDeviceEvent( const DeviceEvent* event ) = 0; @@ -68,4 +72,6 @@ class Mouse : public DeviceHID { void open(const char* filename); }; +}; + #endif diff --git a/include/deviceTypes.h b/include/deviceTypes.h index 2e7bbc3..2172bc4 100644 --- a/include/deviceTypes.h +++ b/include/deviceTypes.h @@ -2,6 +2,10 @@ #define DEVICETYPES_H +namespace Chaos { + + + // This is for the PS4: typedef enum ButtonID { BUTTON_X = 0, @@ -112,5 +116,6 @@ typedef struct DeviceEvent { } } DeviceEvent; +}; #endif diff --git a/include/interface.h b/include/interface.h index b1d4673..b649e16 100644 --- a/include/interface.h +++ b/include/interface.h @@ -5,6 +5,8 @@ #include #include +namespace Chaos { + class CommandListenerObserver { public: @@ -66,4 +68,6 @@ class ChaosInterface : public Mogi::Thread { void addObserver( CommandListenerObserver* observer ); }; +}; + #endif diff --git a/include/modifier.h b/include/modifier.h new file mode 100644 index 0000000..fc01973 --- /dev/null +++ b/include/modifier.h @@ -0,0 +1,50 @@ +#ifndef MODIFIER_H +#define MODIFIER_H + +#include + +#include +#include + +#include "controller.h" + +namespace Chaos { + + +class Engine; + +class Modifier { +friend Engine; +protected: + Modifier(); + + Mogi::Math::Time timer; + Controller* dualshock; + Engine* chaosEngine; + + double pauseTimeAccumulator; + + void _update(bool isPaused); // ChaosEngine call this, which then calls virtual update(); + +public: + + static std::map> factory; + static Modifier* build( const std::string& name ); + static std::string getModList( double timePerModifier ); + + void setDualshock(Controller* dualshock); + void setChaosEngine(Engine* chaosEngine); + + virtual void begin(); // called when first instantiated + virtual void update(); // called regularly + virtual void finish(); // called just + virtual const char* description(); // A short description of this mod, for Twitch bot response + + double lifetime(); + + virtual bool tweak( DeviceEvent* event ); +}; + +}; + +#endif diff --git a/include/sequence.h b/include/sequence.h new file mode 100644 index 0000000..667f69c --- /dev/null +++ b/include/sequence.h @@ -0,0 +1,41 @@ +#ifndef SEQUENCE_H +#define SEQUENCE_H + +#include + +#include "controller.h" + +//#define TIME_PER_MODIFIER (30) + +#define TIME_AFTER_JOYSTICK_DISABLE ((unsigned int)(1000000/3)) // in us +//#define TIME_PER_BUTTON_PRESS (50000) // in us +//#define TIME_PER_BUTTON_RELEASE (50000) // in us +#define TIME_PER_BUTTON_PRESS ((unsigned int)(50000*1.25)) // in us +#define TIME_PER_BUTTON_RELEASE ((unsigned int)(50000*1.25)) // in us +#define MENU_SELECT_DELAY ((unsigned int)(50)) // in ms + +namespace Chaos { + +class Sequence { +private: + std::vector events; + +public: + Sequence(); + void disablejoysticks(); // Needed for proper menuing, probably + void addButtonPress( ButtonID id ); + void addButtonHold( ButtonID id ); + void addButtonRelease( ButtonID id ); + void addTimeDelay( unsigned int timeInMilliseconds ); + void addAxisPress( AxisID id, short value ); + void addAxisHold( AxisID id, short value ); + void send(Controller* dualshock); + + void clear(); + // For building a sequence: + //void changeMenuOption(); +}; + +}; + +#endif diff --git a/scripts/chaos.service b/scripts/chaos.service index 73171fa..b7e1350 100755 --- a/scripts/chaos.service +++ b/scripts/chaos.service @@ -7,7 +7,6 @@ Type=simple Restart=always RestartSec=1 ExecStart=/bin/bash /home/pi/chaos/start.sh -#ExecStart=/home/pi/chaos2/build/chaos [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/src/chaos-uhid.cpp b/src/chaos-uhid.cpp index 7c1b45f..92c9b8f 100644 --- a/src/chaos-uhid.cpp +++ b/src/chaos-uhid.cpp @@ -1,6 +1,8 @@ #include "chaos-uhid.h" +using namespace Chaos; + static __u8 rdesc[] = { 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x05, // Usage (Game Pad) diff --git a/src/chaosEngine.cpp b/src/chaosEngine.cpp index 871963f..fddf815 100644 --- a/src/chaosEngine.cpp +++ b/src/chaosEngine.cpp @@ -7,7 +7,9 @@ #include #include -ChaosEngine::ChaosEngine(Controller* dualshock) +using namespace Chaos; + +Engine::Engine(Controller* dualshock) : dualshock(dualshock), timePerModifier(30.0), pause(true) { dualshock->addInjector(this); @@ -18,8 +20,8 @@ ChaosEngine::ChaosEngine(Controller* dualshock) //pthread_mutex_init(&chaosMutex, NULL); } -void ChaosEngine::newCommand(const std::string& command) { - std::cout << "ChaosEngine::newCommand() received: " << command << std::endl; +void Engine::newCommand(const std::string& command) { + std::cout << "Chaos::Engine::newCommand() received: " << command << std::endl; Json::Value root; Json::CharReaderBuilder builder; @@ -63,7 +65,7 @@ void ChaosEngine::newCommand(const std::string& command) { } -void ChaosEngine::doAction() { +void Engine::doAction() { usleep(500); // 200Hz // Update timers/states of modifiers @@ -110,7 +112,7 @@ void ChaosEngine::doAction() { } -bool ChaosEngine::sniffify(const DeviceEvent* input, DeviceEvent* output) { +bool Engine::sniffify(const DeviceEvent* input, DeviceEvent* output) { *output = *input; bool valid = true; @@ -177,7 +179,7 @@ bool ChaosEngine::sniffify(const DeviceEvent* input, DeviceEvent* output) { return valid; } -void ChaosEngine::fakePipelinedEvent(DeviceEvent* fakeEvent, Modifier* modifierThatSentTheFakeEvent) { +void Engine::fakePipelinedEvent(DeviceEvent* fakeEvent, Modifier* modifierThatSentTheFakeEvent) { bool valid = true; if (!pause) { @@ -197,11 +199,11 @@ void ChaosEngine::fakePipelinedEvent(DeviceEvent* fakeEvent, Modifier* modifierT } } -void ChaosEngine::setInterfaceReply(const std::string& reply) { +void Engine::setInterfaceReply(const std::string& reply) { // commandListener.setReply(reply); chaosInterface.sendMessage(reply); } -void ChaosEngine::setTimePerModifier(double time) { +void Engine::setTimePerModifier(double time) { timePerModifier = time; } diff --git a/src/command-listener.cpp b/src/command-listener.cpp index 3dcea16..2e85971 100644 --- a/src/command-listener.cpp +++ b/src/command-listener.cpp @@ -6,6 +6,7 @@ #include #include +using namespace Chaos; CommandListener::CommandListener() { const std::string endpoint = "tcp://*:5555"; diff --git a/src/command-sender.cpp b/src/command-sender.cpp index 3d7a0f8..0532172 100644 --- a/src/command-sender.cpp +++ b/src/command-sender.cpp @@ -6,6 +6,8 @@ //#include //#include +using namespace Chaos; + CommandSender::CommandSender() { // printf("Constructing CommandSender()\n"); const std::string endpoint = "tcp://localhost:5556"; diff --git a/src/controller-gpio.cpp b/src/controller-gpio.cpp index 0b8919a..d319ac3 100644 --- a/src/controller-gpio.cpp +++ b/src/controller-gpio.cpp @@ -7,15 +7,17 @@ #include -void functionAxis(int* pins, int value, double calibration) { +using namespace Chaos; + +void Chaos::functionAxis(int* pins, int value, double calibration) { //softPwmWrite (pins[0], PWM_RANGE * (calibration*(double)value/65535.0 + 0.5) ); // deprecated } -void functionButton(int* pins, int value, double calibration) { +void Chaos::functionButton(int* pins, int value, double calibration) { //digitalWrite( pins[0], calibration > 0 ? value : !value ); // deprecated } -void functionDpad(int* pins, int value, double calibration) { +void Chaos::functionDpad(int* pins, int value, double calibration) { value *= calibration; /* // deprecated diff --git a/src/controller-raw.cpp b/src/controller-raw.cpp index 847e1a2..46a7aea 100644 --- a/src/controller-raw.cpp +++ b/src/controller-raw.cpp @@ -2,6 +2,8 @@ #include +using namespace Chaos; + bool ControllerRaw::applyHardware(const DeviceEvent* event) { // State will already be stored, nothing to be done for raw // if (spooferFile) { diff --git a/src/controller-state-dualsense.cpp b/src/controller-state-dualsense.cpp index d0fe97e..f5d2508 100644 --- a/src/controller-state-dualsense.cpp +++ b/src/controller-state-dualsense.cpp @@ -2,14 +2,16 @@ #include "ps5-generated.h" -short int unpackJoystick(uint8_t& input) { +using namespace Chaos; + +short int Chaos::unpackJoystick(uint8_t& input) { return ((short int)input)-128; } -uint8_t packJoystick(short int& input) { +uint8_t Chaos::packJoystick(short int& input) { return input+128; } -short int fixShort(short int input) { +short int Chaos::fixShort(short int input) { return input; // return ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); } @@ -18,7 +20,7 @@ short int fixShort(short int input) { //} -short int positionDY( const uint8_t& input ) { +short int Chaos::positionDY( const uint8_t& input ) { if (input == 0x08) { return 0; } if (input <= 1 || input == 7) { @@ -28,7 +30,7 @@ short int positionDY( const uint8_t& input ) { } return 0; } -short int positionDX( const uint8_t& input ) { +short int Chaos::positionDX( const uint8_t& input ) { if (input == 0x08) { return 0; } if (input >= 1 && input <= 3) { @@ -39,7 +41,7 @@ short int positionDX( const uint8_t& input ) { return 0; } -uint8_t packDpad( const short int& dx, const short int& dy ) { +uint8_t Chaos::packDpad( const short int& dx, const short int& dy ) { switch (dx) { case -1: return 6-dy; diff --git a/src/controller-state-dualshock.cpp b/src/controller-state-dualshock.cpp index 639f979..dca5553 100644 --- a/src/controller-state-dualshock.cpp +++ b/src/controller-state-dualshock.cpp @@ -2,6 +2,7 @@ #include "ps4-generated.h" +using namespace Chaos; ControllerStateDualshock::ControllerStateDualshock() { stateLength = sizeof(inputReport01_t); diff --git a/src/controller-state.cpp b/src/controller-state.cpp index 8f45575..425e960 100644 --- a/src/controller-state.cpp +++ b/src/controller-state.cpp @@ -2,6 +2,8 @@ #include +using namespace Chaos; + ControllerState::~ControllerState() { } diff --git a/src/controller.cpp b/src/controller.cpp index b87a4a1..e195d50 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -3,6 +3,8 @@ #include +using namespace Chaos; + Controller::Controller() { memset(controllerState, 0, sizeof(controllerState)); } diff --git a/src/device.cpp b/src/device.cpp index f224ca0..14bd5a8 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -4,6 +4,8 @@ #include #include +using namespace Chaos; + void Device::init(const char* filename, int bytesPerFrame) { file = fopen( filename, "r" ); diff --git a/src/interface.cpp b/src/interface.cpp index 61f0c46..2258f2c 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -6,6 +6,7 @@ #include #include +using namespace Chaos; ChaosInterface::ChaosInterface() { listener.start(); diff --git a/src/joystick.cpp b/src/joystick.cpp index 655d18c..36fc98e 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -3,6 +3,8 @@ #include // for memcpy +using namespace Chaos; + void Joystick::open(const char* filename) { init(filename, 8); } diff --git a/src/modifier.cpp b/src/modifier.cpp index 9926ec3..0fc70ae 100644 --- a/src/modifier.cpp +++ b/src/modifier.cpp @@ -1,11 +1,13 @@ -#include "chaos.h" +#include "modifier.h" #include #include #include #include +using namespace Chaos; + Modifier::Modifier() { this->timer.initialize(); pauseTimeAccumulator = 0; @@ -15,7 +17,7 @@ void Modifier::setDualshock(Controller* dualshock) { this->dualshock = dualshock; } -void Modifier::setChaosEngine(ChaosEngine* chaosEngine) { +void Modifier::setChaosEngine(Engine* chaosEngine) { this->chaosEngine = chaosEngine; } diff --git a/src/mouse.cpp b/src/mouse.cpp index 922fc62..d092e33 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -1,6 +1,8 @@ #include "device.h" +using namespace Chaos; + void Mouse::open(const char* filename) { init(filename, 3); } diff --git a/src/sequence.cpp b/src/sequence.cpp index 0f42673..2f2c308 100644 --- a/src/sequence.cpp +++ b/src/sequence.cpp @@ -1,7 +1,9 @@ -#include "chaos.h" +#include "sequence.h" #include +using namespace Chaos; + Sequence::Sequence() { } diff --git a/start.sh b/start.sh index d441db5..fb00c8e 100755 --- a/start.sh +++ b/start.sh @@ -8,7 +8,7 @@ cd /home/pi/chaos/raw-gadget-timeout/raw_gadget #while true; #do - /home/pi/chaos/build/chaos + /home/pi/chaos/build/examples/TLOU2/tlou2 #done echo "Done."