Skip to content

Commit

Permalink
Fix the issue what can't start.
Browse files Browse the repository at this point in the history
  • Loading branch information
yoichiro committed Sep 6, 2023
1 parent ffb7d88 commit 0ca535e
Show file tree
Hide file tree
Showing 31 changed files with 134 additions and 141 deletions.
2 changes: 1 addition & 1 deletion src/components/catalog/keyboard/keymap/Catalogkeymap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 &
Expand Down
2 changes: 1 addition & 1 deletion src/components/configure/customkey/CustomKey.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/components/configure/customkey/CustomKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/components/configure/customkey/Modifiers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/configure/customkey/TabKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
IMod,
IModDirection,
KeycodeCompositionFactory,
MOD_LEFT,
} from '../../../services/hid/Composition';

import AutocompleteKeys from './AutocompleteKeys';
Expand All @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions src/components/configure/keycodekey/KeyGen.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/configure/keymap/Keymap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions src/services/hid/Composition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
28 changes: 2 additions & 26 deletions src/services/hid/Composition.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { anyKeymap, MOD_LEFT, MOD_RIGHT } from './Constraints';

import { ICustomKeycode, IKeymap } from './Hid';
import { hexadecimal } from '../../utils/StringUtils';

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions src/services/hid/Constraints.ts
Original file line number Diff line number Diff line change
@@ -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
);
3 changes: 1 addition & 2 deletions src/services/hid/Hid.mock.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/KeycodeList.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/AsciiComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/BasicComposition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { anyKeymap, IComposition, MOD_LEFT } from '../Composition';
import { IComposition } from '../Composition';
import { IKeycodeCategoryInfo, IKeycodeInfo, IKeymap } from '../Hid';
import {
KeyboardLabelLang,
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/DefLayerComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/LayerModComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 2 additions & 6 deletions src/services/hid/compositions/LayerTapComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/LayerTapToggleComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/services/hid/compositions/LooseKeycodeComposition.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
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,
KEY_SUB_CATEGORY_MIDI_NOTES,
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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/MacroComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/services/hid/compositions/ModTapComposition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/MomentaryComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/hid/compositions/OneShotLayerComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 2 additions & 7 deletions src/services/hid/compositions/OneShotModComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 2 additions & 7 deletions src/services/hid/compositions/SwapHandsComposition.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit 0ca535e

Please sign in to comment.