Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDL-0238] Keyboard Enhancements #366

22 changes: 21 additions & 1 deletion lib/js/src/rpc/enums/KeyboardEvent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2020, SmartDeviceLink Consortium, Inc.
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -88,6 +88,24 @@ class KeyboardEvent extends Enum {
return KeyboardEvent._MAP.ENTRY_ABORTED;
}

/**
* Get the enum value for INPUT_KEY_MASK_ENABLED.
* @since SmartDeviceLink 7.1.0
* @returns {String} - The enum value.
*/
static get INPUT_KEY_MASK_ENABLED () {
return KeyboardEvent._MAP.INPUT_KEY_MASK_ENABLED;
}

/**
* Get the enum value for INPUT_KEY_MASK_DISABLED.
* @since SmartDeviceLink 7.1.0
* @returns {String} - The enum value.
*/
static get INPUT_KEY_MASK_DISABLED () {
return KeyboardEvent._MAP.INPUT_KEY_MASK_DISABLED;
}

/**
* Get the value for the given enum key
* @param {*} key - A key to find in the map of the subclass
Expand Down Expand Up @@ -121,6 +139,8 @@ KeyboardEvent._MAP = Object.freeze({
'ENTRY_VOICE': 'ENTRY_VOICE',
'ENTRY_CANCELLED': 'ENTRY_CANCELLED',
'ENTRY_ABORTED': 'ENTRY_ABORTED',
'INPUT_KEY_MASK_ENABLED': 'INPUT_KEY_MASK_ENABLED',
'INPUT_KEY_MASK_DISABLED': 'INPUT_KEY_MASK_DISABLED',
});

export { KeyboardEvent };
108 changes: 108 additions & 0 deletions lib/js/src/rpc/enums/KeyboardInputMask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

import { Enum } from '../../util/Enum.js';

/**
* Enumeration listing possible input character masking.
* @typedef {Enum} KeyboardInputMask
* @property {Object} _MAP
*/
class KeyboardInputMask extends Enum {
/**
* Constructor for KeyboardInputMask.
* @class
* @since SmartDeviceLink 7.1.0
*/
constructor () {
super();
}

/**
* Get the enum value for ENABLE_INPUT_KEY_MASK.
* @returns {String} - The enum value.
*/
static get ENABLE_INPUT_KEY_MASK () {
return KeyboardInputMask._MAP.ENABLE_INPUT_KEY_MASK;
}

/**
* Get the enum value for DISABLE_INPUT_KEY_MASK.
* @returns {String} - The enum value.
*/
static get DISABLE_INPUT_KEY_MASK () {
return KeyboardInputMask._MAP.DISABLE_INPUT_KEY_MASK;
}

/**
* Get the enum value for USER_CHOICE_INPUT_KEY_MASK.
* @returns {String} - The enum value.
*/
static get USER_CHOICE_INPUT_KEY_MASK () {
return KeyboardInputMask._MAP.USER_CHOICE_INPUT_KEY_MASK;
}

/**
* Get the value for the given enum key
* @param {*} key - A key to find in the map of the subclass
* @returns {*} - Returns a value if found, or null if not found
*/
static valueForKey (key) {
return KeyboardInputMask._valueForKey(key, KeyboardInputMask._MAP);
}

/**
* Get the key for the given enum value
* @param {*} value - A primitive value to find the matching key for in the map of the subclass
* @returns {*} - Returns a key if found, or null if not found
*/
static keyForValue (value) {
return KeyboardInputMask._keyForValue(value, KeyboardInputMask._MAP);
}

/**
* Retrieve all enumerated values for this class
* @returns {*} - Returns an array of values
*/
static values () {
return Object.values(KeyboardInputMask._MAP);
}
}

KeyboardInputMask._MAP = Object.freeze({
'ENABLE_INPUT_KEY_MASK': 'ENABLE_INPUT_KEY_MASK',
'DISABLE_INPUT_KEY_MASK': 'DISABLE_INPUT_KEY_MASK',
'USER_CHOICE_INPUT_KEY_MASK': 'USER_CHOICE_INPUT_KEY_MASK',
});

export { KeyboardInputMask };
12 changes: 11 additions & 1 deletion lib/js/src/rpc/enums/KeyboardLayout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2020, SmartDeviceLink Consortium, Inc.
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -72,6 +72,15 @@ class KeyboardLayout extends Enum {
return KeyboardLayout._MAP.AZERTY;
}

/**
* Get the enum value for NUMERIC.
* @since SmartDeviceLink 7.1.0
* @returns {String} - The enum value.
*/
static get NUMERIC () {
return KeyboardLayout._MAP.NUMERIC;
}

/**
* Get the value for the given enum key
* @param {*} key - A key to find in the map of the subclass
Expand Down Expand Up @@ -103,6 +112,7 @@ KeyboardLayout._MAP = Object.freeze({
'QWERTY': 'QWERTY',
'QWERTZ': 'QWERTZ',
'AZERTY': 'AZERTY',
'NUMERIC': 'NUMERIC',
});

export { KeyboardLayout };
91 changes: 91 additions & 0 deletions lib/js/src/rpc/structs/KeyboardCapabilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

import { KeyboardLayoutCapability } from './KeyboardLayoutCapability.js';
import { RpcStruct } from '../RpcStruct.js';

class KeyboardCapabilities extends RpcStruct {
/**
* Initalizes an instance of KeyboardCapabilities.
* @class
* @param {object} parameters - An object map of parameters.
* @since SmartDeviceLink 7.1.0
*/
constructor (parameters) {
super(parameters);
}

/**
* Set the MaskInputCharactersSupported
* @since SmartDeviceLink 7.1.0
* @param {Boolean} supported - Availability of capability to mask input characters using keyboard. True: Available, False: Not Available - The desired MaskInputCharactersSupported.
* @returns {KeyboardCapabilities} - The class instance for method chaining.
*/
setMaskInputCharactersSupported (supported) {
this.setParameter(KeyboardCapabilities.KEY_MASK_INPUT_CHARACTERS_SUPPORTED, supported);
return this;
}

/**
* Get the MaskInputCharactersSupported
* @returns {Boolean} - the KEY_MASK_INPUT_CHARACTERS_SUPPORTED value
*/
getMaskInputCharactersSupported () {
return this.getParameter(KeyboardCapabilities.KEY_MASK_INPUT_CHARACTERS_SUPPORTED);
}

/**
* Set the SupportedKeyboards
* @param {KeyboardLayoutCapability[]} keyboards - Capabilities of supported keyboard layouts by HMI. - The desired SupportedKeyboards.
* {'array_min_size': 1, 'array_max_size': 1000}
* @returns {KeyboardCapabilities} - The class instance for method chaining.
*/
setSupportedKeyboards (keyboards) {
this._validateType(KeyboardLayoutCapability, keyboards, true);
this.setParameter(KeyboardCapabilities.KEY_SUPPORTED_KEYBOARDS, keyboards);
return this;
}

/**
* Get the SupportedKeyboards
* @returns {KeyboardLayoutCapability[]} - the KEY_SUPPORTED_KEYBOARDS value
*/
getSupportedKeyboards () {
return this.getObject(KeyboardLayoutCapability, KeyboardCapabilities.KEY_SUPPORTED_KEYBOARDS);
}
}

KeyboardCapabilities.KEY_MASK_INPUT_CHARACTERS_SUPPORTED = 'maskInputCharactersSupported';
KeyboardCapabilities.KEY_SUPPORTED_KEYBOARDS = 'supportedKeyboards';

export { KeyboardCapabilities };
93 changes: 93 additions & 0 deletions lib/js/src/rpc/structs/KeyboardLayoutCapability.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2021, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

import { KeyboardLayout } from '../enums/KeyboardLayout.js';
import { RpcStruct } from '../RpcStruct.js';

/**
* Describes the capabilities of a single keyboard layout.
*/
class KeyboardLayoutCapability extends RpcStruct {
/**
* Initalizes an instance of KeyboardLayoutCapability.
* @class
* @param {object} parameters - An object map of parameters.
* @since SmartDeviceLink 7.1.0
*/
constructor (parameters) {
super(parameters);
}

/**
* Set the KeyboardLayout
* @param {KeyboardLayout} layout - Enumeration listing possible keyboard layouts. - The desired KeyboardLayout.
* @returns {KeyboardLayoutCapability} - The class instance for method chaining.
*/
setKeyboardLayout (layout) {
this._validateType(KeyboardLayout, layout);
this.setParameter(KeyboardLayoutCapability.KEY_KEYBOARD_LAYOUT, layout);
return this;
}

/**
* Get the KeyboardLayout
* @returns {KeyboardLayout} - the KEY_KEYBOARD_LAYOUT value
*/
getKeyboardLayout () {
return this.getObject(KeyboardLayout, KeyboardLayoutCapability.KEY_KEYBOARD_LAYOUT);
}

/**
* Set the NumConfigurableKeys
* @param {Number} keys - Number of keys available for special characters, App can customize as per their needs. - The desired NumConfigurableKeys.
* {'num_min_value': 0, 'num_max_value': 10}
* @returns {KeyboardLayoutCapability} - The class instance for method chaining.
*/
setNumConfigurableKeys (keys) {
this.setParameter(KeyboardLayoutCapability.KEY_NUM_CONFIGURABLE_KEYS, keys);
return this;
}

/**
* Get the NumConfigurableKeys
* @returns {Number} - the KEY_NUM_CONFIGURABLE_KEYS value
*/
getNumConfigurableKeys () {
return this.getParameter(KeyboardLayoutCapability.KEY_NUM_CONFIGURABLE_KEYS);
}
}

KeyboardLayoutCapability.KEY_KEYBOARD_LAYOUT = 'keyboardLayout';
KeyboardLayoutCapability.KEY_NUM_CONFIGURABLE_KEYS = 'numConfigurableKeys';

export { KeyboardLayoutCapability };
Loading