mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
add mouse interface
Signed-off-by: wuzhihuitmac <wuzhihui4@huawei.com> Change-Id: I3c5bb0c2777a3513a34623006a34d914d69f5b4d
This commit is contained in:
@@ -30,6 +30,7 @@ export function mockInputMonitor() {
|
||||
localY: 0,
|
||||
size: 2.03
|
||||
}];
|
||||
const pressedButtons = [10, 11 , 12, 13, 14];
|
||||
global.systemplugin.multimodalInput = {};
|
||||
global.systemplugin.multimodalInput.inputMonitor = {
|
||||
on: function (...args) {
|
||||
@@ -38,16 +39,40 @@ export function mockInputMonitor() {
|
||||
clearInterval(this.offInputMonitor);
|
||||
delete this.offInputMonitor;
|
||||
this.offInputMonitor = setInterval(() => {
|
||||
const len = args.length;
|
||||
if (len !== 2 || typeof args[0] !== 'string' || typeof args[len - 1] !== 'function') {
|
||||
console.warn('multimodalInput.inputMonitor.on param invalid.');
|
||||
return;
|
||||
}
|
||||
if (args[0] !== 'touch' && args[0] !== 'mouse') {
|
||||
console.warn('multimodalInput.inputMonitor.on first param should be touch or mouse.');
|
||||
return;
|
||||
}
|
||||
const value = {};
|
||||
value.type = 'up';
|
||||
value.timestamp = 318878;
|
||||
value.deviceId = 0;
|
||||
value.touches = touches;
|
||||
value.changedTouches = changedTouches;
|
||||
const len = args.length;
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
console.warn('multimodalInput.inputMonitor.on callback.');
|
||||
const mouse = {};
|
||||
mouse.type = 'move';
|
||||
mouse.pressedButtons = pressedButtons;
|
||||
mouse.displayId = 20;
|
||||
mouse.targetWindowId = 21;
|
||||
mouse.agentWindowId = 22;
|
||||
mouse.localX = 450;
|
||||
mouse.localY = 736;
|
||||
mouse.globalX = 450;
|
||||
mouse.globalY = 784;
|
||||
mouse.timestamp = 55670246;
|
||||
mouse.axisVerticalValue = 15;
|
||||
mouse.axisHorizontalValue = 20;
|
||||
if (args[0] === 'touch') {
|
||||
console.warn('multimodalInput.inputMonitor.on touch callback.');
|
||||
args[len - 1].call(this, value);
|
||||
} else if (args[0] === 'mouse') {
|
||||
console.warn('multimodalInput.inputMonitor.on mouse callback.');
|
||||
args[len - 1].call(this, mouse);
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user