Skip to content

Commit

Permalink
Multi-mapping route added to webconfig, start adding customDpadMask
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelsin committed Feb 28, 2024
1 parent 3834e9d commit d471c75
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/configs/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace std;

extern struct fsdata_file file__index_html[];

const static char* spaPaths[] = { "/backup", "/display-config", "/led-config", "/pin-mapping", "/keyboard-mapping", "/settings", "/reset-settings", "/add-ons", "/custom-theme", "/macro", "/peripheral-mapping" };
const static char* spaPaths[] = { "/backup", "/display-config", "/led-config", "/pin-mapping", "/multi-mapping", "/keyboard-mapping", "/settings", "/reset-settings", "/add-ons", "/custom-theme", "/macro", "/peripheral-mapping" };
const static char* excludePaths[] = { "/css", "/images", "/js", "/static" };
const static uint32_t rebootDelayMs = 500;
static string http_post_uri;
Expand Down
5 changes: 4 additions & 1 deletion www/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ app.get('/api/getCustomTheme', (req, res) => {
app.get('/api/getPinMappingsV2', (req, res) => {
return res.send(
Object.entries(picoController).reduce(
(acc, [key]) => ({ ...acc, [key]: { action: 0, customButtonMask: 0 } }),
(acc, [key]) => ({
...acc,
[key]: { action: 0, customButtonMask: 0, customDpadMask: 0 },
}),
{},
),
);
Expand Down
18 changes: 12 additions & 6 deletions www/src/Data/Buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ export const KEYBOARD_LAYOUT = [
['R1', 'R2'],
['L1', 'L2'],
];
export const DPAD_MASKS = [
{ label: 'Up', value: 0 },
{ label: 'Down', value: 1 },
{ label: 'Left', value: 2 },
{ label: 'right', value: 3 },
];

export const BUTTON_MASKS = [
{ label: 'None', value: 0 },
Expand All @@ -234,18 +240,18 @@ export const BUTTON_MASKS = [
export const ANALOG_PINS = [26, 27, 28, 29];

// deep copy and swp
export const getButtonLabels = (labelType, swapTpShareLabels = false)=> {
export const getButtonLabels = (labelType, swapTpShareLabels = false) => {
const buttons = BUTTONS[labelType];

if (labelType == 'ps4' && swapTpShareLabels) {
const buttonLabelS1 = buttons['S1'];
const buttonLabelA2 = buttons['A2'];
return {
...buttons,
"S1": buttonLabelA2,
"A2": buttonLabelS1,
}
S1: buttonLabelA2,
A2: buttonLabelS1,
};
} else {
return buttons
return buttons;
}
}
};
13 changes: 11 additions & 2 deletions www/src/Store/useMultiPinStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { create } from 'zustand';
import WebApi from '../Services/WebApi';
import { BUTTON_ACTIONS } from '../Data/Pins';

export type MaskPayload = { action: number; customButtonMask: number };
export type MaskPayload = {
action: number;
customButtonMask: number;
customDpadMask: number;
};
type State = {
pins: { [key: string]: MaskPayload };
loadingPins: boolean;
Expand All @@ -14,7 +18,11 @@ type Actions = {
setPinMask: (pin: string, customButtonMask: number) => void;
savePins: () => Promise<object>;
};
const DEFAULT_MASKS_STATE = { action: 0, customButtonMask: 0 };
const DEFAULT_MASKS_STATE = {
action: 0,
customButtonMask: 0,
customDpadMask: 0,
};
const INITIAL_STATE: State = {
pins: {
pin00: DEFAULT_MASKS_STATE,
Expand Down Expand Up @@ -70,6 +78,7 @@ const useMultiPinStore = create<State & Actions>()((set, get) => ({
[pin]: {
action: customButtonMask ? BUTTON_ACTIONS.CUSTOM_BUTTON_COMBO : 0,
customButtonMask,
customDpadMask: 0,
},
},
})),
Expand Down

0 comments on commit d471c75

Please sign in to comment.