From c54cfb3d145d64abe7c3ebcf90c1874ac3ad78ea Mon Sep 17 00:00:00 2001 From: shaoziyun Date: Wed, 25 May 2022 01:39:59 +0000 Subject: [PATCH] commit msg Signed-off-by: shaoziyun --- .../napi/ohos_multimodalInput_inputDevice.js | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) mode change 100644 => 100755 runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js diff --git a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js old mode 100644 new mode 100755 index 8c5d09d1..97a3106c --- a/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js +++ b/runtime/main/extend/systemplugin/napi/ohos_multimodalInput_inputDevice.js @@ -30,7 +30,8 @@ export function mockInputDevice() { } const EventType = ['changed'] - const DeviceIds = [0, 1, 2, 3, 4, 5, 6, 7] + const DeviceIds = [0, 1, 2, 3, 4] + const GetKeyboardType = 3 const inputDevice = { on: function (...args) { console.warn("inputDevice.on interface mocked in the Previewer. How this interface works on the" + @@ -173,7 +174,31 @@ export function mockInputDevice() { } args[2].call(this, KeystrokeAbilityArr); } - } - } + }, + getKeyboardType: function(...args) { + console.warn("inputDevice.getKeyboardType interface mocked in the Previewer." + + "How this interface works on the" + " Previewer may be different from that on a real device."); + const len = args.length; + if (len < 1 || len > 2) { + console.warn("parameter number error"); + return; + } + if (typeof args[0] !== 'number') { + console.warn("the first parameter error"); + return; + } + if (len == 1) { + return new Promise((resolve, reject) => { + resolve(GetKeyboardType); + }) + } else { + if (typeof args[1] !== 'function') { + console.warn("the second parameter type must be function"); + return; + } + args[1].call(this, GetKeyboardType); + } + }, + }; return inputDevice } \ No newline at end of file