Skip to content

Commit

Permalink
Allow toggling rumble from ApeSphere menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ComplexPlane committed Feb 4, 2021
1 parent f4c6b34 commit aeabcb6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 16 deletions.
3 changes: 2 additions & 1 deletion rel/include/mkb2.us.lst
Original file line number Diff line number Diff line change
Expand Up @@ -14934,4 +14934,5 @@ E0000094:locked_cache_mtx_stack_ptr
E000019C:e
E00001A0:0.5
8032bfb0:sprite_loadin_stage_name_tick
8032ccb4:sprite_bonus_stage_tick
8032ccb4:sprite_bonus_stage_tick
804a7560:rumble_enabled_bitflag
63 changes: 50 additions & 13 deletions rel/menu_defn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

#define ARRAY_LEN(a) (sizeof((a)) / sizeof((a)[0]))

namespace mkb
{

extern "C"
{
extern u8 rumble_enabled_bitflag;
}

}

namespace menu
{

Expand All @@ -33,14 +43,40 @@ static void set_practice_tools_enabled(bool enable)
}
}

static void set_jump_mod_enabled(bool enable) { if (enable) jump::init(); else jump::dest(); }

static bool get_rumble_enabled()
{
return true;
}

static void set_rumble_enabled(bool enable) {}
static Widget rumble_widgets[] = {
{
.type = WidgetType::Checkbox,
.checkbox = {
.label = "Controller 1 Rumble",
.get = []() { return static_cast<bool>(mkb::rumble_enabled_bitflag & (1 << 0)); },
.set = [](bool enable) { mkb::rumble_enabled_bitflag ^= (1 << 0); },
}
},
{
.type = WidgetType::Checkbox,
.checkbox = {
.label = "Controller 2 Rumble",
.get = []() { return static_cast<bool>(mkb::rumble_enabled_bitflag & (1 << 1)); },
.set = [](bool enable) { mkb::rumble_enabled_bitflag ^= (1 << 1); },
}
},
{
.type = WidgetType::Checkbox,
.checkbox = {
.label = "Controller 3 Rumble",
.get = []() { return static_cast<bool>(mkb::rumble_enabled_bitflag & (1 << 2)); },
.set = [](bool enable) { mkb::rumble_enabled_bitflag ^= (1 << 2); },
}
},
{
.type = WidgetType::Checkbox,
.checkbox = {
.label = "Controller 4 Rumble",
.get = []() { return static_cast<bool>(mkb::rumble_enabled_bitflag & (1 << 3)); },
.set = [](bool enable) { mkb::rumble_enabled_bitflag ^= (1 << 3); },
}
}
};

static Widget help_widgets[] = {
{.type = WidgetType::Header, .header = {"Practice Tools Bindings"}},
Expand Down Expand Up @@ -70,12 +106,13 @@ static Widget root_widgets[] = {
},
{
.type = WidgetType::Checkbox,
.checkbox = {"Jump Mod", jump::is_enabled, set_jump_mod_enabled},
},
{
.type = WidgetType::Checkbox,
.checkbox = {"Rumble", get_rumble_enabled, set_rumble_enabled},
.checkbox = {
.label = "Jump Mod",
.get = jump::is_enabled,
.set = [](bool enable) { if (enable) jump::init(); else jump::dest(); },
},
},
{.type = WidgetType::Menu, .menu = {"Rumble", rumble_widgets, ARRAY_LEN(rumble_widgets)}},
{.type = WidgetType::Menu, .menu = {"Help", help_widgets, ARRAY_LEN(help_widgets)}},
};

Expand Down
4 changes: 2 additions & 2 deletions rel/menu_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ void draw_menu_widget(MenuWidget *menu, u32 cursor_pos)
MARGIN + PAD,
y,
cursor_pos == selectable_idx ? lerped_color : unfocused,
" %s",
widget.checkbox.get() ? "Enabled" : "Disabled");
" %s",
widget.checkbox.get() ? "On" : "Off");

if (cursor_pos == selectable_idx) cursor_y = y;
y += LINE_HEIGHT;
Expand Down

0 comments on commit aeabcb6

Please sign in to comment.