import java.util.Map;
/**
- * Human input device input tracker.
- * <p>
- * Idea is to capture all keyboard and mouse inputs from underlying operating system in this class
- * and forward those as needed to subsequent virtual components.
+ * This class is responsible for tracking human input devices (keyboard, mouse, etc.) and
+ * forwarding those inputs to subsequent virtual components.
*/
public class HIDInputTracker implements
MouseMotionListener, KeyListener, MouseListener, MouseWheelListener, ViewRenderListener {
/**
- * <pre>
- * Key is keyboard key code.
- * Value is system milliseconds when key was pressed.
- *
- * So by reading the map one can determine currently pressed keys as well as duration.
- * </pre>
+ * <p> Map of pressed keys. </p>
+ * <p> Key is mouse button code. </p>
+ * <p> Value is system milliseconds when button was pressed. </p>
+ * <p> So by reading the map one can determine currently pressed buttons as well as duration. </p>
*/
private final Map<Integer, Long> pressedKeysToPressedTimeMap = new HashMap<>();
private final List<MouseEvent> detectedMouseEvents = new ArrayList<>();
private final List<KeyEvent> detectedKeyEvents = new ArrayList<>();
private int wheelMovedDirection = 0;
- private Point2D mouseDraggedDirection = new Point2D();
+ private final Point2D mouseDraggedDirection = new Point2D();
private Point2D oldMouseCoordinatesWhenDragging;
- private ViewPanel viewPanel;
+ private final ViewPanel viewPanel;
private Point2D currentMouseLocation;
private boolean mouseMoved;
private boolean mouseWithinWindow = false;