input-device-handler - v9.0.4
    Preparing search index...

    Class InputDeviceHandler

    The main export of this package. Construct one to start listening to and handling input devices.

    Hierarchy

    Index
    currentKeyboardInputs: {
        [key: string]: Readonly<
            {
                details: Readonly<SpecificInputDetails>;
                deviceKey: "keyboard";
                deviceName: string;
                deviceType: InputDeviceType;
                inputName: string;
                inputValue: number;
            },
        >;
    } = {}
    currentLoopIndex: number = -1
    currentMouseInputs: {
        [key: string]: Readonly<
            {
                details: Readonly<SpecificInputDetails>;
                deviceKey: "mouse";
                deviceName: string;
                deviceType: InputDeviceType;
                inputName: string;
                inputValue: number;
            },
        >;
    } = {}
    gamepadDeadZoneSettings: AllGamepadDeadZoneSettings = {}
    globalDeadZone: number = 0
    lastEventDetails: Partial<
        Record<
            DeviceHandlerEventType,
            {
                constructor: DeviceHandlerEventConstructor;
                constructorInputs: Parameters<
                    DeviceHandlerEventConstructor["constructIfDataIsNew"],
                >;
            },
        >,
    > = {}
    lastReadInputDevices: AllDevices

    Make sure this is set after the other member variables.

    This is not-null asserted because updateInputDevices, which sets it, is called in the constructor.

    loopIsRunning: boolean = false
    • Updates the internal state of all current devices and triggers all relevant listeners.

      Use this if method if you're hooking up polling to your own system. For example, if you already have a render loop, call this method to update all inputs and read their values.

      If you just want to read the last values but already have InputDeviceHandler running its loop, instead call getLastPollResults.

      Parameters

      • deadZoneSettings: Readonly<{ [key: string]: Readonly<{ [inputName: string]: number }> }> = ...
      • timestamp: number = ...
      • globalDeadZone: number = ...

        DeadZone for all inputs.

      Returns AllDevices

    • Reads device values continuously while the polling loop is active.

      Parameters

      • __namedParameters: Readonly<{ loopIndex: number; timestamp: number }>

      Returns void