xScal Scaleform API 0.4.34

Input: text

One owned text-input session at a time. While a session exists, xScal consumes keyboard key, character and raw-input messages before Fallout 76 gets them; mouse raw input still reaches the game. The native buffer holds at most 512 UTF-16 code units. A key still held when the session ends stays consumed until its key-up message.

var begin:Object = JSON.parse(__SFCodeObj.call("Input.BeginInput"));
if (begin.success) {
    var sessionId:uint = uint(begin.sessionId);
    // From a timer or frame callback:
    var current:Object = JSON.parse(
        __SFCodeObj.call("Input.PollInput", sessionId));
    if (current.state == "submitted") {
        sendMessage(String(current.text));
        __SFCodeObj.call("Input.EndInput", sessionId);
    } else if (current.state == "cancelled") {
        __SFCodeObj.call("Input.EndInput", sessionId);
    }
}

Input.BeginInput

Start the owned text-input session

__SFCodeObj.call("Input.BeginInput"):String

No arguments.

Returns String (JSON)

FieldTypeDescription
successtrue
sessionIdint
revisionintIncrements on text changes, cursor moves, Enter and Escape.
textStringCurrent text, UTF-8.
caretIndexintCursor position in UTF-16 code units, the same unit as AS3 String indexes. A surrogate pair counts as two. Read-only; Left, Right, Home and End move it.
state"active" | "submitted" | "cancelled"Enter sets submitted, Escape sets cancelled.

Sample result

{"success":true,"sessionId":1,"revision":0,"text":"","caretIndex":0,"state":"active"}

Returns {"success":false,"error":"input_unavailable"} when another session is active or the Fallout 76 window cannot be attached.

Input.PollInput

Read the session's text, cursor and state

__SFCodeObj.call("Input.PollInput", sessionId:uint):String

Arguments

NameTypeDescription
sessionIduintSession ID from Input.BeginInput.

Returns String (JSON)

FieldTypeDescription
successtrue
sessionIdint
revisionintIncrements on text changes, cursor moves, Enter and Escape.
textStringCurrent text, UTF-8.
caretIndexintCursor position in UTF-16 code units, the same unit as AS3 String indexes. A surrogate pair counts as two. Read-only; Left, Right, Home and End move it.
state"active" | "submitted" | "cancelled"Enter sets submitted, Escape sets cancelled.

Sample result

{"success":true,"sessionId":1,"revision":3,"text":"hello","caretIndex":5,"state":"active"}

Invalid or stale session IDs return {"success":false,"error":"invalid_session"}.

Input.EndInput

Close the session

__SFCodeObj.call("Input.EndInput", sessionId:uint):String

Arguments

NameTypeDescription
sessionIduintSession ID from Input.BeginInput.

Returns String (JSON)

FieldTypeDescription
successtrue
sessionIdint

Sample result

{"success":true,"sessionId":1}

The session stays allocated after Enter or Escape until this call succeeds. Invalid or stale session IDs return {"success":false,"error":"invalid_session"}.