refactor: pointerMove
This commit is contained in:
parent
9b79c079a5
commit
bc725229e5
|
@ -7,7 +7,7 @@ const decorate = compose(
|
|||
export default class ActionRegistry extends decorate(Class) {
|
||||
|
||||
$$listen = {
|
||||
joystick: {},
|
||||
joystickMove: {},
|
||||
key: {},
|
||||
button: {},
|
||||
wheel: {},
|
||||
|
@ -25,13 +25,11 @@ export default class ActionRegistry extends decorate(Class) {
|
|||
const [action, candidates] = entries[i];
|
||||
for (let j = 0; j < candidates.length; ++j) {
|
||||
const {index, type, ...rest} = candidates[j];
|
||||
if ('joystick' === type) {
|
||||
if (this.$$listen[type][index]) {
|
||||
this.$$listen[type][index].push({action, ...rest});
|
||||
}
|
||||
else {
|
||||
this.$$listen[type][index] = [{action, ...rest}];
|
||||
if ('joystickMove' === type) {
|
||||
if (!this.$$listen[type][index]) {
|
||||
this.$$listen[type][index] = [];
|
||||
}
|
||||
this.$$listen[type][index].push({action, ...rest});
|
||||
}
|
||||
else {
|
||||
this.$$listen[type][index] = {action};
|
||||
|
@ -70,22 +68,22 @@ export default class ActionRegistry extends decorate(Class) {
|
|||
|
||||
onInput(type, input, value, transforming) {
|
||||
if (this.$$listen[type][input]) {
|
||||
if ('joystick' === type) {
|
||||
if ('joystickMove' === type) {
|
||||
for (let i = 0; i < this.$$listen[type][input].length; i++) {
|
||||
const {action, axis} = this.$$listen[type][input][i];
|
||||
if (
|
||||
(axis > 0 && value > 0)
|
||||
|| (axis < 0 && value < 0)
|
||||
(axis > 0 && value > 0.01)
|
||||
|| (axis < 0 && value < 0.01)
|
||||
) {
|
||||
this.$$stream.push({
|
||||
action,
|
||||
value: this.transform(action, value * axis, 'joystick'),
|
||||
value: this.transform(action, value * axis, 'joystickMove'),
|
||||
});
|
||||
}
|
||||
else if (0 === value) {
|
||||
this.$$stream.push({
|
||||
action,
|
||||
value: this.transform(action, value, 'joystick'),
|
||||
value: this.transform(action, value, 'joystickMove'),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +99,7 @@ export default class ActionRegistry extends decorate(Class) {
|
|||
}
|
||||
|
||||
onJoystickMove(index, value) {
|
||||
this.onInput('joystick', index, value * (10 / 9));
|
||||
this.onInput('joystickMove', index, value * (10 / 9));
|
||||
}
|
||||
|
||||
onKeyDown(key) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user