xyin
Sense the cursor position in an output window
When xyin is called the position of the mouse within the output window is used to reply to the request. This simple mechanism does mean that only one xyin can be used accurately at once. The position of the mouse is reported in the output window.
Syntax
Initialization
iprd -- period of cursor sensing (in seconds). Typically .1 seconds.
xmin, xmax, ymin, ymax -- edge values for the x-y coordinates of a cursor in the input window.
ixinit, iyinit (optional) -- initial x-y coordinates reported; the default values are 0,0. If these values are not within the given min-max range, they will be coerced into that range.
Performance
xyin samples the cursor x-y position in an input window every iprd seconds. Output values are repeated (not interpolated) at the k-rate, and remain fixed until a new change is registered in the window. There may be any number of input windows. This unit is useful for real-time control, but continuous motion should be avoided if iprd is unusually small.
Note
Depending on your platform and distribution, you might need to enable displays using the --displays command line flag.
Examples
Here is an example of the xyin opcode. It uses the file xyin.csd.
As the values of kx and ky change, they will be printed out like this:
See also
Sensing and Control: Keyboard and mouse sensing
Credits
Example written by Kevin Conder.