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

feat: recording of keystrokes on the keyboard followed by insertion on the layer #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/n-links/keyboard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useCallback, useContext, useEffect, useMemo} from 'react';
import {matrixKeycodes} from 'src/utils/key-event';
import { useKeyboardRecord } from 'src/utils/use-keyboard-record';
import fullKeyboardDefinition from '../../utils/test-keyboard-definition.json';
import {VIAKey, DefinitionVersionMap} from '@the-via/reader';
import {useAppDispatch, useAppSelector} from 'src/store/hooks';
Expand Down Expand Up @@ -79,6 +80,9 @@ export const ConfigureKeyboard = (props: {
}

const KeyboardCanvas = getKeyboardCanvas(props.nDimension);

useKeyboardRecord();

return (
<>
<KeyboardCanvas
Expand Down Expand Up @@ -227,7 +231,7 @@ export const Design = (props: {
};

const EMPTY_ARR = [] as any[];
export const Test = (props: {dimensions?: DOMRect; nDimension: NDimension}) => {
export const Test = (props: { dimensions?: DOMRect; nDimension: NDimension }) => {
const dispatch = useAppDispatch();
const [path] = useLocation();
const isShowingTest = path === '/test';
Expand Down Expand Up @@ -336,7 +340,7 @@ export const Test = (props: {dimensions?: DOMRect; nDimension: NDimension}) => {
nDimension={props.nDimension}
/>
{partitionedPressedKeys && testKeyboardSoundsSettings.isEnabled && (
<TestKeyboardSounds pressedKeys={partitionedPressedKeys} />
<TestKeyboardSounds pressedKeys={partitionedPressedKeys}/>
)}
</>
);
Expand Down
14 changes: 12 additions & 2 deletions src/components/panes/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
getThemeName,
updateThemeName,
getRenderMode,
updateRenderMode,
updateRenderMode, getDisableRecordKeyboard, toggleRecordKeyboard,
} from 'src/store/settingsSlice';
import {AccentSelect} from '../inputs/accent-select';
import {THEMES} from 'src/utils/themes';
Expand Down Expand Up @@ -57,6 +57,7 @@ export const Settings = () => {
const dispatch = useDispatch();
const showDesignTab = useAppSelector(getShowDesignTab);
const disableFastRemap = useAppSelector(getDisableFastRemap);
const disableRecordKeyboard = useAppSelector(getDisableRecordKeyboard);
const themeMode = useAppSelector(getThemeMode);
const themeName = useAppSelector(getThemeName);
const renderMode = useAppSelector(getRenderMode);
Expand Down Expand Up @@ -94,7 +95,7 @@ export const Settings = () => {
<MenuContainer>
<Row $selected={true}>
<IconContainer>
<FontAwesomeIcon icon={faToolbox} />
<FontAwesomeIcon icon={faToolbox}/>
<MenuTooltip>General</MenuTooltip>
</IconContainer>
</Row>
Expand All @@ -120,6 +121,15 @@ export const Settings = () => {
/>
</Detail>
</ControlRow>
<ControlRow>
<Label>Record Keyboard</Label>
<Detail>
<AccentSlider
onChange={() => dispatch(toggleRecordKeyboard())}
isChecked={!disableRecordKeyboard}
/>
</Detail>
</ControlRow>
<ControlRow>
<Label>Light Mode</Label>
<Detail>
Expand Down
6 changes: 6 additions & 0 deletions src/store/settingsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const settingsSlice = createSlice({
toggleFastRemap: (state) => {
toggleBool(state, 'disableFastRemap');
},
toggleRecordKeyboard: (state) => {
toggleBool(state, 'disableRecordKeyboard');
},
toggleCreatorMode: (state) => {
toggleBool(state, 'showDesignTab');
},
Expand Down Expand Up @@ -104,6 +107,7 @@ const settingsSlice = createSlice({
export const {
toggleFastRemap,
toggleCreatorMode,
toggleRecordKeyboard,
setTestMatrixEnabled,
setTestKeyboardSoundsSettings,
setMacroEditorSettings,
Expand All @@ -123,6 +127,8 @@ export const getAllowGlobalHotKeys = (state: RootState) =>
state.settings.allowGlobalHotKeys;
export const getDisableFastRemap = (state: RootState) =>
state.settings.disableFastRemap;
export const getDisableRecordKeyboard = (state: RootState) =>
state.settings.disableRecordKeyboard;
export const getShowDesignTab = (state: RootState) =>
state.settings.showDesignTab;
export const getRestartRequired = (state: RootState) =>
Expand Down
1 change: 1 addition & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export type TestKeyboardSoundsSettings = {
export type Settings = {
showDesignTab: boolean;
disableFastRemap: boolean;
disableRecordKeyboard: boolean;
renderMode: '3D' | '2D';
themeMode: 'light' | 'dark';
themeName: string;
Expand Down
1 change: 1 addition & 0 deletions src/utils/device-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const defaultStoreData = {
settings: {
showDesignTab: false,
disableFastRemap: false,
disableRecordKeyboard: false,
renderMode: '2D' as const,
themeMode: 'dark' as const,
designDefinitionVersion: 'v3' as const,
Expand Down
Loading