import KeyboardHandler from "./handler/keyboard_handler.js";
import MouseHandler from "./handler/mouse_handler.js";
import EventHandler from "../event/event_handler.js";
/**
* @module InputManager
* @fileoverview Contains InputManager class.
*/
/**
* Root input manager. For use globally and in actor components.
* @class
*/
class InputManager {
/**
* Create a new input manager.
* @param {EventHandler|null} Parent event handler (optional)
* @param {function} condition Function for checking whether events should run
* @constructor
*/
constructor({
parentHandler = null,
condition = () => { return true; }
} = {}) {
if (parentHandler === null)
parentHandler = new EventHandler();
/**
* Keyboard input handler.
* @type {KeyboardHandler}
* @private
*/
this._keyboard = new KeyboardHandler(parentHandler, condition);
/**
* Mouse input handler.
* @type {MouseHandler}
* @private
*/
this._mouse = new MouseHandler(parentHandler, condition);
}
/**
* Handle removing listeners from document.
*/
destructor() {
this._keyboard.destructor();
this._mouse.destructor();
}
// Getters
/**
* Get the keyboard input handler.
* @returns {KeyboardHandler} Keyboard input handler
*/
get keyboard() {
return this._keyboard;
}
/**
* Get the mouse input handler.
* @returns {MouseHandler} Mouse input handler
*/
get mouse() {
return this._mouse;
}
}
export default InputManager;