From 0ca535e3c5c0a2a69dd284bc3afbd89685f363bc Mon Sep 17 00:00:00 2001 From: Yoichiro Date: Wed, 6 Sep 2023 21:03:28 +0900 Subject: [PATCH] Fix the issue what can't start. --- .../catalog/keyboard/keymap/Catalogkeymap.tsx | 2 +- .../configure/customkey/CustomKey.stories.tsx | 2 +- .../configure/customkey/CustomKey.tsx | 2 +- .../configure/customkey/Modifiers.tsx | 3 +- src/components/configure/customkey/TabKey.tsx | 2 +- src/components/configure/keycodekey/KeyGen.ts | 11 +- .../configure/keymap/Keymap.stories.tsx | 2 +- src/services/hid/Composition.test.ts | 3 +- src/services/hid/Composition.ts | 28 +---- src/services/hid/Constraints.ts | 28 +++++ src/services/hid/Hid.mock.ts | 3 +- src/services/hid/KeycodeList.ts | 3 +- .../hid/compositions/AsciiComposition.ts | 3 +- .../hid/compositions/BasicComposition.ts | 3 +- .../hid/compositions/DefLayerComposition.ts | 3 +- .../hid/compositions/LayerModComposition.ts | 3 +- .../hid/compositions/LayerTapComposition.ts | 8 +- .../compositions/LayerTapToggleComposition.ts | 3 +- .../compositions/LooseKeycodeComposition.ts | 15 +-- .../hid/compositions/MacroComposition.ts | 3 +- .../hid/compositions/ModTapComposition.ts | 4 +- .../hid/compositions/MomentaryComposition.ts | 3 +- .../compositions/OneShotLayerComposition.ts | 3 +- .../hid/compositions/OneShotModComposition.ts | 9 +- .../hid/compositions/SwapHandsComposition.ts | 9 +- .../hid/compositions/ToComposition.ts | 3 +- .../compositions/ToggleLayerComposition.ts | 3 +- .../ViaUserKeyComposition.test.ts | 2 +- .../hid/compositions/ViaUserKeyComposition.ts | 3 +- src/services/macro/Macro.test.ts | 2 +- src/store/reducers.ts | 104 +++++++++--------- 31 files changed, 134 insertions(+), 141 deletions(-) create mode 100644 src/services/hid/Constraints.ts diff --git a/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx b/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx index 50ccb8b9..9211ff2a 100644 --- a/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx +++ b/src/components/catalog/keyboard/keymap/Catalogkeymap.tsx @@ -7,7 +7,6 @@ import { import KeyboardModel from '../../../../models/KeyboardModel'; import KeyModel from '../../../../models/KeyModel'; import { IKeymap } from '../../../../services/hid/Hid'; -import { MOD_LEFT } from '../../../../services/hid/Composition'; import Keycap from '../../../configure/keycap/Keycap.container'; import { Grid, IconButton, Paper, Tooltip, Typography } from '@mui/material'; import { AbstractKeymapData } from '../../../../services/storage/Storage'; @@ -20,6 +19,7 @@ import { KeymapPdfGenerator } from '../../../../services/pdf/KeymapPdfGenerator' import { sendEventToGoogleAnalytics } from '../../../../utils/GoogleAnalytics'; import LayerPagination from '../../../common/layer/LayerPagination'; import { useNavigate } from 'react-router-dom'; +import { MOD_LEFT } from '../../../../services/hid/Constraints'; type OwnProps = {}; type CatalogKeymapProps = OwnProps & diff --git a/src/components/configure/customkey/CustomKey.stories.tsx b/src/components/configure/customkey/CustomKey.stories.tsx index 863d1ad9..e6355c60 100644 --- a/src/components/configure/customkey/CustomKey.stories.tsx +++ b/src/components/configure/customkey/CustomKey.stories.tsx @@ -5,7 +5,7 @@ import CustomKey from './CustomKey'; import Keycap from '../keycap/Keycap'; import KeyModel from '../../../models/KeyModel'; import { Key } from '../keycodekey/KeyGen'; -import { MOD_LEFT } from '../../../services/hid/Composition'; +import { MOD_LEFT } from '../../../services/hid/Constraints'; export default { title: 'CustomKey', diff --git a/src/components/configure/customkey/CustomKey.tsx b/src/components/configure/customkey/CustomKey.tsx index 2db4efc3..29c25b70 100644 --- a/src/components/configure/customkey/CustomKey.tsx +++ b/src/components/configure/customkey/CustomKey.tsx @@ -8,7 +8,6 @@ import TabKey from './TabKey.container'; import { DIRECTION_LABELS, MOD_LABELS, - MOD_LEFT, } from '../../../services/hid/Composition'; import TabHoldTapKey, { buildHoldKeyLabel } from './TabHoldTapKey'; import { ICustomKeycode, IKeymap } from '../../../services/hid/Hid'; @@ -23,6 +22,7 @@ import { ModsComposition } from '../../../services/hid/compositions/ModsComposit import { LayerTapComposition } from '../../../services/hid/compositions/LayerTapComposition'; import { SwapHandsComposition } from '../../../services/hid/compositions/SwapHandsComposition'; import { ModTapComposition } from '../../../services/hid/compositions/ModTapComposition'; +import { MOD_LEFT } from '../../../services/hid/Constraints'; export const CUSTOMKEY_POPOVER_WIDTH = 400; export const CUSTOMKEY_POPOVER_HEIGHT = 240; diff --git a/src/components/configure/customkey/Modifiers.tsx b/src/components/configure/customkey/Modifiers.tsx index 45a6df45..8b5612fc 100644 --- a/src/components/configure/customkey/Modifiers.tsx +++ b/src/components/configure/customkey/Modifiers.tsx @@ -14,10 +14,9 @@ import { MOD_ALT, MOD_CTL, MOD_GUI, - MOD_LEFT, - MOD_RIGHT, MOD_SFT, } from '../../../services/hid/Composition'; +import { MOD_LEFT, MOD_RIGHT } from '../../../services/hid/Constraints'; type OwnProps = { mods: IMod[]; diff --git a/src/components/configure/customkey/TabKey.tsx b/src/components/configure/customkey/TabKey.tsx index b4fab1b1..fdadbecc 100644 --- a/src/components/configure/customkey/TabKey.tsx +++ b/src/components/configure/customkey/TabKey.tsx @@ -4,7 +4,6 @@ import { IMod, IModDirection, KeycodeCompositionFactory, - MOD_LEFT, } from '../../../services/hid/Composition'; import AutocompleteKeys from './AutocompleteKeys'; @@ -18,6 +17,7 @@ import { ModsComposition } from '../../../services/hid/compositions/ModsComposit import { OneShotModComposition } from '../../../services/hid/compositions/OneShotModComposition'; import { SwapHandsComposition } from '../../../services/hid/compositions/SwapHandsComposition'; import { LayerModComposition } from '../../../services/hid/compositions/LayerModComposition'; +import { MOD_LEFT } from '../../../services/hid/Constraints'; type OwnProps = { autoFocus: boolean; diff --git a/src/components/configure/keycodekey/KeyGen.ts b/src/components/configure/keycodekey/KeyGen.ts index ca4d4a57..b3f42ac0 100644 --- a/src/components/configure/keycodekey/KeyGen.ts +++ b/src/components/configure/keycodekey/KeyGen.ts @@ -1,20 +1,15 @@ import { getMetaLabel, KeyLabel } from '../../../services/labellang/KeyLabel'; -import { - IMod, - MOD_ALT, - MOD_LEFT, - MOD_RIGHT, - MOD_SFT, -} from '../../../services/hid/Composition'; +import { IMod, MOD_ALT, MOD_SFT } from '../../../services/hid/Composition'; import { IKeymap } from '../../../services/hid/Hid'; import { hexadecimal } from '../../../utils/StringUtils'; import { + KEY_LABEL_LANGS, KeyboardLabelLang, KeyLabelLangs, - KEY_LABEL_LANGS, } from '../../../services/labellang/KeyLabelLangs'; import { mods2Number } from '../customkey/Modifiers'; import _ from 'lodash'; +import { MOD_LEFT, MOD_RIGHT } from '../../../services/hid/Constraints'; export type Key = { label: string; diff --git a/src/components/configure/keymap/Keymap.stories.tsx b/src/components/configure/keymap/Keymap.stories.tsx index ae2259fa..679c248f 100644 --- a/src/components/configure/keymap/Keymap.stories.tsx +++ b/src/components/configure/keymap/Keymap.stories.tsx @@ -20,7 +20,6 @@ import { OptionChoice2Keymap } from '../../../assets/keymaps/OptionChoice2Keymap import { CrkbdKeymap } from '../../../assets/keymaps/CrkbdKeymap'; import { Jisplit89Keymap } from '../../../assets/keymaps/Jisplit89Keymap'; import { Naked64SFKeymap } from '../../../assets/keymaps/Naked64SFKeymap'; -import { MOD_LEFT } from '../../../services/hid/Composition'; import { HotdoxKeymap } from '../../../assets/keymaps/HotdoxKeymap'; import { BigAssEnterKeymap } from '../../../assets/keymaps/BigAssEnterKeymap'; import { VerticalSplitKeymap } from '../../../assets/keymaps/VerticalSplit'; @@ -30,6 +29,7 @@ import { GK6Keymap } from '../../../assets/keymaps/GK6Keymap'; import { CtMacropadKeymap } from '../../../assets/keymaps/CtMacropadKeymap'; import { CtMacropadWithoutDefaultOptionKeymap } from '../../../assets/keymaps/CtMacropadWithoutDefaultOptionKeymap'; import { GiabalanaiKeymap } from '../../../assets/keymaps/GiabalanaiKeymap'; +import { MOD_LEFT } from '../../../services/hid/Constraints'; export default { title: 'Keyboards', diff --git a/src/services/hid/Composition.test.ts b/src/services/hid/Composition.test.ts index bd027aa4..fcf46426 100644 --- a/src/services/hid/Composition.test.ts +++ b/src/services/hid/Composition.test.ts @@ -5,11 +5,10 @@ import { MOD_ALT, MOD_CTL, MOD_GUI, - MOD_LEFT, - MOD_RIGHT, MOD_SFT, } from './Composition'; import { OP_SH_TAP_TOGGLE } from './compositions/SwapHandsComposition'; +import { MOD_LEFT, MOD_RIGHT } from './Constraints'; const EXPECT_BASIC_LIST = [0b0000_0000_0000_0000, 0b0000_0000_1111_1111]; const EXPECT_MODS_LIST = [0b0000_0001_0000_0000, 0b0001_1111_1111_1111]; diff --git a/src/services/hid/Composition.ts b/src/services/hid/Composition.ts index 90c96f31..3b3efc02 100644 --- a/src/services/hid/Composition.ts +++ b/src/services/hid/Composition.ts @@ -1,3 +1,5 @@ +import { anyKeymap, MOD_LEFT, MOD_RIGHT } from './Constraints'; + import { ICustomKeycode, IKeymap } from './Hid'; import { hexadecimal } from '../../utils/StringUtils'; @@ -267,9 +269,6 @@ export type IMod = | typeof MOD_GUI; export const MODIFIERS: IMod[] = [MOD_CTL, MOD_SFT, MOD_ALT, MOD_GUI]; -export const MOD_LEFT = 0b0; -export const MOD_RIGHT = 0b1; - export type IModDirectionLabel = 'left' | 'right'; export type IModDirection = typeof MOD_LEFT | typeof MOD_RIGHT; // eslint-disable-next-line no-unused-vars @@ -296,29 +295,6 @@ export const SWAP_HANDS_OPTIONS: ISwapHandsOption[] = [ OP_SH_ONESHOT, ]; -export function anyKeymap(hex: number): IKeymap { - return { - code: hex, - isAny: true, - kinds: ['any'], - direction: MOD_LEFT, - modifiers: [], - keycodeInfo: { - code: hex, - label: 'Any', - name: { - short: 'Any', - long: 'Any', - }, - keywords: [], - }, - }; -} - -export const WILL_BE_REPLACED_KEYCODE = -1; -export const WILL_BE_REPLACED_KEYMAP: IKeymap = anyKeymap( - WILL_BE_REPLACED_KEYCODE -); export const DUMMY_KEYMAP: IKeymap = anyKeymap(0); export const DIRECTION_LABELS = ['Left', 'Right'] as const; diff --git a/src/services/hid/Constraints.ts b/src/services/hid/Constraints.ts new file mode 100644 index 00000000..b8f2e4ec --- /dev/null +++ b/src/services/hid/Constraints.ts @@ -0,0 +1,28 @@ +import { IKeymap } from './Hid'; + +export const MOD_LEFT = 0b0; +export const MOD_RIGHT = 0b1; + +export function anyKeymap(hex: number): IKeymap { + return { + code: hex, + isAny: true, + kinds: ['any'], + direction: MOD_LEFT, + modifiers: [], + keycodeInfo: { + code: hex, + label: 'Any', + name: { + short: 'Any', + long: 'Any', + }, + keywords: [], + }, + }; +} + +export const WILL_BE_REPLACED_KEYCODE = -1; +export const WILL_BE_REPLACED_KEYMAP: IKeymap = anyKeymap( + WILL_BE_REPLACED_KEYCODE +); diff --git a/src/services/hid/Hid.mock.ts b/src/services/hid/Hid.mock.ts index 5c6be1e4..5c1f03a7 100644 --- a/src/services/hid/Hid.mock.ts +++ b/src/services/hid/Hid.mock.ts @@ -1,17 +1,16 @@ /* eslint-disable no-unused-vars */ import { KeyboardLabelLang } from '../labellang/KeyLabelLangs'; -import { MOD_LEFT } from './Composition'; import { ICommand, IConnectionEventHandler, IConnectParams, IFetchLayoutOptionsResult, IFetchViaProtocolVersionResult, - IGetMacroCountResult, IHid, IKeyboard, IResult, } from './Hid'; +import { MOD_LEFT } from './Constraints'; export const IDeviceInformationMock = { vendorId: 777, diff --git a/src/services/hid/KeycodeList.ts b/src/services/hid/KeycodeList.ts index a3a632af..4a2503f9 100644 --- a/src/services/hid/KeycodeList.ts +++ b/src/services/hid/KeycodeList.ts @@ -1,10 +1,11 @@ import { ICustomKeycode, IKeymap } from './Hid'; import { - anyKeymap, IKeycodeCompositionKind, KeycodeCompositionFactory, } from './Composition'; import { KeyboardLabelLang } from '../labellang/KeyLabelLangs'; +import { anyKeymap } from './Constraints'; + export type KeymapCategory = | IKeycodeCompositionKind | 'any' diff --git a/src/services/hid/compositions/AsciiComposition.ts b/src/services/hid/compositions/AsciiComposition.ts index 210d2aa1..535c5640 100644 --- a/src/services/hid/compositions/AsciiComposition.ts +++ b/src/services/hid/compositions/AsciiComposition.ts @@ -1,8 +1,9 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeymap } from '../Hid'; import { KEY_CATEGORY_ASCII } from '../KeyCategoryList'; import { hexadecimal } from '../../../utils/StringUtils'; import { keyInfoList } from '../KeycodeInfoList'; +import { MOD_LEFT } from '../Constraints'; export const ASCII_MIN = 0b0000_0000_0000_0000; export const ASCII_MAX = 0b0000_0000_0111_1111; diff --git a/src/services/hid/compositions/BasicComposition.ts b/src/services/hid/compositions/BasicComposition.ts index e9f79900..4f2bfcd1 100644 --- a/src/services/hid/compositions/BasicComposition.ts +++ b/src/services/hid/compositions/BasicComposition.ts @@ -1,4 +1,4 @@ -import { anyKeymap, IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeycodeCategoryInfo, IKeycodeInfo, IKeymap } from '../Hid'; import { KeyboardLabelLang, @@ -26,6 +26,7 @@ import { } from '../KeyCategoryList'; import { KeyLabel } from '../../labellang/KeyLabel'; import { keyInfoList } from '../KeycodeInfoList'; +import { anyKeymap, MOD_LEFT } from '../Constraints'; export const QK_BASIC_MIN = 0b0000_0000_0000_0000; export const QK_BASIC_MAX = 0b0000_0000_1111_1111; diff --git a/src/services/hid/compositions/DefLayerComposition.ts b/src/services/hid/compositions/DefLayerComposition.ts index dd4da85f..c6b40c95 100644 --- a/src/services/hid/compositions/DefLayerComposition.ts +++ b/src/services/hid/compositions/DefLayerComposition.ts @@ -1,6 +1,7 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IMomentaryComposition } from './MomentaryComposition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT } from '../Constraints'; export const QK_DEF_LAYER_MIN = 0b0101_0010_0100_0000; export const QK_DEF_LAYER_MAX = 0b0101_0010_0101_1111; diff --git a/src/services/hid/compositions/LayerModComposition.ts b/src/services/hid/compositions/LayerModComposition.ts index e145a358..48648603 100644 --- a/src/services/hid/compositions/LayerModComposition.ts +++ b/src/services/hid/compositions/LayerModComposition.ts @@ -1,5 +1,6 @@ -import { IComposition, IMod, MOD_LEFT } from '../Composition'; +import { IComposition, IMod } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT } from '../Constraints'; export const QK_LAYER_MOD_MIN = 0b0101_0000_0000_0000; export const QK_LAYER_MOD_MAX = 0b0101_0001_1111_1111; diff --git a/src/services/hid/compositions/LayerTapComposition.ts b/src/services/hid/compositions/LayerTapComposition.ts index 14ebbda1..1defd443 100644 --- a/src/services/hid/compositions/LayerTapComposition.ts +++ b/src/services/hid/compositions/LayerTapComposition.ts @@ -1,10 +1,6 @@ -import { - IComposition, - ITapKey, - MOD_LEFT, - WILL_BE_REPLACED_KEYMAP, -} from '../Composition'; +import { IComposition, ITapKey } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT, WILL_BE_REPLACED_KEYMAP } from '../Constraints'; export const QK_LAYER_TAP_MIN = 0b0100_0000_0000_0000; export const QK_LAYER_TAP_MAX = 0b0100_1111_1111_1111; diff --git a/src/services/hid/compositions/LayerTapToggleComposition.ts b/src/services/hid/compositions/LayerTapToggleComposition.ts index 5f77f758..e1ee94a7 100644 --- a/src/services/hid/compositions/LayerTapToggleComposition.ts +++ b/src/services/hid/compositions/LayerTapToggleComposition.ts @@ -1,5 +1,6 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT } from '../Constraints'; export const QK_LAYER_TAP_TOGGLE_MIN = 0b0101_0010_1100_0000; export const QK_LAYER_TAP_TOGGLE_MAX = 0b0101_0010_1101_1111; diff --git a/src/services/hid/compositions/LooseKeycodeComposition.ts b/src/services/hid/compositions/LooseKeycodeComposition.ts index 55ddf031..63cd1892 100644 --- a/src/services/hid/compositions/LooseKeycodeComposition.ts +++ b/src/services/hid/compositions/LooseKeycodeComposition.ts @@ -1,9 +1,12 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeycodeCategoryInfo, IKeymap } from '../Hid'; import { bmpKeyInfoList } from '../KeycodeInfoListBmp'; import { KeyInfo, keyInfoList } from '../KeycodeInfoList'; import { + KEY_SUB_CATEGORY_AUDIO, KEY_SUB_CATEGORY_BACKLIGHT, + KEY_SUB_CATEGORY_JOYSTICK, + KEY_SUB_CATEGORY_MACRO, KEY_SUB_CATEGORY_MAGIC, KEY_SUB_CATEGORY_MIDI_CHANNEL, KEY_SUB_CATEGORY_MIDI_MISC, @@ -11,16 +14,14 @@ import { KEY_SUB_CATEGORY_MIDI_OCTAVE, KEY_SUB_CATEGORY_MIDI_TRANSPOSE, KEY_SUB_CATEGORY_MIDI_VELOCITY, - KEY_SUB_CATEGORY_AUDIO, - KEY_SUB_CATEGORY_UNDERGLOW, - KEY_SUB_CATEGORY_SEQUENCER, - KEY_SUB_CATEGORY_JOYSTICK, KEY_SUB_CATEGORY_PROGRAMMABLE_BUTTON, - KEY_SUB_CATEGORY_STENO, KEY_SUB_CATEGORY_QUANTUM, + KEY_SUB_CATEGORY_SEQUENCER, + KEY_SUB_CATEGORY_STENO, + KEY_SUB_CATEGORY_UNDERGLOW, KEY_SUB_CATEGORY_USER, - KEY_SUB_CATEGORY_MACRO, } from '../KeyCategoryList'; +import { MOD_LEFT } from '../Constraints'; export const QK_MAGIC_MIN = 0x7000; export const QK_MAGIC_MAX = 0x70ff; diff --git a/src/services/hid/compositions/MacroComposition.ts b/src/services/hid/compositions/MacroComposition.ts index b503aecb..56da8108 100644 --- a/src/services/hid/compositions/MacroComposition.ts +++ b/src/services/hid/compositions/MacroComposition.ts @@ -1,7 +1,8 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeymap } from '../Hid'; import { KeyInfo, keyInfoList } from '../KeycodeInfoList'; import { KEY_SUB_CATEGORY_MACRO } from '../KeyCategoryList'; +import { MOD_LEFT } from '../Constraints'; export const QK_MACRO_MIN = 0b0111_0111_0000_0000; export const QK_MACRO_MAX = 0b0111_0111_0111_1111; diff --git a/src/services/hid/compositions/ModTapComposition.ts b/src/services/hid/compositions/ModTapComposition.ts index 849b22a8..65836a41 100644 --- a/src/services/hid/compositions/ModTapComposition.ts +++ b/src/services/hid/compositions/ModTapComposition.ts @@ -7,12 +7,10 @@ import { MOD_ALT, MOD_CTL, MOD_GUI, - MOD_LEFT, - MOD_RIGHT, MOD_SFT, - WILL_BE_REPLACED_KEYMAP, } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT, MOD_RIGHT, WILL_BE_REPLACED_KEYMAP } from '../Constraints'; export const QK_MOD_TAP_MIN = 0b0010_0000_0000_0000; export const QK_MOD_TAP_MAX = 0b0011_1111_1111_1111; diff --git a/src/services/hid/compositions/MomentaryComposition.ts b/src/services/hid/compositions/MomentaryComposition.ts index 2c0a1505..c79dede1 100644 --- a/src/services/hid/compositions/MomentaryComposition.ts +++ b/src/services/hid/compositions/MomentaryComposition.ts @@ -1,5 +1,6 @@ import { IKeymap } from '../Hid'; -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; +import { MOD_LEFT } from '../Constraints'; export const QK_MOMENTARY_MIN = 0b0101_0010_0010_0000; export const QK_MOMENTARY_MAX = 0b0101_0010_0011_1111; diff --git a/src/services/hid/compositions/OneShotLayerComposition.ts b/src/services/hid/compositions/OneShotLayerComposition.ts index 9d22079c..3d7b30b8 100644 --- a/src/services/hid/compositions/OneShotLayerComposition.ts +++ b/src/services/hid/compositions/OneShotLayerComposition.ts @@ -1,5 +1,6 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT } from '../Constraints'; export const QK_ONE_SHOT_LAYER_MIN = 0b0101_0010_1000_0000; export const QK_ONE_SHOT_LAYER_MAX = 0b0101_0010_1001_1111; diff --git a/src/services/hid/compositions/OneShotModComposition.ts b/src/services/hid/compositions/OneShotModComposition.ts index 948fbdc9..18674b2b 100644 --- a/src/services/hid/compositions/OneShotModComposition.ts +++ b/src/services/hid/compositions/OneShotModComposition.ts @@ -1,11 +1,6 @@ -import { - IComposition, - IMod, - IModDirection, - MOD_LEFT, - WILL_BE_REPLACED_KEYCODE, -} from '../Composition'; +import { IComposition, IMod, IModDirection } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT, WILL_BE_REPLACED_KEYCODE } from '../Constraints'; export const QK_ONE_SHOT_MOD_MIN = 0b0101_0010_1010_0000; export const QK_ONE_SHOT_MOD_MAX = 0b0101_0010_1011_1111; diff --git a/src/services/hid/compositions/SwapHandsComposition.ts b/src/services/hid/compositions/SwapHandsComposition.ts index e14c7bf1..04fb22ff 100644 --- a/src/services/hid/compositions/SwapHandsComposition.ts +++ b/src/services/hid/compositions/SwapHandsComposition.ts @@ -1,11 +1,6 @@ -import { - IComposition, - ISwapHandsOption, - ITapKey, - MOD_LEFT, - WILL_BE_REPLACED_KEYCODE, -} from '../Composition'; +import { IComposition, ISwapHandsOption, ITapKey } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT, WILL_BE_REPLACED_KEYCODE } from '../Constraints'; export const QK_SWAP_HANDS_MIN = 0b0101_0110_0000_0000; export const QK_SWAP_HANDS_MAX = 0b0101_0110_1111_1111; diff --git a/src/services/hid/compositions/ToComposition.ts b/src/services/hid/compositions/ToComposition.ts index 3dfff42d..f84163a8 100644 --- a/src/services/hid/compositions/ToComposition.ts +++ b/src/services/hid/compositions/ToComposition.ts @@ -1,5 +1,6 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT } from '../Constraints'; export const QK_TO_MIN = 0b0101_0010_0000_0000; export const QK_TO_MAX = 0b0101_0010_0001_1111; diff --git a/src/services/hid/compositions/ToggleLayerComposition.ts b/src/services/hid/compositions/ToggleLayerComposition.ts index 6d0fbc7c..56305b98 100644 --- a/src/services/hid/compositions/ToggleLayerComposition.ts +++ b/src/services/hid/compositions/ToggleLayerComposition.ts @@ -1,6 +1,7 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { IMomentaryComposition } from './MomentaryComposition'; import { IKeymap } from '../Hid'; +import { MOD_LEFT } from '../Constraints'; export const QK_TOGGLE_LAYER_MIN = 0b0101_0010_0110_0000; export const QK_TOGGLE_LAYER_MAX = 0b0101_0010_0111_1111; diff --git a/src/services/hid/compositions/ViaUserKeyComposition.test.ts b/src/services/hid/compositions/ViaUserKeyComposition.test.ts index 2adbe7e5..dc2a2ad4 100644 --- a/src/services/hid/compositions/ViaUserKeyComposition.test.ts +++ b/src/services/hid/compositions/ViaUserKeyComposition.test.ts @@ -1,5 +1,5 @@ import { ViaUserKeyComposition } from './ViaUserKeyComposition'; -import { MOD_LEFT } from '../Composition'; +import { MOD_LEFT } from '../Constraints'; describe('ViaUserKeyComposition', () => { test('getCode', () => { diff --git a/src/services/hid/compositions/ViaUserKeyComposition.ts b/src/services/hid/compositions/ViaUserKeyComposition.ts index 24dead5e..867fa7af 100644 --- a/src/services/hid/compositions/ViaUserKeyComposition.ts +++ b/src/services/hid/compositions/ViaUserKeyComposition.ts @@ -1,7 +1,8 @@ -import { IComposition, MOD_LEFT } from '../Composition'; +import { IComposition } from '../Composition'; import { ICustomKeycode, IKeymap } from '../Hid'; import { KeyInfo, keyInfoList } from '../KeycodeInfoList'; import { KEY_SUB_CATEGORY_VIA_USER_KEY } from '../KeyCategoryList'; +import { MOD_LEFT } from '../Constraints'; export const VIA_USER_KEY_MIN = 0b0111_1110_0000_0000; // This is same as QK_KB_0. export const VIA_USER_KEY_MAX = 0b0111_1110_0001_1111; // This is same as QK_KB_31. diff --git a/src/services/macro/Macro.test.ts b/src/services/macro/Macro.test.ts index a738bbe6..1d4aa723 100644 --- a/src/services/macro/Macro.test.ts +++ b/src/services/macro/Macro.test.ts @@ -9,9 +9,9 @@ import { SS_TAP_CODE, SS_UP_CODE, } from './Macro'; -import { MOD_LEFT } from '../hid/Composition'; import { Key } from '../../components/configure/keycodekey/KeyGen'; import sinon from 'sinon'; +import { MOD_LEFT } from '../hid/Constraints'; const createKey = (code: number, label: string, isAscii: boolean): Key => { return { diff --git a/src/store/reducers.ts b/src/store/reducers.ts index 9c75111b..9af6b1f1 100644 --- a/src/store/reducers.ts +++ b/src/store/reducers.ts @@ -1,50 +1,50 @@ import immer from 'immer'; import { WritableDraft } from 'immer/dist/internal'; import { + ANYKEYCODEKEY_ACTIONS, + ANYKEYCODEKEY_ADD_ANYKEY, + ANYKEYCODEKEY_UPDATE_ANYKEY, + APP_ACTIONS, + APP_PACKAGE_INIT, + APP_REMAPS_CLEAR, + APP_REMAPS_INIT, + APP_REMAPS_REMOVE_KEY, + APP_REMAPS_SET_KEY, + APP_REMAPS_SET_KEYS, + APP_TEST_MATRIX_UPDATE, + APP_TESTED_MATRIX_CLEAR, + APP_UPDATE_KEYBOARD_SIZE, + APP_UPDATE_LANG_LABEL, + APP_UPDATE_SETUP_PHASE, + APP_UPDATE_SIGNED_IN, + HEADER_ACTIONS, + HEADER_UPDATE_FLASHING, KEYCODEKEY_ACTIONS, + KEYCODEKEY_CLEAR, + KEYCODEKEY_UPDATE_DRAGGING_KEY, KEYCODEKEY_UPDATE_HOVER_KEY, KEYCODEKEY_UPDATE_SELECTED_KEY, KEYCODES_ACTIONS, KEYCODES_UPDATE_MACRO, - KEYMAP_UPDATE_SELECTED_LAYER, - KEYMAP_ACTIONS, - NOTIFICATION_ACTIONS, - NOTIFICATION_ADD_ERROR, - NOTIFICATION_ADD_WARN, - HEADER_UPDATE_FLASHING, - HEADER_ACTIONS, - KEYCODEKEY_UPDATE_DRAGGING_KEY, KEYDIFF_ACTIONS, - KEYDIFF_UPDATE_KEYDIFF, KEYDIFF_CLEAR_KEYDIFF, - KEYMAP_UPDATE_SELECTED_POS, + KEYDIFF_UPDATE_KEYDIFF, + KEYMAP_ACTIONS, KEYMAP_CLEAR_SELECTED_POS, - APP_ACTIONS, - APP_REMAPS_SET_KEY, - APP_REMAPS_INIT, - APP_REMAPS_REMOVE_KEY, - APP_PACKAGE_INIT, - NOTIFICATION_REMOVE, - NOTIFICATION_ADD_INFO, - NOTIFICATION_ADD_SUCCESS, - APP_UPDATE_SETUP_PHASE, - APP_REMAPS_CLEAR, - KEYCODEKEY_CLEAR, - ANYKEYCODEKEY_ACTIONS, - ANYKEYCODEKEY_ADD_ANYKEY, - ANYKEYCODEKEY_UPDATE_ANYKEY, + KEYMAP_TOOLBAR_ACTIONS, + KEYMAP_TOOLBAR_TEST_MATRIX_MODE, + KEYMAP_UPDATE_SELECTED_LAYER, + KEYMAP_UPDATE_SELECTED_POS, LAYOUT_OPTIONS_ACTIONS, - LAYOUT_OPTIONS_UPDATE_SELECTED_OPTION, LAYOUT_OPTIONS_INIT_SELECTED_OPTION, - APP_UPDATE_KEYBOARD_SIZE, - APP_UPDATE_LANG_LABEL, - APP_UPDATE_SIGNED_IN, - APP_REMAPS_SET_KEYS, LAYOUT_OPTIONS_RESTORE_SELECTED_OPTIONS, - KEYMAP_TOOLBAR_ACTIONS, - KEYMAP_TOOLBAR_TEST_MATRIX_MODE, - APP_TESTED_MATRIX_CLEAR, - APP_TEST_MATRIX_UPDATE, + LAYOUT_OPTIONS_UPDATE_SELECTED_OPTION, + NOTIFICATION_ACTIONS, + NOTIFICATION_ADD_ERROR, + NOTIFICATION_ADD_INFO, + NOTIFICATION_ADD_SUCCESS, + NOTIFICATION_ADD_WARN, + NOTIFICATION_REMOVE, } from '../actions/actions'; import { HID_ACTIONS, @@ -91,12 +91,16 @@ import { KEYBOARDS_CREATE_DEFINITION_ACTIONS, KEYBOARDS_CREATE_DEFINITION_CLEAR, KEYBOARDS_CREATE_DEFINITION_UPDATE_AGREEMENT, + KEYBOARDS_CREATE_DEFINITION_UPDATE_AUTHOR_TYPE, + KEYBOARDS_CREATE_DEFINITION_UPDATE_CONTACT_INFORMATION, KEYBOARDS_CREATE_DEFINITION_UPDATE_FIRMWARE_CODE_PLACE, KEYBOARDS_CREATE_DEFINITION_UPDATE_FORKED_REPOSITORY_EVIDENCE, KEYBOARDS_CREATE_DEFINITION_UPDATE_FORKED_REPOSITORY_URL, KEYBOARDS_CREATE_DEFINITION_UPDATE_JSON_FILENAME, KEYBOARDS_CREATE_DEFINITION_UPDATE_JSON_STRING, KEYBOARDS_CREATE_DEFINITION_UPDATE_KEYBOARD_DEFINITION, + KEYBOARDS_CREATE_DEFINITION_UPDATE_ORGANIZATION_EVIDENCE, + KEYBOARDS_CREATE_DEFINITION_UPDATE_ORGANIZATION_ID, KEYBOARDS_CREATE_DEFINITION_UPDATE_OTHER_PLACE_HOW_TO_GET, KEYBOARDS_CREATE_DEFINITION_UPDATE_OTHER_PLACE_PUBLISHER_EVIDENCE, KEYBOARDS_CREATE_DEFINITION_UPDATE_OTHER_PLACE_SOURCE_CODE_EVIDENCE, @@ -105,47 +109,42 @@ import { KEYBOARDS_EDIT_DEFINITION_ACTIONS, KEYBOARDS_EDIT_DEFINITION_ADD_ADDITIONAL_DESCRIPTIONS, KEYBOARDS_EDIT_DEFINITION_CLEAR, + KEYBOARDS_EDIT_DEFINITION_CLEAR_FIRMWARE_FORM, KEYBOARDS_EDIT_DEFINITION_DELETE_ADDITIONAL_DESCRIPTIONS, KEYBOARDS_EDIT_DEFINITION_INIT, KEYBOARDS_EDIT_DEFINITION_UPDATE_ADDITIONAL_DESCRIPTIONS, KEYBOARDS_EDIT_DEFINITION_UPDATE_AGREEMENT, + KEYBOARDS_EDIT_DEFINITION_UPDATE_AUTHOR_TYPE, + KEYBOARDS_EDIT_DEFINITION_UPDATE_CONTACT_INFORMATION, + KEYBOARDS_EDIT_DEFINITION_UPDATE_DEFAULT_BOOTLOADER_TYPE, KEYBOARDS_EDIT_DEFINITION_UPDATE_DESCRIPTION, KEYBOARDS_EDIT_DEFINITION_UPDATE_FEATURE, KEYBOARDS_EDIT_DEFINITION_UPDATE_FEATURES, KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_CODE_PLACE, + KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_DESCRIPTION, + KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_FILE, + KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_NAME, + KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_SOURCE_CODE_URL, + KEYBOARDS_EDIT_DEFINITION_UPDATE_FLASH_SUPPORT, KEYBOARDS_EDIT_DEFINITION_UPDATE_FORKED_REPOSITORY_EVIDENCE, KEYBOARDS_EDIT_DEFINITION_UPDATE_FORKED_REPOSITORY_URL, KEYBOARDS_EDIT_DEFINITION_UPDATE_JSON_FILENAME, KEYBOARDS_EDIT_DEFINITION_UPDATE_JSON_STRING, KEYBOARDS_EDIT_DEFINITION_UPDATE_KEYBOARD_DEFINITION, + KEYBOARDS_EDIT_DEFINITION_UPDATE_MAIN_IMAGE_UPLOADED_RATE, + KEYBOARDS_EDIT_DEFINITION_UPDATE_MAIN_IMAGE_UPLOADING, + KEYBOARDS_EDIT_DEFINITION_UPDATE_ORGANIZATION_EVIDENCE, + KEYBOARDS_EDIT_DEFINITION_UPDATE_ORGANIZATION_ID, KEYBOARDS_EDIT_DEFINITION_UPDATE_OTHER_PLACE_HOW_TO_GET, KEYBOARDS_EDIT_DEFINITION_UPDATE_OTHER_PLACE_PUBLISHER_EVIDENCE, KEYBOARDS_EDIT_DEFINITION_UPDATE_OTHER_PLACE_SOURCE_CODE_EVIDENCE, KEYBOARDS_EDIT_DEFINITION_UPDATE_PRODUCT_NAME, KEYBOARDS_EDIT_DEFINITION_UPDATE_QMK_REPOSITORY_FIRST_PULL_REQUEST_URL, KEYBOARDS_EDIT_DEFINITION_UPDATE_STORES, - KEYBOARDS_EDIT_DEFINITION_UPDATE_MAIN_IMAGE_UPLOADED_RATE, - KEYBOARDS_EDIT_DEFINITION_UPDATE_MAIN_IMAGE_UPLOADING, - KEYBOARDS_EDIT_DEFINITION_UPDATE_WEBSITE_URL, KEYBOARDS_EDIT_DEFINITION_UPDATE_SUB_IMAGE_UPLOADED_RATE, KEYBOARDS_EDIT_DEFINITION_UPDATE_SUB_IMAGE_UPLOADING, - KEYBOARDS_CREATE_DEFINITION_UPDATE_CONTACT_INFORMATION, - KEYBOARDS_EDIT_DEFINITION_UPDATE_CONTACT_INFORMATION, - KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_NAME, - KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_FILE, - KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_DESCRIPTION, - KEYBOARDS_EDIT_DEFINITION_CLEAR_FIRMWARE_FORM, - KEYBOARDS_EDIT_DEFINITION_UPDATE_FIRMWARE_SOURCE_CODE_URL, - KEYBOARDS_EDIT_DEFINITION_UPDATE_FLASH_SUPPORT, - KEYBOARDS_CREATE_DEFINITION_UPDATE_AUTHOR_TYPE, - KEYBOARDS_CREATE_DEFINITION_UPDATE_ORGANIZATION_ID, - KEYBOARDS_CREATE_DEFINITION_UPDATE_ORGANIZATION_EVIDENCE, - KEYBOARDS_EDIT_DEFINITION_UPDATE_ORGANIZATION_EVIDENCE, - KEYBOARDS_EDIT_DEFINITION_UPDATE_ORGANIZATION_ID, - KEYBOARDS_EDIT_DEFINITION_UPDATE_AUTHOR_TYPE, - KEYBOARDS_EDIT_DEFINITION_UPDATE_DEFAULT_BOOTLOADER_TYPE, + KEYBOARDS_EDIT_DEFINITION_UPDATE_WEBSITE_URL, } from '../actions/keyboards.actions'; -import { MOD_LEFT } from '../services/hid/Composition'; import { LayoutOption } from '../components/configure/keymap/Keymap'; import { CATALOG_APP_ACTIONS, @@ -195,6 +194,7 @@ import { UPLOAD_FIRMWARE_DIALOG_UPDATE_FIRMWARE_FILE_BUFFER, UPLOAD_FIRMWARE_DIALOG_UPDATE_OPEN, } from '../actions/firmware.action'; +import { MOD_LEFT } from '../services/hid/Constraints'; export type Action = { type: string; value: any };