Table of Contents

Struct ViewerInput

Namespace
Gym.Environments
Assembly
Gym.dll

One input a window reported, in the window's own order. Keys are SDL keycodes (pygame's event.key): a printable key is its unshifted character ('a' is 97), any other is its scancode with bit 30 set (K_LEFT is 1073741904); Gym.Rendering.KeyCode names them. The mouse is reported as GLFW reports it to MuJoCo's viewer (DR-70): the pointer in the client area's units from its top-left corner, buttons numbered as GLFW's (LeftButton, RightButton, MiddleButton), the wheel in notches with a positive ScrollY away from the user.

public readonly record struct ViewerInput : IEquatable<ViewerInput>
Implements
Inherited Members
Extension Methods

Constructors

ViewerInput(ViewerInputKind, int, int, int, double, double, int, double, double)

One input a window reported, in the window's own order. Keys are SDL keycodes (pygame's event.key): a printable key is its unshifted character ('a' is 97), any other is its scancode with bit 30 set (K_LEFT is 1073741904); Gym.Rendering.KeyCode names them. The mouse is reported as GLFW reports it to MuJoCo's viewer (DR-70): the pointer in the client area's units from its top-left corner, buttons numbered as GLFW's (LeftButton, RightButton, MiddleButton), the wheel in notches with a positive ScrollY away from the user.

public ViewerInput(ViewerInputKind Kind, int Key = 0, int Width = 0, int Height = 0, double X = 0, double Y = 0, int Button = 0, double ScrollX = 0, double ScrollY = 0)

Parameters

Kind ViewerInputKind

What happened.

Key int

The SDL keycode for KeyDown and KeyUp, else 0.

Width int

The new client width for Resized, else 0.

Height int

The new client height for Resized, else 0.

X double

The pointer's x for the mouse kinds, from the client area's left edge, else 0.

Y double

The pointer's y for the mouse kinds, from the client area's top edge, else 0.

Button int

The button for MouseDown and MouseUp, else 0.

ScrollX double

The horizontal turn for Scroll, in notches, else 0.

ScrollY double

The vertical turn for Scroll, in notches (positive away from the user), else 0.

Fields

LeftButton

The left mouse button (GLFW's MOUSE_BUTTON_LEFT).

public const int LeftButton = 0

Field Value

int

MiddleButton

The middle mouse button (GLFW's MOUSE_BUTTON_MIDDLE).

public const int MiddleButton = 2

Field Value

int

RightButton

The right mouse button (GLFW's MOUSE_BUTTON_RIGHT).

public const int RightButton = 1

Field Value

int

Properties

Button

The button for MouseDown and MouseUp, else 0.

public int Button { get; init; }

Property Value

int

Height

The new client height for Resized, else 0.

public int Height { get; init; }

Property Value

int

Key

The SDL keycode for KeyDown and KeyUp, else 0.

public int Key { get; init; }

Property Value

int

Kind

What happened.

public ViewerInputKind Kind { get; init; }

Property Value

ViewerInputKind

ScrollX

The horizontal turn for Scroll, in notches, else 0.

public double ScrollX { get; init; }

Property Value

double

ScrollY

The vertical turn for Scroll, in notches (positive away from the user), else 0.

public double ScrollY { get; init; }

Property Value

double

Width

The new client width for Resized, else 0.

public int Width { get; init; }

Property Value

int

X

The pointer's x for the mouse kinds, from the client area's left edge, else 0.

public double X { get; init; }

Property Value

double

Y

The pointer's y for the mouse kinds, from the client area's top edge, else 0.

public double Y { get; init; }

Property Value

double

Methods

Close()

A press of the window's close button.

public static ViewerInput Close()

Returns

ViewerInput

The input.

KeyDown(int)

A key press.

public static ViewerInput KeyDown(int key)

Parameters

key int

The SDL keycode.

Returns

ViewerInput

The input.

KeyUp(int)

A key release.

public static ViewerInput KeyUp(int key)

Parameters

key int

The SDL keycode.

Returns

ViewerInput

The input.

MouseDown(int, double, double)

A mouse button press.

public static ViewerInput MouseDown(int button, double x, double y)

Parameters

button int

LeftButton, RightButton or MiddleButton.

x double

The pointer's x.

y double

The pointer's y.

Returns

ViewerInput

The input.

MouseMove(double, double)

A pointer move.

public static ViewerInput MouseMove(double x, double y)

Parameters

x double

The pointer's new x.

y double

The pointer's new y.

Returns

ViewerInput

The input.

MouseUp(int, double, double)

A mouse button release.

public static ViewerInput MouseUp(int button, double x, double y)

Parameters

button int

LeftButton, RightButton or MiddleButton.

x double

The pointer's x.

y double

The pointer's y.

Returns

ViewerInput

The input.

Resized(int, int)

A new client size.

public static ViewerInput Resized(int width, int height)

Parameters

width int

The new width in pixels.

height int

The new height in pixels.

Returns

ViewerInput

The input.

Scroll(double, double, double, double)

A turn of the wheel.

public static ViewerInput Scroll(double scrollX, double scrollY, double x, double y)

Parameters

scrollX double

The horizontal turn in notches.

scrollY double

The vertical turn in notches, positive away from the user.

x double

The pointer's x.

y double

The pointer's y.

Returns

ViewerInput

The input.