Package rsb.internal

Class MouseHandler

java.lang.Object
rsb.internal.MouseHandler

public class MouseHandler extends Object
Author:
BenLand100
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The maximum distance (in pixels) to move the mouse after clicks in either direction on both axes.
    static final int
    The default mouse speed.
    static final int
    The amount of time (in ms) it takes per bit of difficulty (look up Fitts Law) to move the mouse.
    static final int
    The amount of time (in ms) it takes an average mouse user to realise the mouse needs to be moved
  • Method Summary

    Modifier and Type
    Method
    Description
    static Point[]
    applyDynamism(Point[] spline, int msForMove, int msPerMove)
    Omits points along the spline in order to move in steps rather then pixel by pixel
    static long
    fittsLaw(double targetDist, double targetSize)
    Calculates the ammount of time a movement should Mousetake based on Fitts' Law TIP: Do not add/subtract random values from this result, rather varry the targetSize value or do not move the same distance each time ;)
    static Point[]
    generateControls(int sx, int sy, int ex, int ey, int ctrlSpacing, int ctrlVariance)
    Creates random control points for a spline.
    static Point[]
    generateSpline(Point[] controls)
    Generates a spline that moves no more then one pixel at a time TIP: For most movements, this spline is not good, use applyDynamism
    void
    moveMouse(int x, int y)
     
    void
    moveMouse(int speed, int x1, int y1, int x2, int y2, int randX, int randY)
    Deprecated.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MOUSE_SPEED

      public static final int DEFAULT_MOUSE_SPEED
      The default mouse speed. This is the delay in ms between actual mouse moves. Lower is faster.
      See Also:
    • DEFAULT_MAX_MOVE_AFTER

      public static final int DEFAULT_MAX_MOVE_AFTER
      The maximum distance (in pixels) to move the mouse after clicks in either direction on both axes.
      See Also:
    • msPerBit

      public static final int msPerBit
      The amount of time (in ms) it takes per bit of difficulty (look up Fitts Law) to move the mouse. This appears to partially control the speed of mouse movement.
      See Also:
    • reactionTime

      public static final int reactionTime
      The amount of time (in ms) it takes an average mouse user to realise the mouse needs to be moved
      See Also:
  • Method Details

    • applyDynamism

      public static Point[] applyDynamism(Point[] spline, int msForMove, int msPerMove)
      Omits points along the spline in order to move in steps rather then pixel by pixel
      Parameters:
      spline - The pixel by pixel spline
      msForMove - The ammount of time taken to traverse the spline. should be a value from fittsLaw(double, double)
      msPerMove - The ammount of time per each move
      Returns:
      The stepped spline
    • fittsLaw

      public static long fittsLaw(double targetDist, double targetSize)
      Calculates the ammount of time a movement should Mousetake based on Fitts' Law TIP: Do not add/subtract random values from this result, rather varry the targetSize value or do not move the same distance each time ;)
      Parameters:
      targetDist - The distance from the current position to the center of the target
      targetSize - The maximum distence from the center of the target within which the end point could be
      Returns:
      the ammount of time (in ms) the movement should take
    • generateControls

      public static Point[] generateControls(int sx, int sy, int ex, int ey, int ctrlSpacing, int ctrlVariance)
      Creates random control points for a spline. Written by Benland100
      Parameters:
      sx - Begining X position
      sy - Begining Y position
      ex - Begining X position
      ey - Begining Y position
      ctrlSpacing - Distance between control origins
      ctrlVariance - Max X or Y variance of each control point from its origin
      Returns:
      An array of Points that represents the control points of the spline
    • generateSpline

      public static Point[] generateSpline(Point[] controls)
      Generates a spline that moves no more then one pixel at a time TIP: For most movements, this spline is not good, use applyDynamism
      Parameters:
      controls - An array of control points
      Returns:
      An array of Points that represents the spline
    • moveMouse

      @Deprecated public void moveMouse(int speed, int x1, int y1, int x2, int y2, int randX, int randY)
      Deprecated.
      Moves the mouse from a position to another position with randomness applied.
      Parameters:
      speed - the speed to move the mouse. Anything under DEFAULT_MOUSE_SPEED is faster than normal.
      x1 - from x
      y1 - from y
      x2 - to x
      y2 - to y
      randX - randomness in the x direction
      randY - randomness in the y direction
    • moveMouse

      public void moveMouse(int x, int y)