-
Notifications
You must be signed in to change notification settings - Fork 2
API
This page documents the API exposed to Python script and other mods. Enables you to access connected controllers, their buttons and all defined input axes.
-
int GetNumAxes()
Returns the number of created input axes.AdvancedControls.GetNumAxes() -
InputAxis GetAxis(int i)
Returns reference to an axis at indexiin an alphabetically ordered list. Returns None if out of range.axis = AdvancedControls.GetAxis(0) print axis.OutputValue -
InputAxis GetAxis(string name)
Returns reference to an axis with given name. Returns None if such axis is not found.axis = AdvancedControls.GetAxis("some axis") print axis.OutputValue
Important note:
This is the preferred method of axis reference retrieval in Custom Axis code. By calling this function in initialization code, the mod recognizes which axes are linked and includes them in machine file for sharing.
Base axis class.
-
string Name
Name of the axis. -
float InputValue
Raw axis input value. -
float OutputValue
Processed axis output value. -
bool Connected
Is associated controller connected. Always True if axis is not of controller type. -
bool Saveable
Is axis ready to be saved. -
AxisStatus Status
Current axis status. Only gives correct output if OK.
AxisStatus enumerator:- OK = 0
- NotFound = 1
- Unavailable = 2
- Disconnected = 3
- NotRunning = 4
- Error = 5
- NoLink = 6
-
AxisType Type
Type of the axis.
AxisType enumerator:- Controller = 1
- Custom = 4
- Chain = 5
- Mouse = 6
- Key = 7
axis = AdvancedControls.GetAxis("example controller axis") if axis.Type == AxisType.Controller: print "This is a controller axis."
InputAxis derived class for controller based axes.
- float Sensitivity
- float Curvature
- float Deadzone
- float OffsetX
- float OffsetY
- bool Invert
- bool Smooth
-
int Axis
Index of the controller axis. -
Guid GUID
GUID of the associated controller. -
float Process(float input)
Returns axis value for given input.
Key axis class derived from the InputAxis.
- float Gravity
- float Sensitivity
- float Momentum
- bool Snap
- bool Raw
- Button PositiveBind
- Button NegativeBind
- int Axis
- float Center
- float Range
Custom Python axis class. Inherits from InputAxis.
- string InitialisationCode
- string UpdateCode
- bool GlobalScope
- HashSet LinkedAxes
Chain axis class. Inherits from InputAxis.
-
string SubAxis1
Name of the axis linked on the left. -
string SubAxis2
Name of the axis linked on the right. -
ChainMethod Method
Method of combining axes.
ChainMethod enumerator:- Sum = 0
- Subtract = 1
- Average = 2
- Multiply = 3
- Maximum = 4
- Minimum = 5
-
int GetNumControllers()
Returns the number of currenctly connected joysticks or controllers.AdvancedControls.GetNumControllers() -
Controller GetController(int i)
Returns reference to a controller at indexiin a list, ordered by the order devices were connected. Returns None if index is out of range.controller = AdvancedControls.GetController(0) if controller: print controller.Name -
Controller GetController(string guid)
Returns reference to a controller with given GUID. Returns None if no such controller is found.controller = AdvancedControls.GetController("3001047d-0000-0000-0000-504944564944") if controller: print controller.Name
-
int Index
-
string Name
-
Guid GUID
-
bool Connected
-
bool IsGameController
-
int NumAxes
-
int NumBalls
-
int NumHats
-
int NumButtons
-
List<string> AxisNames
-
List<string> BallNames
-
List<string> HatNames
-
List<string> ButtonNames
-
List<Button> Buttons
List of all buttons on this joystick. Includes all four states of each hat. The count of these buttons isNumButtons + 4 * NumHats. -
float GetAxis(int i)
Returns the raw value of theithaxis in range from -1 to 1. -
float GetAxisSmooth(int i)
Returns the smoothed value of theithaxis in range from -1 to 1. -
void Dispose()
Disables this controller and clears up it's SDL handle. Called automatically on disconnect.
-
Button CreateButtonFromKeycode(UnityEngine.KeyCode key)
Creates and returns a new button, mapped to a keyboard key.axis = AdvancedControls.GetAxis("example standard axis") if axis.Type == AxisType.Standard or axis.Type == AxisType.Inertial: axis.PositiveBind = CreateButtonFromKeyCode(KeyCode.X)
Button interface that joystick buttons, hats and keyboard keys implement.
-
string ID
Button identifier string used for saving and loading. Holds information about type, device, index and state. -
bool IsDown
Is button currently held down. -
bool Pressed
Has button been pressed on this frame. -
bool Released
Has button been released on this frame. -
float Value
Button value. Normally 1 or 0. -
string Name
Name of the button. -
bool Connected
Is the associated controller connected.
API
API exposed to Python scripts, custom axes and other mods.
Sharing
Concepts behind the mod design and machine sharing.
Controller axis
Help regarding controller axis.
Key axis
Map keys, buttons and hats to an analog input axis.
Mouse
Use mouse position as input.
Chain axis
Chaining axes for complex input configurations.
Custom axis
Custom axes for everything else.
Controls
Full analog control list.
Console commands
Mod configuration console commands.
Fueled by coffee
