CFXControl Flex Wiki
English中文

Interface reference

Every public type in com.ifels.controlflex.api: the entry point, the plugin interface, the four providers, the state registry, the overlay and camera hooks, and the asset installer. Each section gives the signature and its calling rules; the snippets are meant to be copied.

Section: Overview · Setup & lifecycle · Interfaces · Implementations · Who uses the API

Type overview

Package com.ifels.controlflex.api, 13 public types. Everything except IPlayerStateRegistry.setState() must be called on the client main thread.

Type Purpose
ControlFlexApiStatic entry point: availability check plus provider accessors
IControlFlexPluginSPI plugin interface (lifecycle callbacks)
ICompatAssetInstallerAsset installer (only usable inside the matching callback)
IActionStateProviderQuery whether an action is currently active
IInputProviderController connection state and hardware view
IControllerStateLive view of sticks / triggers / buttons
IControllerCapabilitiesHardware capabilities (type, paddles, gyro, rumble)
ButtonNameButton and axis name constants
IPlayerStateRegistryPush modId:state states for JSON to consume
IInteractiveContextRegistrarDeclare an interactive overlay's foreground / background
ICameraLookConsumerTake over each frame's look delta (when a mod owns the camera)
ControllerType · InputModeController type / current input mode enums

Input injection was removed in 0.9.0: IInputInjector and getInputInjector() are gone, so tooling that needs synthetic gamepad input has to stay on 0.8.x.

ControlFlexApi (static entry point)

boolean isAvailable()               // installed and fully initialized
boolean isControllerConnected()     // a controller is connected

// Providers (null when unavailable)
IActionStateProvider getActionStateProvider()
IInputProvider getInputProvider()
IPlayerStateRegistry getPlayerStateRegistry()
IInteractiveContextRegistrar getInteractiveContextRegistrar()

String getApiVersion()              // e.g. "0.9.2"
void reloadGuides()                 // reload guide configs from disk

IActionStateProvider

boolean isGameActionActive(String actionId)   // game layer (no screen open)
boolean isGuiActionActive(String actionId)    // GUI layer
Set<String> getActiveGameActions()             // live view: never cache across ticks
Set<String> getActiveGuiActions()              // live view: never cache across ticks

Three action ID forms:

IInputProvider · IControllerState · ICapabilities

// IInputProvider
boolean isConnected()
IControllerState getControllerState()          // null when disconnected
IControllerCapabilities getCapabilities()      // null when disconnected
String getGamepadName()                        // null when disconnected
int getGamepadIndex()                          // -1 when disconnected

// IControllerState — live view; sticks -1..1, triggers 0..1, +Y points down
float getLeftStickX()  / getLeftStickY()
float getRightStickX() / getRightStickY()
float getLeftTrigger() / getRightTrigger()
boolean isButtonAPressed() ... isDpadUpPressed() ...
boolean isButtonPressed(String buttonName)     // prefer ButtonName constants
float getAxisValue(String axisName)
boolean isShiftLayerActive()

// IControllerCapabilities
ControllerType getControllerType()   // XBOX / PLAYSTATION / NINTENDO_SWITCH / ...
boolean hasPaddles() / int getPaddleCount()
boolean hasTouchpad() / hasGyro() / hasRumble() / hasAnalogTriggers()
boolean isNintendoLayout()           // A/B swapped

ButtonName gives three groups: buttons (A…Y, DPAD_UP, LEFT_BUMPER, LEFT_TRIGGER, LEFT_STICK_CLICK, BACK, START, GUIDE, PADDLE_1…PADDLE_4, TOUCHPAD), stick directions (LEFT_STICK_UP …) and axes (AXIS_LEFT_X, AXIS_RIGHT_TRIGGER …).

IPlayerStateRegistry

void setState(String stateKey, boolean active)  // thread-safe, callable from any thread
boolean getState(String stateKey)               // client thread
void clearState(String stateKey)                // drop the registration

stateKey is modId:stateName (e.g. epicfight:battle_mode) — exactly the string compat JSON reads in itemSuppressKeys[].playerState.

ICameraLookConsumer (0.8.8+)

boolean consumeLook(float yaw, float pitch)
// true  = this frame's look is consumed: Control Flex must not write player rotation
// false = not consumed: Control Flex keeps its normal path

IInteractiveContextRegistrar

void notifyOverlayForeground(String className)   // overlay entered the foreground
void notifyOverlayBackground(String className)   // overlay went back (pairs with foreground)
void clearAll()                                  // fallback: world unload / mod shutdown

className is the fully qualified class name — Control Flex looks it up in the compat JSON overlay table to resolve stick and cursor behavior. Null-check first: getInteractiveContextRegistrar() may be null.

ICompatAssetInstaller

boolean install(String resourcePath, String fileName)
// resourcePath: classpath path inside your jar, e.g. "/assets/mymod/compat/targetmod_keys.json"
// fileName:     target file name inside compat/mods/ or guides/mods/
// returns:      true when installed

Keep reading