# Mouse subsystem

The mouse subsystem periodically polls a mouse driver for movement and clicks
and maintains its position in a two dimensional environment.

To be able to properly follow updates from the device, this subsystem has to
be called upon regularly, which you'll probably want to do in the Loop
(sys/loop).

The mouse subsystem defines the Mouse structure as well as a "mouse" structbind
to it. During initialization, what you'll want to do is create an instance of
the Mouse from the driver and bind it to "mouse".

## Driver implementation

To implement the mouse, we need an underlying driver to extend it and implement
its methods, namely:

:mouse@ ( -- dx dy btnflags )
  Return the number of "units" (device dependant) by which the mouse moved since
  we last called this method. "dx" is negative when going left. "dy" is negative
  when going up. "btnflags" is a bitmask of the buttons that are currently
  pushed. b0=left b1=right b2=middle.

:mouseabs@  ( -- 0 ) or ( -- x xbounds y ybounds )
  Most implementations can just return 0. In case the mouse is an absolute pointer
  device (touch screen or tablet), the implementation can return the current absolute
  position and the bounds of the absolute device. For example, when x = xbound / 2
  and y = ybound / 2, the cursor will be moved to the middle of the screen.

## API

Constants:

BTN_LEFT   $01
BTN_RIGHT  $02
BTN_MIDDLE $04

Fields:

x       Current X pos before divisor is applied
y       Current Y pos before divisor is applied
xmax    Max X pos without divisor
ymax    Max Y pos without divisor
divisor A divisor to apply to movement to make it go slower
buttons Bitmask of buttons that are currently pressed
clicks  Bitmask of push/release cycles that occured since last :click@

:x ( self -- n )
  X with divisor applied

:y ( self -- n )
  Y with divisor applied

:update ( self -- )
  Fetch new data from :mouse@ and update fields accordingly.

:configure ( xmax ymax divisor self -- )
  Configure mouse with specified parameters.

:click@ not implemented
