blob: cb447d0da258b763d02094e43ddd250a1cfeeac4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import { Component } from '@serpentity/serpentity';
/**
* The contorl mapping object, holds a source and target for the action.
*
* @typedef tControlMap
* @type object
*
* @property {tControlSource} source the source input for the action
* @property {tControlTarget} target the target property for the action
*/
/**
* The definition of an input source
*
* @typedef tControlSource
* @type object
*
* @property {string} type type of input, can be keyboard or gamepad (only keyboard supported atm)
* @property {number} gamepadNumber the number of gamepad to use (unsupported)
* @property {string} gamepadInputSource either axes or buttons
* @property {number} index the input index or keycode
*/
/**
* The definition of an input target
*
* @typedef tControlTarget
* @type object
*
* @property {external:Serpentity:Component} component the component affected by this
* @property {string} property property to affect. For nested properties use dot.notation
* @property {[function]} value a function that takes in the input and outputs a transformed value
*/
/**
* Component that stores the state of motion controls to properties
*
* @extends {external:Serpentity.Component}
* @class ControlMapComponent
* @param {object} config a configuration object to extend.
*/
export default class ControlMapComponent extends Component {
constructor(config) {
super(config);
/**
* The map of actions and controls. An array of mappings
*
* @property {Array<tControlMap>} map
* @instance
* @memberof ControlMapComponent
*/
this.map = this.map || [];
}
};
|