Skip to content

Commit

Permalink
Merge branch 'development' into featMacrosDelaysModifiable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpargon committed Nov 14, 2024
2 parents 4fd7807 + c34efdd commit 05d70e7
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 53 deletions.
17 changes: 13 additions & 4 deletions src/api/flash/defyFlasher/sideFlasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ export default class SideFlaser {
// Update process
// log.info(this.firmwareSides);
const seal = recoverSeal(this.firmwareSides.slice(0, 28));
log.info("This is the seal", seal);
// console.dir(seal);
// log.info("This is the seal from the FW file");
// eslint-disable-next-line no-console
console.info("This is the seal from the Neuron");
// eslint-disable-next-line no-console
console.table(seal);

// Serial port instancing
if (this.serialport !== undefined) {
Expand Down Expand Up @@ -166,7 +169,7 @@ export default class SideFlaser {
// Begin upgrade process for selected side
let ans;
const sideId = side === "right" ? 0 : 1;
log.info("going to start writing to Neuron");
log.info(`going to start writing to the ${side} side`);
this.serialport.write(`upgrade.keyscanner.isConnected ${sideId}\n`);
const testRead = await readLine();
log.info("testing after first read", testRead);
Expand All @@ -187,7 +190,7 @@ export default class SideFlaser {
await readLine();
ans = await readLine();
if ((ans as string).trim() !== "true") {
log.info("not returned true when begin!!!", ans);
log.error("not returned true when begin!!!", ans);
return {
error: true,
message: `${side} side disconnected from keyboard\n`,
Expand All @@ -207,6 +210,12 @@ export default class SideFlaser {
validation: parseInt(ans[4], 10),
};

// log.info("This is the seal from the Neuron");
// eslint-disable-next-line no-console
console.info("This is the seal from the Neuron");
// eslint-disable-next-line no-console
console.table(info);

// Write Firmware FOR Loop
let step = 0;
const totalsteps = this.firmwareSides.length / 256;
Expand Down
2 changes: 1 addition & 1 deletion src/api/hid/hid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class HID {
const [nme, wless, ly] = device.productName.split(" ")[0].split("-");
name = nme;
wireless = wless.includes("Wless");
layout = ly.includes("A") ? "ANSI" : "ISO";
layout = ly.includes("I") ? "ISO" : "ANSI";
log.info("Raise2 Data", name, wireless, layout);
}
for (const Hdevice of Hardware.serial) {
Expand Down
17 changes: 16 additions & 1 deletion src/api/parsers/macros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const parseMacrosRaw = (raw: string, storedMacros?: MacrosType[]) => {
// macros are `0` terminated or when end of macrosArray has been reached, the outer loop
// must cycle once more than the inner
while (iter <= macrosArray.length) {
const actions: MacroActionsType[] = [];
let actions: MacroActionsType[] = [];
while (iter < macrosArray.length) {
const type = macrosArray[iter];
if (type === 0) {
Expand Down Expand Up @@ -48,6 +48,15 @@ export const parseMacrosRaw = (raw: string, storedMacros?: MacrosType[]) => {

iter += 1;
}
actions = actions.filter(a => {
let result;
if (Array.isArray(a.keyCode)) {
a.keyCode.filter(k => !Number.isNaN(k));
} else {
result = !Number.isNaN(a.keyCode);
}
return result;
});
macros.push({
actions,
name: "",
Expand Down Expand Up @@ -91,6 +100,12 @@ export const serializeMacros = (macros: MacrosType[], tMem: number) => {
return macrosEraser(tMem);
}
const mapAction = (action: MacroActionsType): number[] => {
if (
Array.isArray(action.keyCode)
? Number.isNaN(action.keyCode[0]) || Number.isNaN(action.keyCode[1])
: Number.isNaN(action.keyCode)
)
return [];
switch (action.type) {
case 1:
return [
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/organisms/Select/LayerSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@Renderer/components/atoms/DropdownMenu";

Expand Down Expand Up @@ -131,7 +130,7 @@ const LayerSelector: React.FC<any> = ({
<DropdownMenuItem className="flex gap-2" onSelect={clearFunc}>
<IconDelete /> {i18n.editor.layers.clearLayer}
</DropdownMenuItem>
{/*
{/*
<DropdownMenuSeparator />
<DropdownMenuItem className="flex gap-2" onSelect={exportToPdf}>
<IconFileDownload /> {i18n.editor.layers.exportToPdf}
Expand Down
101 changes: 60 additions & 41 deletions src/renderer/components/organisms/Select/MacroSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,50 @@ import { i18n } from "@Renderer/i18n";
import NameModal from "@Renderer/components/molecules/CustomModal/ModalName";
import MacrosMemoryUsage from "@Renderer/modules/Macros/MacrosMemoryUsage";

import { IconDelete, IconPen, IconClone, IconAddNew } from "@Renderer/components/atoms/icons";

import {
IconDelete,
IconPen,
IconClone,
IconAddNew,
IconSettings,
IconArrowUpWithLine,
IconArrowDownWithLine,
} from "@Renderer/components/atoms/icons";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@Renderer/components/atoms/DropdownMenu";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@Renderer/components/atoms/Select";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@Renderer/components/atoms/Tooltip";
import { Button } from "@Renderer/components/atoms/Button";
import { MacrosType } from "@Renderer/types/macros";

interface ItemList {
id: number;
name: string;
interface MacroSelectorProps {
onSelect: (value: number) => void;
deleteItem: () => void;
addItem: (name: string) => void;
cloneItem: () => void;
importMacro: () => void;
exportMacro: () => void;
updateItem: (name: string) => void;
itemList: MacrosType[];
selectedItem: number;
subtitle: string;
mem: number;
tMem: number;
}

const MacroSelector: React.FC<any> = ({
const MacroSelector: React.FC<MacroSelectorProps> = ({
onSelect,
itemList,
selectedItem,
deleteItem,
addItem,
cloneItem,
importMacro,
exportMacro,
subtitle,
mem,
tMem,
Expand All @@ -62,13 +88,13 @@ const MacroSelector: React.FC<any> = ({
return (
<div className="flex items-center gap-1">
<div className="itemListelector dropdownMultipleActions max-w-[350px] min-w-[350px]">
<Select onValueChange={value => onSelect(parseInt(value, 10))} value={selectedItem}>
<SelectTrigger variant="combo" className="pr-[126px]">
<Select onValueChange={value => onSelect(parseInt(value, 10))} value={String(selectedItem)}>
<SelectTrigger variant="combo" className="pr-[80px]">
{/* dropdownListInner */}
<div className="flex flex-nowrap items-center">
{/* dropdownListNumber */}
<div className="relative self-center w-[34px] text-center pr-[8px] text-[13px] font-semibold tracking-tight text-gray-500 dark:text-gray-200 after:content-[' '] after:absolute after:flex after:w-[1px] after:h-[30px] after:right-0 after:top-1/2 after:transform-style-3d after:translate-y-[-50%] after:bg-gray-200/50 dark:after:bg-gray-500/50">
{itemList.length === 0 ? "#0" : `#${parseInt(selectedItem, 10) + 1}`}
{itemList.length === 0 ? "#0" : `#${selectedItem + 1}`}
</div>
{/* dropdownListItem style={{ width: "calc(100% - 42px)" }} */}
<div className="flex flex-wrap pl-[12px] leading-[1.25em] text-left">
Expand All @@ -88,45 +114,38 @@ const MacroSelector: React.FC<any> = ({
</div>
</SelectTrigger>
<SelectContent>
{itemList.map((item: ItemList, i: string) => (
<SelectItem key={`item-macro-id-${item.id}`} value={i}>
{itemList.map((item, i) => (
<SelectItem key={`item-macro-id-${item.id}`} value={String(i)}>
<em className="itemIndex inline-block w-7 mr-1 text-right not-italic">#{i + 1}.</em>
{item.name === "" ? i18n.general.noname : item.name}
</SelectItem>
))}
</SelectContent>
</Select>
<div className="absolute top-1 right-[44px]">
<DropdownMenu>
<DropdownMenuTrigger>
<div className="flex w-[36px] h-[36px] rounded-md items-center justify-center shadow-none p-0 text-purple-300 dark:text-white hover:text-purple-300 hover:dark:text-gray-50 bg-gradient-to-r from-gray-100/40 to-gray-25/40 hover:from-gray-70 hover:to-gray-25 dark:bg-none dark:bg-gray-600 dark:hover:bg-gray-500">
<IconSettings />
</div>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="min-w-56">
<DropdownMenuItem className="flex gap-2" onSelect={toggleShow}>
<IconPen /> {i18n.app.menu.changeName}
</DropdownMenuItem>
<DropdownMenuItem className="flex gap-2" onSelect={exportMacro}>
<IconArrowUpWithLine /> {i18n.editor.macros.exportTitle}
</DropdownMenuItem>
<DropdownMenuItem className="flex gap-2" onSelect={importMacro}>
<IconArrowDownWithLine /> {i18n.editor.macros.importTitle}
</DropdownMenuItem>
<DropdownMenuItem className="flex gap-2" onSelect={cloneItem}>
<IconClone /> {i18n.editor.macros.clone}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="absolute top-[2px] right-[2px] flex gap-0.5 p-0.5">
<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger asChild>
<div>
<Button variant="config" size="icon" onClick={toggleShow} className="!w-[36px] !h-[36px]">
<IconPen />
</Button>
</div>
</TooltipTrigger>
<TooltipContent className="max-w-xs" side="bottom" size="sm">
{i18n.app.menu.changeName}
</TooltipContent>
</Tooltip>
</TooltipProvider>

<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger asChild>
<div>
<Button variant="config" size="icon" onClick={cloneItem} className="!w-[36px] !h-[36px]">
<IconClone />
</Button>
</div>
</TooltipTrigger>
<TooltipContent className="max-w-xs" side="bottom" size="sm">
{i18n.general.clone}
</TooltipContent>
</Tooltip>
</TooltipProvider>

<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger asChild>
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const English = {
deviceDisconnected: "Keyboard disconnected",
deviceDisconnectedContent: "The device was disconnected from bazecor!",
invalidLayerFile: "Not a valid Layer file",
invalidMacroFile: "Not a valid Macro file",
tooManyMacros: "Too many macros!",
exportError: "Error at Exporting: ",
exportFailed: "Export failed!",
preferenceFailOnSave: "Whoops, Something Went Wrong!",
Expand Down Expand Up @@ -175,6 +177,9 @@ const English = {
backup: "Backup All",
backupMacro: "Backup Macros",
backupMacroFile: "Backup Macros to file",
exportTitle: "Export selected macro",
importTitle: "Import selected macro",
clone: "Clone",
copy: "Copy",
editMacros: "Edit macros",
delay: "Delay",
Expand Down Expand Up @@ -492,9 +497,11 @@ const English = {
pasteSuccess: "Pasted!",
importSuccessCurrentLayerTitle: "Imported successfully!",
importSuccessCurrentLayer: "Imported to current Layer successfully",
importSuccessCurrentMacro: "Imported to current Macro successfully",
importSuccessAllLayers: "Imported all Layers successfully",
exportSuccessCurrentLayer: "Ready to share!",
exportSuccessCurrentLayerContent: "Your layer has been successfully exported.",
exportSuccessCurrentMacroContent: "Your Macro has been successfully exported.",
exportSuccessAllLayers: "Exported all Layers successfully",
},
preferences: {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/modules/Settings/EnergyManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function EnergyManagement(props: EnergyManagementProps) {
<div className={`flex flex-col pt-3 ${!wireless.true_sleep ? "opacity-50 pointer-events-none" : "opacity-100"}`}>
<div className="block w-full relative">
<Slider
min={0}
min={1}
max={60}
step={1}
value={[Math.round(wireless.true_sleep_time / 60)]}
Expand Down
Loading

0 comments on commit 05d70e7

Please sign in to comment.