Input

Constants

M_LEFT - left mouse button
M_RIGHT - right mouse button
M_MIDDLE - middle mouse button
M_WHEEL_UP - scrolling the mouse wheel up
M_WHEEL_DOWN - scrolling the mouse wheel down

Keyboard

class serge.input.Keyboard[source]

Bases: serge.common.Loggable

Represents the state of the keyboard

areAnyClicked()[source]

Is any button clicked?

areAnyDown()[source]

Is any button depressed?

getClicked()[source]

Return a list of the keys that are clicked

getTextEntered()[source]

Return any text entered since the last call

isAltDown()[source]

Return True if the alt key is down

isClicked(key)[source]

Return True if the key has been clicked

isControlDown()[source]

Return True if the control key is down

isDown(key)[source]

Return True if the key is down

isShiftDown()[source]

Return True if the shift key is down

isUp(key)[source]

Return True if the key is up

update(interval)[source]

Update the state of the keyboard

class serge.input.KeyState[source]

Bases: object

Represents the state of keyboard keys

getCopy()[source]

Return a new copy of the key states

getState(key)[source]

Return the state of a specific key

setState(key, state)[source]

Set the state for a key

Mouse

class serge.input.Mouse(engine)[source]

Bases: object

Represents the state of the mouse

clearClick(MouseStateType)[source]

Clear a click event

getActorEvents(world, layers=None, layer_order=None)[source]

Return the type of events for each actor that we have hit

The optional parameter layers can be a list of layers that we are interested in. Only actors on the given layers will be returned.

getActorsUnderMouse(world)[source]

Return all the actors that the mouse is over

getScreenPoint()[source]

Return the location of the mouse relative to the screen as a point

getScreenPos()[source]

Return the pixel location relative to the screen and camera

getStaticScreenPos()[source]

Return the pixel location relative to the screen and NOT camera

isClicked(MouseStateType)[source]

Return True if the mouse button is pressed

isDown(MouseStateType)[source]

Return True if the mouse button is down

isUp(MouseStateType)[source]

Return True if the mouse button is up

update(interval)[source]

Update our mouse states

class serge.input.MouseState[source]

Bases: object

A structure that contains the states of our mouse buttons.

getCopy()[source]

Return a copy of this state

getState(StateType)[source]

Return True if the specified button is pressed

setState(StateType, state)[source]

Set the state of a specific key