Skip to content

InputCandy:Advanced Private Class Reference

h3rb edited this page Apr 2, 2021 · 7 revisions

The complete reference to the private class __ICI attached to __INPUTCANDY.internal, these methods and properties are created when the function New_InputCandy_Private() is invoked.

These functions are considered "private" because they do not need to be accessed directly to use InputCandy. Please note that you are able to access these functions by calling them with the prefix __ICI.<method-name>

Method Description
__ICI.Step() The main per-frame step function of InputCandy, it checks and keeps updated the active devices, performs ICSetup loading when 5 frames have passed (a good time since all gamepads are connected then) applies the settings and drops any disconnected devices from the device profile. This function is called from __INPUTCANDY.Step()
__ICI.Init() Initializes __INPUTCANDY.platform, loads settings and setup data from disk, sets the maximum number of players and initializes the step counter. This function is called from __INPUTCANDY.Init()
UpdateNetwork() Not yet implemented but reserved for future use. This function will maintain the network connectivity.
GetPlatformSpecifics() This method gets basic device information, as described in InputCandy:Advanced Class Reference
New_ICDevice() Creates an ICDevice object as specified in InputCandy:Advanced Class Reference
ICDevicePrintDiagnostics(icdevice) returns a string form of an ICDevice object
ICDevicePrintDiagnostics_Verbose(icdevice) returns a string form of an ICDevice object including button, hat and axis information. This is used on the diagnostics screen in the InputCandy sample project.
IsSameICDevice(a,b) Determines if an ICDevice "a" is identical to ICDevice "b", return true or false
GetActiveDeviceS() Called by __ICI.Step(), this function maintains the list of active gamepad devices, __INPUTCANDY.devices, dropping any devices from the list that are not active, and activating any newly detected devices. This function is called 5 times before any ICSetup is applied to make sure there are enough detections available.
AssignUnusedDevices() This method assigns unused devices to player slots that do not have a gamepad device associated. It is called by __ICI.Step() right after GetActiveDevices() is called.
GuessBestDeviceIcon(icdevice) This method picks from the iconified drawings of gamepads in the sprite s_InputCandy_device_icons to illustrate approximately what the controller looks like. You can add additional detection criteria to this function and create corresponding icons in the sprite to help illustrate additional devices like flight sticks, or any other attachment you wish to support.
New_ICButtonState() This method creates a new ICButtonState object, as described in InputCandy:Advanced Class Reference
ICButtonStatePrintDiagnostics(icbuttonstate) This method creates and returns a string out of an ICButtonState object
New_ICDeviceState() This method creates a new ICDeviceState object, as described in InputCandy:Advanced Class Reference
ICDeviceStatePrintDiagnostics(icdevicestate) This method creates and returns a string out of an ICDeviceState object
ICDeviceStatePrintDiagnostics_Verbose(icdevicestate) This method creates and returns a string out of an ICDeviceState object but contains verbose information about the button, hat and axis states
GetDeviceStates() This method is the main polling function called in __ICI.Step() once per frame, that populates __INPUTCANDY.states[] and __INPUTCANDY.keys[] and __INPUTCANDY.mouseStates[]
ButtonStateIn( code, keys, len ) This method asks the question "is the button state in the list?" and is used to detect if a code is in a set of codes (keys). It is used by GetKeyboardMouseStates() to determine partial matches of non-combination signals.
GetKeyboardMouseStates() Called by GetDeviceStates(), this method gathers __INPUTCANDY.keys[] and __INPUTCANDY.mouseStates[] for each frame.
New_ICAction() This method creates a new ICAction object, as described in InputCandy:Advanced Class Reference ; it is exposed by the global function IC_NewAction()
CopyOfAction(icaction) This function returns a duplicate object of the icaction object provided, see also InputCandy:Advanced Class Reference ; this function is used sometimes to create a distinct copy of an action, like in the case of the bound_action portion of the ICBinding object
MatchSignal( player_number, action, ic_code ) This function attempts to match an action for a player with a provided signal code against the current device states, within the scope of the action's rules. The action parameter is an actual object, not an action_index. It could be the bound_action of an ICBinding.
MatchButtonList( player_number, action, is_combo, buttonlist ) Matches against a button list. Action is an actual object pass down to MatchSignal(). Checks the entire list of ic_codes. In the case of is_combo being true, it requires all to match.
MatchAction( player_number, action, type ) Attempts to match an action against a device "type", for a player_number. The action is provided, along with the ICDeviceType value for type. This allows an action to match only for a particular player, and a particular device type, for example a keyboard, or a gamepad, exclusively. It makes calls to MatchButtonList() and MatchSignal() to determine matching based on the logic rules defined in the action.
InterpretAction(player_number,action,type,binding) A wrapper around MatchAction() that interprets a player's binding as an override to the action and attempts to match either the binding or the original action if there is no binding.
New_ICMoving() Generates a blank "moving" object that describes a snapshot of directional movement pulled from either a D-Pad, WASD/NUMPAD, hat, or axis combination (thumbstick) and is of the form { up: false, down: false, left: false, right: false, value: AXIS_NO_VALUE, angle: AXIS_NO_VALUE, H: AXIS_NO_VALUE, V: AXIS_NO_VALUE, H2:[], V2:[], not_available: false }
_MovingOr( moving, or_moving ) You can pass this method two "moving" objects gathered from GetDirectional() and it will "boolean OR" them together into a single "moving" object. A new AxisToAngle is calculated.
_MovingAnd( moving, and_moving ) You can pass this method two "moving" objects gathered from GetDirectional() and it will "boolean AND" them together into a single "moving" object. A new AxisToAngle is calculated.
ApplyBindingToMoving( binding, moving ) Applies the "reverse" "invert" "swap LR UD" (rotate) options to a binding
GetDirectional( player_index, moving, type ) Acquires a directional object back from a gamepad device. For the special is_directional type of action that is a special way to bind a single action to a hat, dpat or virtual thumbstick (axis combination). The input object "moving" allows for accumulation and compounding of multiple inputs. The "type" parameter is an IC_code that indicates whether the check should target the IC_dpad, IC_hatX, IC_axisX, IC_arrows / IC_wasd / IC_numpad. It is a method of convenience for getting a complex movement object back in a single check. The returned object "moving", is of the class ICMoving
GetDirectionalByCode( code ) Returns the index in the __INPUTCANDY.directionals list that matches the IC_code, or none
GetStickByAxisPair( haxis, vaxis ) Returns the index in the __INPUTCANDY.directionals list that matches the H and V axis index or none
DirectionalSupported( device, directional_index ) Checks if a device supports one of the members of the __INPUTCANDY.directionals list
MatchBoundDirectional( player_index, action_index, action, binding, moving ) Called by MatchDirectional, attempt to match a binding and gather its results.
MatchDirectional( player_index, action_index, action ) This method attempts to match a player and a directional appropriate to the player's settings. Both the action_index and action refer to the same __INPUTCANDY.action. Bindings are checked on the player internally to the function.
New_ICPlayer() This method creates a new ICPlayer object, as described in InputCandy:Advanced Class Reference
New_ICSettings() This method creates a new ICSettings object, as described in InputCandy:Advanced Class Reference
GetSettings(player_number) Returns the player's referenced settings, or none if there are no settings associated with the player.
GetSettingsIndex(player_number) Returns the player's referenced settings index in the __INPUTCANDY.settings list, or none if there are no settings associated with the player.
SetSettings(player_number, settings_index) Simply assigns the player's settings reference in the master player list. This is a method of convenience.
AddSettings() or AddSettings(player_number) Creates a new ICSettings object and appends it to __INPUTCANDY.settings, with an optional parameter to assign a player's settings referenced, used in the ICUI to begin customizing settings for a particular player.
RemoveSettings( settings_index ) TODO. Not yet implemented. Will remove any references to the setting and renumber other settings, then remove the setting from the master list __INPUTCANDY.settings
AssociateSettingsWithDevice( settings_index, device_index ) Used to assign a device association with an ICSettings object. Settings gets a copy of the deviceInfo so it is data that is not lost when the device is disconnected. Using this association, you could offer the player a way to programmatically assign the first available settings made for each device connected.
New_ICBinding() This method creates a new ICBinding object, as described in InputCandy:Advanced Class Reference
AddBinding( setting_index, from_action_index ) Adds a binding to an ICSetting object from an ICAction object, by passing the index of the action in the __INPUTCANDY.actions list
GetBinding( settings_index, action_index ) Retrieves a binding index from an ICSetting object by the action's index from the __INPUTCANDY.actions list, returning the index of the binding in the ICSetting object
GetBindingData( settings_index, action_index ) Retrieves a binding from an ICSetting object by the action's index from the __INPUTCANDY.actions list, returning the actual object of the binding in the ICSetting object
CodeMatches( code, single_array ) Determines if a signal code or code array matches a code or is present in an array of codes. Used in ui.input_binding for testing if a code or code set is already in use.
CodeMatchesAll( code, single_array ) Determines if a signal code matches or a code array matches a single code or code array. Used in ui.input_binding for testing if a code or code set is already in use.
ActionMatches( action, code ) Does the logic by wrapping CodeMatches() and CodeMatchesAll(). Used in ui.input_binding for testing if a code or code set is already in use.
GetActionsBindingsByCode( settings_index, code, exclude, for_action ) Checks to see if, in an ICSettings object, a code batches bindings or actions in the master __INPUTCANDY.actions[] list. Returns a complex result of the format { bindings_count: (integer), bindings: [..], actions_count: (integer), actions: [..] } describing where the matches were found.
RemoveBinding( settings_index, action_index ) Expunges any bindings in an ICSettings object that match the action_index provided.
SetBindingGamepad( settings_index, action_index, binding_index, gamepad ) Sets the gamepad signal codes section of the ICBinding object in an ICSettings object. This function will create the binding from the action provided if none exists before setting the gamepad portion of the action's binding.
SetBindingKeyboard( settings_index, action_index, binding_index, keyboard) Same as above but for the keyboard portion of the action's binding.
SetBindingMouse( settings_index, action_index, binding_index, mouse) Same as above but for the keyboard portion of the action's binding.
SetBindingKeyboardMouse( settings_index, action_index, binding_index, keyboard, mouse) Same as above but for the keyboard and mouse portions of the action's binding.
PostLoadBinding( json_struct ) Called by LoadSettings() for each binding to search the action's list __INPUTCANDY.actions by the action's name and group, and converts the action into an action index. This allows the binding to be silently discarded if your game has removed a previously defined action.
PreSaveBinding( binding ) The reverse of PostLoadBinding(), this method is called for each binding to convert the binding back into a name, group pairing, rather than an action index. This allows you to insert new actions into your game and not have them break previous settings that were associated with the binding in the case of reordering them in your code.
SaveSettings() Saves all of the ICSettings to disk.
LoadSettings() Loads all of the ICSettings from disk.
New_ICSetup() This method creates a new ICSetup object, as described in InputCandy:Advanced Class Reference
CurrentSetup() Builds and populates a new ICSetup object based on the present configuration.
SaveSetup() Saves the ICSetup object to disk.
LoadSetup() Loads the ICSetup object from disk.
Is_Valid_Setting(setting_index) Checks if the player's setting reference to the __INPUTCANDY.settings[] list is valid.
Is_Valid_Device(device_index) Checks if a device reference to the __INPUTCANDY.devices[] list is still valid.
ActivateSetup() Activate Setup applies device swapping, settings, call on "Frame 5", and only then. Called by __ICI.Step()
UpdateActiveSetup() Updates the active setup based on current settings then saves it.
ApplySDLMappings() This method goes through the device list and clears any mappings, then applies any currently selected mappings.
ApplyDeviceSettings() This method goes through the device list and sets the axis deadzone and button threshold based on the ICSettings for that player.
New_ICNetwork() TODO; reserved but not yet implemented.