Exemple #1
0
 def test_joystick_udlr(self):
     game = self._game('joystick_udlr')
     self.assertEqual(self._button_seq(game), [
         Buttons(BLog.JOYSTICK_UP, BPhys.NONE),
         Buttons(BLog.JOYSTICK_DOWN, BPhys.NONE),
         Buttons(BLog.JOYSTICK_LEFT, BPhys.NONE),
         Buttons(BLog.JOYSTICK_RIGHT, BPhys.NONE)])
Exemple #2
0
 def test_dpad_udlr(self):
     game = self._game('dpad_udlr')
     self.assertEqual(self._button_seq(game), [
         Buttons(BLog.DPAD_UP, BPhys.DPAD_UP),
         Buttons(BLog.DPAD_DOWN, BPhys.DPAD_DOWN),
         Buttons(BLog.DPAD_LEFT, BPhys.DPAD_LEFT),
         Buttons(BLog.DPAD_RIGHT, BPhys.DPAD_RIGHT)])
Exemple #3
0
 def test_buttons_abxy(self):
     game = self._game('buttons_abxy')
     self.assertEqual(self._button_seq(game), [
         Buttons(BLog.A, BPhys.A),
         Buttons(BLog.B, BPhys.B),
         Buttons(BLog.X, BPhys.X),
         Buttons(BLog.Y, BPhys.Y)])
Exemple #4
0
    def set_button_state(self, button_state: Buttons.Logical):
        diff = self.prev ^ button_state  # prev XOR new
        press = diff & button_state  # Send press for: diff AND new
        release = diff & self.prev  # Send release for: diff AND pref
        # keep = self.prev & button_state # Keep pressing: prev AND new
        self.prev = press

        # Release old buttons
        for i in bits(release):
            self.release_button(Buttons.Logical(i))

        # Press new buttons
        for i in bits(press):
            self.press_button(Buttons.Logical(i))

        return press, release
Exemple #5
0
    def as_slippi_bitmask(self) -> Buttons.Logical:
        """Return action(s) as Slippi bitmask."""
        res = Buttons.Logical(Buttons.Logical.NONE)
        for i, mask in enumerate(STATE_TO_SLIPPI):
            if self.state[i]:
                res |= mask

        return res
Exemple #6
0
 def test_buttons_lrzs(self):
     game = self._game('buttons_lrzs')
     self.assertEqual(self._button_seq(game), [
         Buttons(BLog.TRIGGER_ANALOG, BPhys.NONE),
         Buttons(BLog.TRIGGER_ANALOG|BLog.L, BPhys.L),
         Buttons(BLog.TRIGGER_ANALOG, BPhys.NONE),
         Buttons(BLog.TRIGGER_ANALOG|BLog.R, BPhys.R),
         Buttons(BLog.TRIGGER_ANALOG|BLog.A|BLog.Z, BPhys.Z),
         Buttons(BLog.START, BPhys.START)])