#ifndef PROPS_MULTI_PROP_H #define PROPS_MULTI_PROP_H /* multi_prop.h will allow (once finished) for 2 (3) discrete prop files to be used, //(3) where detonator.h will be added to the mix (in the future) alternating on a 2 buttons extra long push. Your prop NEEDS to have two or more buttons. This is useful when you want a saber, with or without a blade, to toggle to a blaster,// and to a thermal detonator, and you want the buttons to take on different behaviors. How to use: #ifdef CONFIG_PROP #include "../props/multi_prop.h" #include "../props/saber_fett263_buttons.h" #include "../props/blaster.h" //#include "../props/detonator.h" //For the future #undef PROP_TYPE #define PROP_TYPE SaberBlasterProp //SaberBlasterDetonatorProp #endif ** Note the prop file saber_fett263_buttons here would change to the file name of the prop you choose. */ #define BUTTON_HELD_X_LONG_TIMEOUT 4000 //#define MODE_SWITH_TO_NEXT_PROP //Place holder for the future. I have no idea how this should work? #ifndef TWO_BUTTONS_X_LONG_PUSH #define TWO_BUTTONS_X_LONG_PUSH case EVENTID(BUTTON_POWER and BUTTON_AUX, EVENT_CLICK_X_LONG, "??what do I need to put here ??"): StartOrStopTrack(); return true; #endif #ifndef MULTI_PROP_CONDITION #define MULTI_PROP_CONDITION TWO_BUTTONS_X_LONG_PUSH #endif #ifdef PROP_INHERIT_PREFIX #error multi_prop.h must be included first #else #define PROP_INHERIT_PREFIX virtual #endif #include "prop_base.h" template class SaberBlasterProp : public virtual Saber, public virtual Blaster { //class SaberBlasterDetonatorProp : public virtual Saber, public virtual Blaster, public virtual Detonator { public: uint32_t map_button(uint32_t b) { switch (b) { #if NUM_BUTTONS == 3 case BUTTON_AUX: return BUTTON_FIRE; case BUTTON_AUX2: return BUTTON_MODE_SELECT; #else case BUTTON_POWER: return BUTTON_FIRE; case BUTTON_AUX: return BUTTON_MODE_SELECT; #endif default: return b; } } uint32_t reverse_map_button(uint32_t b) { switch (b) { #if NUM_BUTTONS == 3 case BUTTON_FIRE: return BUTTON_AUX; case BUTTON_MODE_SELECT: return BUTTON_AUX2; #else case BUTTON_FIRE: return BUTTON_POWER; case BUTTON_MODE_SELECT: return BUTTON_AUX; #endif default: return b; } } const char* name() override { return "DualProp"; } bool Event(enum BUTTON button, EVENT event) override { if (button == TWO_BUTTONS_X_LONG_PUSH) {} if (Saber::TWO_BUTTONS_X_LONG_PUSH) { return Saber::Event(button, event); } else { button = static_cast(map_button(button)); // Map modifiers uint32_t m = current_modifiers; current_modifiers = 0; for (; m; m &= m - 1) current_modifiers |= map_button(m & -m); bool ret = Blaster::Event(button, event); // Map modifiers back m = current_modifiers; current_modifiers = 0; for (; m; m &= m - 1) current_modifiers |= reverse_map_button(m & -m); return ret; } } bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override { if (Saber::TWO_BUTTONS_X_LONG_PUSH) { return Saber::Event2(button, event, modifiers); } else { return Blaster::Event2(button, event, modifiers); } } void SetPreset(int preset_num, bool announce) override { if (Saber::TWO_BUTTONS_X_LONG_PUSH) { Saber::SetPreset(preset_num, announce); } else { Blaster::SetPreset(preset_num, announce); } } void Loop() override { if (Saber::TWO_BUTTONS_X_LONG_PUSH) { Saber::Loop(); } else { Blaster::Loop(); } } void DoMotion(const Vec3& motion, bool clear) override { if (Saber::TWO_BUTTONS_X_LONG_PUSH) { Saber::DoMotion(motion, clear); } else { Blaster::DoMotion(motion, clear); } } void Clash(bool stab, float strength) override { if (Saber::TWO_BUTTONS_X_LONG_PUSH) { Saber::Clash(stab, strength); } else { Blaster::Clash(stab, strength); } } void SB_Effect(EffectType effect, float location) override { if (Saber::TWO_BUTTONS_X_LONG_PUSH) { Saber::SB_Effect(effect, location); } else { Blaster::SB_Effect(effect, location); } } }; #endif