Skip to content
Lenart Bezek edited this page Jun 21, 2016 · 19 revisions

This page documents the API exposed to Python script and other mods.

Axes

  • int GetNumAxes()
    Returns the number of created input axes.

      AdvancedControls.GetNumAxes()
    
  • InputAxis GetAxis(int i)
    Returns reference to an axis at index i in 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(0)
      print axis.OutputValue
    

InputAxis class

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.

  • AxisType Type
    Type of the axis.
    AxisType enumerator:

    • Controller = 1
    • Inertial = 2
    • Standard = 3
    • Custom = 4
    • Chain = 5
    axis = AdvancedControls.GetAxis("example controller axis")
    if axis.Type == AxisType.Controller:
        print "This is a controller axis."

ControllerAxis class

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.

StandardAxis and InertialAxis class

Two key classes derived from the InputAxis.

  • float Gravity
  • float Sensitivity
  • bool Snap
  • bool Invert
  • Button PositiveBind
  • Button NegativeBind

CustomAxis class

Custom Python axis class. Inherits from InputAxis.

  • string InitialisationCode
  • string UpdateCode
  • bool GlobalScope

ChainAxis class

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

Controllers

  • int GetNumControllers()
    Returns the number of currenctly connected joysticks or controllers.

      AdvancedControls.GetNumControllers()
    
  • Controller GetController(int i)
    Returns reference to a controller at index i in 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
    

Controller class

  • 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 is NumButtons + 4 * NumHats.

  • float GetAxis(int i)
    Returns the raw value of the ith axis in range from -1 to 1.

  • float GetAxisSmooth(int i)
    Returns the smoothed value of the ith axis in range from -1 to 1.

  • void Dispose()
    Disables this controller and clears up it's SDL handle. Called automatically on disconnect.

Buttons

  • 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 == 
    

Button interface

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

ko-fi button

Clone this wiki locally