Files
cocos4/platforms/runtime/common/engine/InputManager.js
T
PP 0a836ac458 optimize sys info init && move in runtime adapters (#7920)
* optimize sys info init in adapters

update

* update sys init

update sys

* fix sys access

* optimize isWebIOS14OrIPadOS14Env

* update

* update

* update QTT adapter

* update sys.capacities

update sys

* update common && qtt

* add downloadFile to job module

* update engine-adapter

* update DeviceMotionEvent  adaption

* remove legacy qtt

* add link-sure adaption

* fix some bug

* update vivo adaption && fs-utils

* remove legacy link-sure

* remove dom-adapter

* remove HTMLCanvas appended to document

* update vivo

* support COCOS_PLAY

* update adapters to platforms

* remove test code

* add OPPO adapter

* add huawei adapter

* remove test code

* rename folder oppo-mini-game

* rename  folder huawei-quick-game

* rename folder vivo-mini-game
2020-12-15 11:54:13 +08:00

53 lines
1.3 KiB
JavaScript

const mgr = cc.internal.inputManager;
const canvasPosition = {
left: 0,
top: 0,
};
Object.defineProperties(canvasPosition, {
width: {
get () {
return window.innerWidth;
},
},
height: {
get () {
return window.innerHeight;
},
},
});
if (mgr) {
Object.assign(mgr, {
_updateCanvasBoundingRect () {},
registerSystemEvent (element) {
if(this._isRegisterEvent) return;
this._glView = cc.view;
let self = this;
//register touch event
let _touchEventsMap = {
onTouchStart: this.handleTouchesBegin,
onTouchMove: this.handleTouchesMove,
onTouchEnd: this.handleTouchesEnd,
onTouchCancel: this.handleTouchesCancel,
};
let registerTouchEvent = function (eventName) {
let handler = _touchEventsMap[eventName];
jsb[eventName](function (event) {
if (!event.changedTouches) return;
handler.call(self, self.getTouchesByEvent(event, canvasPosition));
});
};
for (let eventName in _touchEventsMap) {
registerTouchEvent(eventName);
}
this._isRegisterEvent = true;
},
});
}