Skip to content

Commit

Permalink
Npm run format (OpenStickCommunity#1026)
Browse files Browse the repository at this point in the history
Updating everything with npm run format. This will give us some better consistency with line spacing and styling
  • Loading branch information
arntsonl authored May 30, 2024
1 parent aa0a6f8 commit affc3c4
Show file tree
Hide file tree
Showing 53 changed files with 3,150 additions and 2,333 deletions.
261 changes: 171 additions & 90 deletions www/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,54 +481,54 @@ app.get('/api/getAddonsOptions', (req, res) => {
analog1256DrdyPin: -1,
analog1256AnalogMax: 3.3,
analog1256EnableTriggers: false,
encoderOneEnabled: 0,
encoderOnePinA: -1,
encoderOnePinB: -1,
encoderOneMode: 0,
encoderOnePPR: 24,
encoderOneResetAfter: 0,
encoderOneAllowWrapAround: false,
encoderOneMultiplier: 1,
encoderTwoEnabled: 0,
encoderTwoPinA: -1,
encoderTwoPinB: -1,
encoderTwoMode: 0,
encoderTwoPPR: 24,
encoderTwoResetAfter: 0,
encoderTwoAllowWrapAround: false,
encoderTwoMultiplier: 1,
RotaryAddonEnabled: 1,
pcf8575Block: 0,
PCF8575AddonEnabled: 1,
encoderOneEnabled: 0,
encoderOnePinA: -1,
encoderOnePinB: -1,
encoderOneMode: 0,
encoderOnePPR: 24,
encoderOneResetAfter: 0,
encoderOneAllowWrapAround: false,
encoderOneMultiplier: 1,
encoderTwoEnabled: 0,
encoderTwoPinA: -1,
encoderTwoPinB: -1,
encoderTwoMode: 0,
encoderTwoPPR: 24,
encoderTwoResetAfter: 0,
encoderTwoAllowWrapAround: false,
encoderTwoMultiplier: 1,
RotaryAddonEnabled: 1,
pcf8575Block: 0,
PCF8575AddonEnabled: 1,
usedPins: Object.values(picoController),
});
});

app.get('/api/getExpansionPins', (req, res) => {
return res.send({
"pins": {
"pcf8575": [
{
"pin00": {"option": 2,"direction": 0},
"pin01": {"option": -10,"direction": 0},
"pin02": {"option": -10,"direction": 0},
"pin03": {"option": -10,"direction": 0},
"pin04": {"option": -10,"direction": 0},
"pin05": {"option": -10,"direction": 0},
"pin06": {"option": -10,"direction": 0},
"pin07": {"option": -10,"direction": 0},
"pin08": {"option": -10,"direction": 0},
"pin09": {"option": -10,"direction": 0},
"pin10": {"option": -10,"direction": 0},
"pin11": {"option": -10,"direction": 0},
"pin12": {"option": -10,"direction": 0},
"pin13": {"option": -10,"direction": 0},
"pin14": {"option": -10,"direction": 0},
"pin15": {"option": -10,"direction": 0}
}
]
}
});
return res.send({
pins: {
pcf8575: [
{
pin00: { option: 2, direction: 0 },
pin01: { option: -10, direction: 0 },
pin02: { option: -10, direction: 0 },
pin03: { option: -10, direction: 0 },
pin04: { option: -10, direction: 0 },
pin05: { option: -10, direction: 0 },
pin06: { option: -10, direction: 0 },
pin07: { option: -10, direction: 0 },
pin08: { option: -10, direction: 0 },
pin09: { option: -10, direction: 0 },
pin10: { option: -10, direction: 0 },
pin11: { option: -10, direction: 0 },
pin12: { option: -10, direction: 0 },
pin13: { option: -10, direction: 0 },
pin14: { option: -10, direction: 0 },
pin15: { option: -10, direction: 0 },
},
],
},
});
});

app.get('/api/getMacroAddonOptions', (req, res) => {
Expand All @@ -553,26 +553,61 @@ app.get('/api/getMacroAddonOptions', (req, res) => {
},
],
},
{ enabled: 0, exclusive: 1, interruptible: 1, showFrames: 1,
macroType: 1, useMacroTriggerButton: 0,
macroTriggerButton: 0, macroLabel: '',
macroInputs: [],},
{ enabled: 0, exclusive: 1, interruptible: 1, showFrames: 1,
macroType: 1, useMacroTriggerButton: 0,
macroTriggerButton: 0, macroLabel: '',
macroInputs: [],},
{ enabled: 0, exclusive: 1, interruptible: 1, showFrames: 1,
macroType: 1, useMacroTriggerButton: 0,
macroTriggerButton: 0, macroLabel: '',
macroInputs: [],},
{ enabled: 0, exclusive: 1, interruptible: 1, showFrames: 1,
macroType: 1, useMacroTriggerButton: 0,
macroTriggerButton: 0, macroLabel: '',
macroInputs: [],},
{ enabled: 0, exclusive: 1, interruptible: 1, showFrames: 1,
macroType: 1, useMacroTriggerButton: 0,
macroTriggerButton: 0, macroLabel: '',
macroInputs: [],},
{
enabled: 0,
exclusive: 1,
interruptible: 1,
showFrames: 1,
macroType: 1,
useMacroTriggerButton: 0,
macroTriggerButton: 0,
macroLabel: '',
macroInputs: [],
},
{
enabled: 0,
exclusive: 1,
interruptible: 1,
showFrames: 1,
macroType: 1,
useMacroTriggerButton: 0,
macroTriggerButton: 0,
macroLabel: '',
macroInputs: [],
},
{
enabled: 0,
exclusive: 1,
interruptible: 1,
showFrames: 1,
macroType: 1,
useMacroTriggerButton: 0,
macroTriggerButton: 0,
macroLabel: '',
macroInputs: [],
},
{
enabled: 0,
exclusive: 1,
interruptible: 1,
showFrames: 1,
macroType: 1,
useMacroTriggerButton: 0,
macroTriggerButton: 0,
macroLabel: '',
macroInputs: [],
},
{
enabled: 0,
exclusive: 1,
interruptible: 1,
showFrames: 1,
macroType: 1,
useMacroTriggerButton: 0,
macroTriggerButton: 0,
macroLabel: '',
macroInputs: [],
},
],
macroBoardLedEnabled: 1,
});
Expand Down Expand Up @@ -608,34 +643,80 @@ app.get('/api/getButtonLayoutCustomOptions', (req, res) => {

app.get('/api/getButtonLayoutDefs', (req, res) => {
return res.send({
"buttonLayout":{
"BUTTON_LAYOUT_STICK":0,"BUTTON_LAYOUT_STICKLESS":1,"BUTTON_LAYOUT_BUTTONS_ANGLED":2,
"BUTTON_LAYOUT_BUTTONS_BASIC":3,"BUTTON_LAYOUT_KEYBOARD_ANGLED":4,"BUTTON_LAYOUT_KEYBOARDA":5,
"BUTTON_LAYOUT_DANCEPADA":6,"BUTTON_LAYOUT_TWINSTICKA":7,"BUTTON_LAYOUT_BLANKA":8,
"BUTTON_LAYOUT_VLXA":9,"BUTTON_LAYOUT_FIGHTBOARD_STICK":10,"BUTTON_LAYOUT_FIGHTBOARD_MIRRORED":11,
"BUTTON_LAYOUT_CUSTOMA":12,"BUTTON_LAYOUT_OPENCORE0WASDA":13,"BUTTON_LAYOUT_STICKLESS_13":14,
"BUTTON_LAYOUT_STICKLESS_16":15,"BUTTON_LAYOUT_STICKLESS_14":16,"BUTTON_LAYOUT_DANCEPAD_DDR_LEFT":17,
"BUTTON_LAYOUT_DANCEPAD_DDR_SOLO":18,"BUTTON_LAYOUT_DANCEPAD_PIU_LEFT":19,"BUTTON_LAYOUT_POPN_A":20,
"BUTTON_LAYOUT_TAIKO_A":21,"BUTTON_LAYOUT_BM_TURNTABLE_A":22,"BUTTON_LAYOUT_BM_5KEY_A":23,
"BUTTON_LAYOUT_BM_7KEY_A":24,"BUTTON_LAYOUT_GITADORA_FRET_A":25,"BUTTON_LAYOUT_GITADORA_STRUM_A":26,
"BUTTON_LAYOUT_BOARD_DEFINED_A":27,"BUTTON_LAYOUT_BANDHERO_FRET_A":28,"BUTTON_LAYOUT_BANDHERO_STRUM_A":29,
"BUTTON_LAYOUT_6GAWD_A":30,"BUTTON_LAYOUT_6GAWD_ALLBUTTON_A":31,"BUTTON_LAYOUT_6GAWD_ALLBUTTONPLUS_A":32
buttonLayout: {
BUTTON_LAYOUT_STICK: 0,
BUTTON_LAYOUT_STICKLESS: 1,
BUTTON_LAYOUT_BUTTONS_ANGLED: 2,
BUTTON_LAYOUT_BUTTONS_BASIC: 3,
BUTTON_LAYOUT_KEYBOARD_ANGLED: 4,
BUTTON_LAYOUT_KEYBOARDA: 5,
BUTTON_LAYOUT_DANCEPADA: 6,
BUTTON_LAYOUT_TWINSTICKA: 7,
BUTTON_LAYOUT_BLANKA: 8,
BUTTON_LAYOUT_VLXA: 9,
BUTTON_LAYOUT_FIGHTBOARD_STICK: 10,
BUTTON_LAYOUT_FIGHTBOARD_MIRRORED: 11,
BUTTON_LAYOUT_CUSTOMA: 12,
BUTTON_LAYOUT_OPENCORE0WASDA: 13,
BUTTON_LAYOUT_STICKLESS_13: 14,
BUTTON_LAYOUT_STICKLESS_16: 15,
BUTTON_LAYOUT_STICKLESS_14: 16,
BUTTON_LAYOUT_DANCEPAD_DDR_LEFT: 17,
BUTTON_LAYOUT_DANCEPAD_DDR_SOLO: 18,
BUTTON_LAYOUT_DANCEPAD_PIU_LEFT: 19,
BUTTON_LAYOUT_POPN_A: 20,
BUTTON_LAYOUT_TAIKO_A: 21,
BUTTON_LAYOUT_BM_TURNTABLE_A: 22,
BUTTON_LAYOUT_BM_5KEY_A: 23,
BUTTON_LAYOUT_BM_7KEY_A: 24,
BUTTON_LAYOUT_GITADORA_FRET_A: 25,
BUTTON_LAYOUT_GITADORA_STRUM_A: 26,
BUTTON_LAYOUT_BOARD_DEFINED_A: 27,
BUTTON_LAYOUT_BANDHERO_FRET_A: 28,
BUTTON_LAYOUT_BANDHERO_STRUM_A: 29,
BUTTON_LAYOUT_6GAWD_A: 30,
BUTTON_LAYOUT_6GAWD_ALLBUTTON_A: 31,
BUTTON_LAYOUT_6GAWD_ALLBUTTONPLUS_A: 32,
},
buttonLayoutRight: {
BUTTON_LAYOUT_ARCADE: 0,
BUTTON_LAYOUT_STICKLESSB: 1,
BUTTON_LAYOUT_BUTTONS_ANGLEDB: 2,
BUTTON_LAYOUT_VEWLIX: 3,
BUTTON_LAYOUT_VEWLIX7: 4,
BUTTON_LAYOUT_CAPCOM: 5,
BUTTON_LAYOUT_CAPCOM6: 6,
BUTTON_LAYOUT_SEGA2P: 7,
BUTTON_LAYOUT_NOIR8: 8,
BUTTON_LAYOUT_KEYBOARDB: 9,
BUTTON_LAYOUT_DANCEPADB: 10,
BUTTON_LAYOUT_TWINSTICKB: 11,
BUTTON_LAYOUT_BLANKB: 12,
BUTTON_LAYOUT_VLXB: 13,
BUTTON_LAYOUT_FIGHTBOARD: 14,
BUTTON_LAYOUT_FIGHTBOARD_STICK_MIRRORED: 15,
BUTTON_LAYOUT_CUSTOMB: 16,
BUTTON_LAYOUT_KEYBOARD8B: 17,
BUTTON_LAYOUT_OPENCORE0WASDB: 18,
BUTTON_LAYOUT_STICKLESS_13B: 19,
BUTTON_LAYOUT_STICKLESS_16B: 20,
BUTTON_LAYOUT_STICKLESS_14B: 21,
BUTTON_LAYOUT_DANCEPAD_DDR_RIGHT: 22,
BUTTON_LAYOUT_DANCEPAD_PIU_RIGHT: 23,
BUTTON_LAYOUT_POPN_B: 24,
BUTTON_LAYOUT_TAIKO_B: 25,
BUTTON_LAYOUT_BM_TURNTABLE_B: 26,
BUTTON_LAYOUT_BM_5KEY_B: 27,
BUTTON_LAYOUT_BM_7KEY_B: 28,
BUTTON_LAYOUT_GITADORA_FRET_B: 29,
BUTTON_LAYOUT_GITADORA_STRUM_B: 30,
BUTTON_LAYOUT_BOARD_DEFINED_B: 31,
BUTTON_LAYOUT_BANDHERO_FRET_B: 32,
BUTTON_LAYOUT_BANDHERO_STRUM_B: 33,
BUTTON_LAYOUT_6GAWD_B: 34,
BUTTON_LAYOUT_6GAWD_ALLBUTTON_B: 35,
BUTTON_LAYOUT_6GAWD_ALLBUTTONPLUS_B: 36,
},
"buttonLayoutRight":{
"BUTTON_LAYOUT_ARCADE":0,"BUTTON_LAYOUT_STICKLESSB":1,"BUTTON_LAYOUT_BUTTONS_ANGLEDB":2,
"BUTTON_LAYOUT_VEWLIX":3,"BUTTON_LAYOUT_VEWLIX7":4,"BUTTON_LAYOUT_CAPCOM":5,
"BUTTON_LAYOUT_CAPCOM6":6,"BUTTON_LAYOUT_SEGA2P":7,"BUTTON_LAYOUT_NOIR8":8,
"BUTTON_LAYOUT_KEYBOARDB":9,"BUTTON_LAYOUT_DANCEPADB":10,"BUTTON_LAYOUT_TWINSTICKB":11,
"BUTTON_LAYOUT_BLANKB":12,"BUTTON_LAYOUT_VLXB":13,"BUTTON_LAYOUT_FIGHTBOARD":14,
"BUTTON_LAYOUT_FIGHTBOARD_STICK_MIRRORED":15,"BUTTON_LAYOUT_CUSTOMB":16,
"BUTTON_LAYOUT_KEYBOARD8B":17,"BUTTON_LAYOUT_OPENCORE0WASDB":18,"BUTTON_LAYOUT_STICKLESS_13B":19,
"BUTTON_LAYOUT_STICKLESS_16B":20,"BUTTON_LAYOUT_STICKLESS_14B":21,"BUTTON_LAYOUT_DANCEPAD_DDR_RIGHT":22,
"BUTTON_LAYOUT_DANCEPAD_PIU_RIGHT":23,"BUTTON_LAYOUT_POPN_B":24,"BUTTON_LAYOUT_TAIKO_B":25,
"BUTTON_LAYOUT_BM_TURNTABLE_B":26,"BUTTON_LAYOUT_BM_5KEY_B":27,"BUTTON_LAYOUT_BM_7KEY_B":28,
"BUTTON_LAYOUT_GITADORA_FRET_B":29,"BUTTON_LAYOUT_GITADORA_STRUM_B":30,"BUTTON_LAYOUT_BOARD_DEFINED_B":31,
"BUTTON_LAYOUT_BANDHERO_FRET_B":32,"BUTTON_LAYOUT_BANDHERO_STRUM_B":33,"BUTTON_LAYOUT_6GAWD_B":34,
"BUTTON_LAYOUT_6GAWD_ALLBUTTON_B":35,"BUTTON_LAYOUT_6GAWD_ALLBUTTONPLUS_B":36
}
});
});

Expand Down
44 changes: 26 additions & 18 deletions www/src/Addons/Analog1256.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ import { SPI_BLOCKS } from '../Data/Peripherals';
import WebApi from '../Services/WebApi';

export const analog1256Scheme = {
Analog1256Enabled: yup
.number()
.label('Analog1256 Input Enabled'),
Analog1256Enabled: yup.number().label('Analog1256 Input Enabled'),
analog1256Block: yup
.number()
.label('Analog1256 Block')
.validateSelectionWhenValue('Analog1256Enabled', SPI_BLOCKS),
analog1256CsPin: yup
.number()
.label('Analog1256 CS Pin'),
analog1256CsPin: yup.number().label('Analog1256 CS Pin'),
analog1256DrdyPin: yup
.number()
.label('Analog1256 DRDY Pin')
Expand All @@ -39,7 +35,12 @@ export const analog1256State = {
};

const Analog1256 = ({ values, errors, handleChange, handleCheckbox }) => {
const { getAvailablePeripherals, getSelectedPeripheral, setLoading, usedPins } = useContext(AppContext);
const {
getAvailablePeripherals,
getSelectedPeripheral,
setLoading,
usedPins,
} = useContext(AppContext);
const [csPins, setCsPins] = useState([]);

const { t } = useTranslation();
Expand All @@ -53,13 +54,20 @@ const Analog1256 = ({ values, errors, handleChange, handleCheckbox }) => {
const csPins = [];

const peripheralOptions = await WebApi.getPeripheralOptions(setLoading);
if (peripheralOptions.peripheral[`spi${spiBlock}`] && peripheralOptions.peripheral[`spi${spiBlock}`].cs > -1)
csPins.push({ pin: peripheralOptions.peripheral[`spi${spiBlock}`].cs, hwcs: true });
if (
peripheralOptions.peripheral[`spi${spiBlock}`] &&
peripheralOptions.peripheral[`spi${spiBlock}`].cs > -1
)
csPins.push({
pin: peripheralOptions.peripheral[`spi${spiBlock}`].cs,
hwcs: true,
});

const availablePins = [...Array(boards[import.meta.env.VITE_GP2040_BOARD].maxPin + 1).keys()]
.filter(p => (usedPins || []).indexOf(p) === -1) // Filter out used pins
const availablePins = [
...Array(boards[import.meta.env.VITE_GP2040_BOARD].maxPin + 1).keys(),
].filter((p) => (usedPins || []).indexOf(p) === -1); // Filter out used pins

csPins.push(...availablePins.map(pin => ({ pin, hwcs: false })));
csPins.push(...availablePins.map((pin) => ({ pin, hwcs: false })));

return csPins;
};
Expand All @@ -77,9 +85,7 @@ const Analog1256 = ({ values, errors, handleChange, handleCheckbox }) => {
<Section title={t('AddonsConfig:analog1256-header-text')}>
<div
id="Analog1256InputOptions"
hidden={
!(values.Analog1256Enabled && getAvailablePeripherals('spi'))
}
hidden={!(values.Analog1256Enabled && getAvailablePeripherals('spi'))}
>
<Row className="mb-3">
{getAvailablePeripherals('spi') ? (
Expand Down Expand Up @@ -113,7 +119,10 @@ const Analog1256 = ({ values, errors, handleChange, handleCheckbox }) => {
onChange={handleChange}
>
{csPins.map((p, i) => (
<option key={`cs-pin-select-${i}`} value={p.pin}>{p.pin}{p.hwcs ? ' (HW)' : ''}</option>
<option key={`cs-pin-select-${i}`} value={p.pin}>
{p.pin}
{p.hwcs ? ' (HW)' : ''}
</option>
))}
</FormSelect>
<FormControl
Expand Down Expand Up @@ -164,8 +173,7 @@ const Analog1256 = ({ values, errors, handleChange, handleCheckbox }) => {
reverse
isInvalid={false}
checked={
Boolean(values.Analog1256Enabled) &&
getAvailablePeripherals('spi')
Boolean(values.Analog1256Enabled) && getAvailablePeripherals('spi')
}
onChange={(e) => {
handleCheckbox('Analog1256Enabled', values);
Expand Down
6 changes: 1 addition & 5 deletions www/src/Addons/DualDirection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ const DualDirection = ({ values, errors, handleChange, handleCheckbox }) => {
hidden={!values.DualDirectionalInputEnabled}
>
<Row className="mb-3">
<p>
{t(
'AddonsConfig:pin-config-moved-to-core-text',
)}
</p>
<p>{t('AddonsConfig:pin-config-moved-to-core-text')}</p>
<FormSelect
label={t('AddonsConfig:dual-directional-input-dpad-mode-label')}
name="dualDirDpadMode"
Expand Down
Loading

0 comments on commit affc3c4

Please sign in to comment.