pyremoteplay.controller module

Controller methods.

class pyremoteplay.controller.Controller(session=None)

Bases: object

Controller Interface. Sends user input to Remote Play Session.

class ButtonAction(value)

Bases: IntEnum

Button Action Types.

PRESS = 1
RELEASE = 2
TAP = 3
MAX_EVENTS = 5
STATE_INTERVAL_MAX_MS = 0.2
STATE_INTERVAL_MIN_MS = 0.1
static buttons()

Return list of valid buttons.

Return type

list

connect(session)

Connect controller to session.

start()

Start Controller.

This starts the controller worker which listens for when the sticks move and sends the state to the host. If this is not called, the update_sticks() method needs to be called for the host to receive the state.

stop()

Stop Controller.

disconnect()

Stop and Disconnect Controller. Must be called to change session.

update_sticks()

Send controller stick state to host.

Will be called automatically if controller has been started with start().

button(name, action='tap', delay=0.1)

Emulate pressing or releasing button.

If action is tap this method will block by delay.

Parameters
  • name (Union[str, FeedbackEvent.Type]) – The name of button. Use buttons() to show valid buttons.

  • action (Union[str, ButtonAction]) – One of press, release, tap, or Controller.ButtonAction.

  • delay – Delay between press and release. Only used when action is tap.

async async_button(name, action='tap', delay=0.1)

Emulate pressing or releasing button. Async.

If action is tap this coroutine will sleep by delay.

Parameters
  • name (Union[str, FeedbackEvent.Type]) – The name of button. Use buttons() to show valid buttons.

  • action (Union[str, ButtonAction]) – One of press, release, tap, or Controller.ButtonAction.

  • delay – Delay between press and release. Only used when action is tap.

stick(stick_name, axis=None, value=None, point=None)

Set Stick State.

If controller has not been started with start(), the update_sticks() method needs to be called manually to send stick state.

The value param represents how far to push the stick away from center.

The direction mapping is shown below:

X Axis: Left -1.0, Right 1.0

Y Axis: Up -1.0, Down 1.0

Center 0.0

Parameters
  • stick_name – The stick to move. One of ‘left’ or ‘right’

  • axis – The axis to move. One of ‘x’ or ‘y’

  • value – The value to move stick to. Must be between -1.0 and 1.0

  • point – An iterable of two floats, which represent coordinates. Point takes precedence over axis and value. The first value represents the x axis and the second represents the y axis

property stick_state: ControllerState

Return stick state.

Return type

ControllerState

property running: bool

Return True if running.

Return type

bool

property ready: bool

Return True if controller can be used

Return type

bool

property session: Session

Return Session.

Return type

Session