Next: , Previous: , Up: Kernel   [Contents][Index]


5.1.2 Input Devices

While run-game provides hooks for mouse/keyboard/controller input events, it is often necessary to query input devices for their current state. For example, it could be desirable to query the state of the arrow keys every time the update hook is called to determine which direction the player should move that frame.

Procedure: key-pressed? key

Return #t if key is currently being pressed.

Procedure: key-released? key

Return #t if key is not currently being pressed.

Procedure: mouse-x

Return the current X coordinate of the mouse cursor.

Procedure: mouse-y

Return the current Y coordinate of the mouse cursor.

Procedure: mouse-button-pressed? button

Return #t if button is currently being pressed.

Procedure: mouse-button-released? button

Return #t if button is not currently being pressed.

Procedure: controller-axis controller axis

Return a floating point value in the range [-1, 1] corresponding to how much axis (an analog stick or trigger) is being pushed on controller. 0 is returned if axis is not being pushed at all.

Procedure: controller-name controller

Return the name of controller.

Procedure: controller-button-pressed? controller button

Return #t if button on controller is currently being pressed.

Procedure: controller-button-released? controller button

Return #t if button on controller is not currently being pressed.