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

20 changes: 20 additions & 0 deletions lib/js/src/rpc/enums/KeyboardEvent.js
Original file line number Diff line number Diff line change
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) 2020, 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 };
10 changes: 10 additions & 0 deletions lib/js/src/rpc/enums/KeyboardLayout.js
Original file line number Diff line number Diff line change
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 };
92 changes: 92 additions & 0 deletions lib/js/src/rpc/structs/ConfigurableKeyboards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2020, 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 number of cofigurable Keys for Special characters.
*/
class ConfigurableKeyboards extends RpcStruct {
/**
* Initalizes an instance of ConfigurableKeyboards.
* @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 {ConfigurableKeyboards} - The class instance for method chaining.
*/
setKeyboardLayout (layout) {
this._validateType(KeyboardLayout, layout);
this.setParameter(ConfigurableKeyboards.KEY_KEYBOARD_LAYOUT, layout);
return this;
}

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

/**
* Set the NumConfigurableKeys
* @param {Number} keys - The desired NumConfigurableKeys.
* @returns {ConfigurableKeyboards} - The class instance for method chaining.
*/
setNumConfigurableKeys (keys) {
this.setParameter(ConfigurableKeyboards.KEY_NUM_CONFIGURABLE_KEYS, keys);
return this;
}

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

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

export { ConfigurableKeyboards };
115 changes: 115 additions & 0 deletions lib/js/src/rpc/structs/KeyboardCapabilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* eslint-disable camelcase */
/*
* Copyright (c) 2020, 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 { ConfigurableKeyboards } from './ConfigurableKeyboards.js';
import { KeyboardLayout } from '../enums/KeyboardLayout.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 SupportedKeyboardLayouts
* @since SmartDeviceLink 7.1.0
* @param {KeyboardLayout[]} layouts - Supported keyboard layouts by HMI. - The desired SupportedKeyboardLayouts.
* {'array_min_size': 1, 'array_max_size': 1000}
* @returns {KeyboardCapabilities} - The class instance for method chaining.
*/
setSupportedKeyboardLayouts (layouts) {
this._validateType(KeyboardLayout, layouts, true);
this.setParameter(KeyboardCapabilities.KEY_SUPPORTED_KEYBOARD_LAYOUTS, layouts);
return this;
}

/**
* Get the SupportedKeyboardLayouts
* @returns {KeyboardLayout[]} - the KEY_SUPPORTED_KEYBOARD_LAYOUTS value
*/
getSupportedKeyboardLayouts () {
return this.getObject(KeyboardLayout, KeyboardCapabilities.KEY_SUPPORTED_KEYBOARD_LAYOUTS);
}

/**
* Set the ConfigurableKeys
* @since SmartDeviceLink 7.1.0
* @param {ConfigurableKeyboards[]} keys - Get Number of Keys for Special characters, App can customize as per their needs. - The desired ConfigurableKeys.
* {'array_min_size': 1, 'array_max_size': 1000}
* @returns {KeyboardCapabilities} - The class instance for method chaining.
*/
setConfigurableKeys (keys) {
this._validateType(ConfigurableKeyboards, keys, true);
this.setParameter(KeyboardCapabilities.KEY_CONFIGURABLE_KEYS, keys);
return this;
}

/**
* Get the ConfigurableKeys
* @returns {ConfigurableKeyboards[]} - the KEY_CONFIGURABLE_KEYS value
*/
getConfigurableKeys () {
return this.getObject(ConfigurableKeyboards, KeyboardCapabilities.KEY_CONFIGURABLE_KEYS);
}
}

KeyboardCapabilities.KEY_MASK_INPUT_CHARACTERS_SUPPORTED = 'maskInputCharactersSupported';
KeyboardCapabilities.KEY_SUPPORTED_KEYBOARD_LAYOUTS = 'supportedKeyboardLayouts';
KeyboardCapabilities.KEY_CONFIGURABLE_KEYS = 'configurableKeys';

export { KeyboardCapabilities };
Loading