Package rsb.internal
Class MouseHandler
java.lang.Object
rsb.internal.MouseHandler
- Author:
- BenLand100
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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 TypeMethodDescriptionstatic Point[]
applyDynamism
(Point[] spline, int msForMove, int msPerMove) Omits points along the spline in order to move in steps rather then pixel by pixelstatic 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, useapplyDynamism
void
moveMouse
(int x, int y) void
moveMouse
(int speed, int x1, int y1, int x2, int y2, int randX, int randY) Deprecated.
-
Field Details
-
DEFAULT_MOUSE_SPEED
public static final int DEFAULT_MOUSE_SPEEDThe 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_AFTERThe maximum distance (in pixels) to move the mouse after clicks in either direction on both axes.- See Also:
-
msPerBit
public static final int msPerBitThe 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 reactionTimeThe amount of time (in ms) it takes an average mouse user to realise the mouse needs to be moved- See Also:
-
-
Method Details
-
applyDynamism
Omits points along the spline in order to move in steps rather then pixel by pixel- Parameters:
spline
- The pixel by pixel splinemsForMove
- The ammount of time taken to traverse the spline. should be a value fromfittsLaw(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 targettargetSize
- 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 positionsy
- Begining Y positionex
- Begining X positioney
- Begining Y positionctrlSpacing
- Distance between control originsctrlVariance
- 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
Generates a spline that moves no more then one pixel at a time TIP: For most movements, this spline is not good, useapplyDynamism
- Parameters:
controls
- An array of control points- Returns:
- An array of Points that represents the spline
-
moveMouse
Deprecated.Moves the mouse from a position to another position with randomness applied.- Parameters:
speed
- the speed to move the mouse. Anything underDEFAULT_MOUSE_SPEED
is faster than normal.x1
- from xy1
- from yx2
- to xy2
- to yrandX
- randomness in the x directionrandY
- randomness in the y direction
-
moveMouse
public void moveMouse(int x, int y)
-