Skip to content

Boost ball functionality #1

Description

@thelabcat

I rewrote the Metroid Prime Hunters components of the mousefix for compatibility with my own PC and successfully implemented a way to do boost ball that I thought your code might benefit from. The basic strategy is to perform a quick swipe macro by pressing the tab key, and I also have it look at if any WASD keys are pressed to modify the swipe direction. Here is my Python code:

## CONFIG["directions"] is a dictionary of Cartesian coordinate vectors, [0, 1] being down, for example.
## self[key] queries configuration for this particular mousefix
## self["boostSwipeSize"] is a pixel length that comes from when I discovered that swipes on the touch screen have to be a certain size for the ROM to trigger a boost ball
## self.reset_mouse() picks up the mouse and moves it back to the center of the touch area
## self.goto_relative() moves the mouse cursor to a position of the touch area, relative to the size of the screenshots I used to make the fix[es]

    def boost_ball(self, e):
        """Perform a touch-based boost ball"""
        self.mouse_up()
        time.sleep(CONFIG["mouseResetWait"])
        
        direction=[0, 0]
        
        for d in CONFIG["emuKeys"]["dPad"].keys(): #Sum input CONFIG["directions"]. If they contradict, they will zero out
            if keyboard.is_pressed(CONFIG["emuKeys"]["dPad"][d]):
                #print(key)
                direction[0]+=CONFIG["directions"][d][0]
                direction[1]+=CONFIG["directions"][d][1]
                
        if direction == [0, 0]: #If there is no direction or all input CONFIG["directions"] cancelled out, use the default
            direction = CONFIG["directions"][self["defaultBBDirection"]]

        end_x = self.touch_center[0]+self["boostSwipeSize"]//2*direction[0]
        end_y = self.touch_center[1]+self["boostSwipeSize"]//2*direction[1]

        start_x = self.touch_center[0]-self["boostSwipeSize"]/2*direction[0]
        start_y = self.touch_center[1]-self["boostSwipeSize"]//2*direction[1]
        #print("Direction is", direction)
        #print("Boost from ", start_x, start_y, "to", end_x, end_y)
        self.goto_relative(start_x, start_y)
        time.sleep(CONFIG["mouseResetWait"])
        self.mouse_down()
        time.sleep(CONFIG["mouseResetWait"])
        self.goto_relative(end_x, end_y)
        time.sleep(CONFIG["mouseResetWait"])
        self.reset_mouse()

Hope this helps!
S.D.G.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions