import time


def wait_for_joystick_or_menu(hardware, sleep_time=1 / 30):
    """Waits for either the joystick or the menu. Returns the buttons"""
    while True:
        buttons = hardware.get_buttons()
        if buttons.menu_button or buttons.joy_button:
            return buttons
        time.sleep(sleep_time)