"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogBody = exports.InputBody = exports.SetClipboardText = exports.ViewportResize = exports.PenAbsolute = exports.TouchesAbsolute = exports.Touch = exports.PointerInfo = exports.LogicalInput = exports.KeyboardInput = exports.MouseScroll = exports.MouseClick = exports.MouseRelative = exports.MouseAbsolute = exports.GamepadRumble = exports.GamepadReport = void 0;
const ref_napi_1 = __importDefault(require("ref-napi"));
const ref_array_di_1 = __importDefault(require("ref-array-di"));
const rainway_ffi_1 = require("./rainway-ffi");
const RainwayTouchAbsoluteArray = (0, ref_array_di_1.default)(ref_napi_1.default)(rainway_ffi_1.RainwayTouchAbsoluteDef);
const RainwayVirtualKeyArray = (0, ref_array_di_1.default)(ref_napi_1.default)(rainway_ffi_1.RainwayVirtualKeyDef);
/**
 * An input report describing gamepad input.
 */
class GamepadReport {
    /** @internal */
    constructor(body) {
        this.buttons = body.buttons;
        this.leftTrigger = body.leftTrigger;
        this.rightTrigger = body.rightTrigger;
        this.leftThumbX = body.leftThumbX;
        this.leftThumbY = body.leftThumbY;
        this.rightThumbX = body.rightThumbX;
        this.rightThumbY = body.rightThumbY;
        this.slot = body.slot;
    }
}
exports.GamepadReport = GamepadReport;
/**
 *  An input report describing gamepad rumble.
 */
class GamepadRumble {
    /** @internal */
    constructor(body) {
        this.port = body.port;
        this.leftMotorSpeed = body.leftMotorSpeed;
        this.rightMotorSpeed = body.rightMotorSpeed;
    }
}
exports.GamepadRumble = GamepadRumble;
/**
 *  An input report describing absolute mouse position input.
 */
class MouseAbsolute {
    /** @internal */
    constructor(body) {
        this.x = body.x;
        this.y = body.y;
    }
}
exports.MouseAbsolute = MouseAbsolute;
/**
 * An input report describing relative mouse position input.
 */
class MouseRelative {
    /** @internal */
    constructor(body) {
        this.dx = body.dx;
        this.dy = body.dy;
    }
}
exports.MouseRelative = MouseRelative;
/**
 *  An input report describing mouse click input.
 */
class MouseClick {
    /** @internal */
    constructor(body) {
        this.action = body.action;
        this.button = body.button;
    }
}
exports.MouseClick = MouseClick;
/**
 * An input report describing mouse scroll input.
 */
class MouseScroll {
    /** @internal */
    constructor(body) {
        this.axis = body.axis;
        this.delta = body.delta;
    }
}
exports.MouseScroll = MouseScroll;
/**
 *  An input report describing keyboard input.
 */
class KeyboardInput {
    /** @internal */
    constructor(body) {
        this.action = body.action;
        this.keycode = body.keycode;
    }
}
exports.KeyboardInput = KeyboardInput;
/**
 * An input report describing logical input.
 */
class LogicalInput {
    /** @internal */
    constructor(body) {
        var _a;
        this.inputString = (_a = body.inputString) !== null && _a !== void 0 ? _a : "";
    }
}
exports.LogicalInput = LogicalInput;
/**
 * Information about a pointer.
 */
class PointerInfo {
    /** @internal */
    constructor(info) {
        this.pointerId = info.pointerId;
        this.frameId = info.frameId;
        this.pointerFlags = info.pointerFlags;
        this.x = info.x;
        this.y = info.y;
    }
}
exports.PointerInfo = PointerInfo;
/**
 * Information about touch.
 */
class Touch {
    /** @internal */
    constructor(touch) {
        this.pointerInfo = new PointerInfo(touch.pointerInfo);
        this.touchMask = touch.touchMask;
        this.contactLeft = touch.contactLeft;
        this.contactTop = touch.contactTop;
        this.contactRight = touch.contactRight;
        this.contactBottom = touch.contactBottom;
        this.orientation = touch.orientation;
        this.pressure = touch.pressure;
    }
}
exports.Touch = Touch;
/**
 *  An input report describing absolute positioned touch input.
 */
class TouchesAbsolute {
    /** @internal */
    constructor(body) {
        const arr = new RainwayTouchAbsoluteArray(body.touches, Number(body.numTouches).valueOf());
        this.touches = arr.toArray();
    }
}
exports.TouchesAbsolute = TouchesAbsolute;
/**
 *  An input report describing absolute positioned pen input.
 */
class PenAbsolute {
    /** @internal */
    constructor(body) {
        this.pointerId = body.pointerId;
        this.frameId = body.frameId;
        this.pointerFlags = body.pointerFlags;
        this.x = body.x;
        this.y = body.y;
        this.penFlags = body.penFlags;
        this.penMask = body.penMask;
        this.pressure = body.pressure;
        this.rotation = body.rotation;
        this.tiltX = body.tiltX;
        this.tiltY = body.tiltY;
    }
}
exports.PenAbsolute = PenAbsolute;
/**
 * An input report describing viewport resize changes.
 */
class ViewportResize {
    /** @internal */
    constructor(body) {
        this.width = body.width;
        this.height = body.height;
    }
}
exports.ViewportResize = ViewportResize;
/**
 * An input report describing clipboard text changes.
 */
class SetClipboardText {
    /** @internal */
    constructor(body) {
        var _a;
        this.text = (_a = body.text) !== null && _a !== void 0 ? _a : "";
    }
}
exports.SetClipboardText = SetClipboardText;
/**
 * The body of an input event.
 */
class InputBody {
    /** @internal */
    constructor(native, heldKeys, heldKeysLength) {
        this._native = native.deref();
        const arr = new RainwayVirtualKeyArray(heldKeys, heldKeysLength);
        this.heldKeys = arr.toArray();
    }
    /**
     * A tag identifying the type of input.
     */
    get tag() {
        return this._native.tag;
    }
    /**
     * Retrieve the input as a gamepad report.
     * @returns - gamepad report
     */
    AsGamepadReport() {
        return new GamepadReport(this._native.union.GAMEPAD_REPORT);
    }
    /**
     * Retrieve the input as a gamepad rumble.
     * @returns - gamepad rumble
     */
    AsGamepadRumble() {
        return new GamepadRumble(this._native.union.GAMEPAD_RUMBLE);
    }
    /**
     * Retrieve the input as a mouse absolute.
     * @returns - mouse absolute
     */
    AsMouseAbsolute() {
        return new MouseAbsolute(this._native.union.MOUSE_ABSOLUTE);
    }
    /**
     * Retrieve the input as a mouse relative.
     * @returns - mouse relative
     */
    AsMouseRelative() {
        return new MouseRelative(this._native.union.MOUSE_RELATIVE);
    }
    /**
     * Retrieve the input as a mouse click.
     * @returns - mouse click
     */
    AsMouseClick() {
        return new MouseClick(this._native.union.MOUSE_CLICK);
    }
    /**
     * Retrieve the input as a mouse scroll.
     * @returns - mouse scroll
     */
    AsMouseScroll() {
        return new MouseScroll(this._native.union.MOUSE_SCROLL);
    }
    /**
     * Retrieve the input as a keyboard input.
     * @returns - keyboard input
     */
    AsKeyboardInput() {
        return new KeyboardInput(this._native.union.KEYBOARD_INPUT);
    }
    /**
     * Retrieve the input as a logical input.
     * @returns - logical input
     */
    AsLogicalInput() {
        return new LogicalInput(this._native.union.LOGICAL_INPUT);
    }
    /**
     * Retrieve the input as a touches absolute.
     * @returns - touches absolute
     */
    AsTouchesAbsolute() {
        return new TouchesAbsolute(this._native.union.TOUCHES_ABSOLUTE);
    }
    /**
     * Retrieve the input as a pen absolute.
     * @returns - pen absolute
     */
    AsPenAbsolute() {
        return new PenAbsolute(this._native.union.PEN_ABSOLUTE);
    }
    /**
     * Retrieve the input as a viewport resize.
     * @returns - viewport resize
     */
    AsViewportResize() {
        return new ViewportResize(this._native.union.VIEWPORT_RESIZE);
    }
    /**
     * Retrieve the input as clipboard text.
     * @returns - clipboard text
     */
    AsSetClipboardText() {
        return new SetClipboardText(this._native.union.SET_CLIPBOARD_TEXT);
    }
}
exports.InputBody = InputBody;
/**
 *  The body of a log.
 */
class LogBody {
    /** @internal */
    constructor(level, target, message) {
        this.level = level;
        this.target = target;
        this.message = message;
    }
}
exports.LogBody = LogBody;
//# sourceMappingURL=models.js.map