To handle input from keyboard, mouse and joystick (joysticks require pygame to be installed). See demo_mouse.py and i{demo_joystick.py} for examples
Used in scripts created by the builder to keep track of a clock and the current status (whether or not we are currently checking the keyboard)
Easy way to track what your mouse is doing. It needn’t be a class, but since Joystick works better as a class this may as well be one too for consistency
Create your visual.Window before creating a Mouse.
| Parameters : |
|
|---|
Reset a 3-item list of core.Clocks use in timing button clicks. The pyglet mouse-button-pressed handler uses their timeAtLastReset when a button is pressed so the user can reset them at stimulus onset or offset to measure RT. The default is to reset all, but they can be reset individually as specified in buttons list
Returns the current postion of the mouse, in the same units as the Window (0,0) is at centre
Returns a 3-item list indicating whether or not buttons 1,2,3 are currently pressed
If getTime=True (False by default( then getPressed will return all buttons that have been pressed since the last call to mouse.clickReset as well as their time stamps:
buttons = mouse.getPressed()
buttons, times = mouse.getPressed(getTime=True)
Typically you want to call mouse.clickReset() at stimulus onset, then after the button is pressed in reaction to it, the total time elapsed from the last reset to click is in mouseTimes. This is the actual RT, regardless of when the call to getPressed() was made.
Returns the new position of the mouse relative to the last call to getRel or getPos, in the same units as the Window.
Gets the visibility of the mouse (1 or 0)
Returns the travel of the mouse scroll wheel since last call. Returns a numpy.array(x,y) but for most wheels y is the only value that will change (except mac mighty mice?)
Determine whether/how far the mouse has moved
With no args returns true if mouse has moved at all since last getPos() call, or distance (x,y) can be set to pos or neg distances from x and y to see if moved either x or y that far from lastPos , or distance can be an int/float to test if new coordinates are more than that far in a straight line from old coords.
Retrieve time of last movement from self.mouseClock.getTime().
Reset can be to ‘here’ or to screen coords (x,y) which allows measuring distance from there to mouse when moved. if reset is (x,y) and distance is set, then prevPos is set to (x,y) and distance from (x,y) to here is checked, mouse.lastPos is set as current (x,y) by getPos(), mouse.prevPos holds lastPos from last time mouseMoved was called
Sets the current postiion of the mouse (pygame only), in the same units as the Window (0,0) is at centre
| Parameters : |
|
|---|
Sets the visibility of the mouse to 1 or 0
NB when the mouse is not visible its absolute position is held at (0,0) to prevent it from going off the screen and getting lost! You can still use getRel() in that case.
Clears all events currently in the event buffer. Optional argument, eventType, specifies only certain types to be cleared
| Parameters : |
|
|---|
Returns a list of keys that were pressed.
| Parameters : |
|
|---|---|
| Author : |
|
Halts everything (including drawing) while awaiting input from keyboard. Then returns list of keys pressed. Implicitly clears keyboard, so any preceding keypresses will be lost.
Optional arguments specify maximum wait period and which keys to wait for.
Returns None if times out.
Helper function returning the cartesian distance between p1 and p2