Skip to content

Commit

Permalink
adds webconfiguration options for SNESpad controller input
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertDaleSmith committed May 15, 2023
1 parent dcfec9a commit 81a57cd
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions www/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ app.get("/api/getAddonsOptions", (req, res) => {
wiiExtensionSCLPin: -1,
wiiExtensionBlock: 0,
wiiExtensionSpeed: 400000,
snesPadLatchPin: -1,
snesPadClockPin: -1,
snesPadDataPin: -1,
AnalogInputEnabled: 1,
BoardLedAddonEnabled: 1,
BuzzerSpeakerAddonEnabled: 1,
Expand All @@ -236,6 +239,7 @@ app.get("/api/getAddonsOptions", (req, res) => {
SliderSOCDInputEnabled: 1,
TurboInputEnabled: 1,
WiiExtensionAddonEnabled: 1,
SNESpadAddonEnabled: 1,
usedPins: Object.values(picoController),
});
});
Expand Down
73 changes: 73 additions & 0 deletions www/src/Pages/AddonsConfigPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ const defaultValues = {
wiiExtensionSCLPin: -1,
wiiExtensionBlock: 0,
wiiExtensionSpeed: 400000,
snesPadLatchPin: -1,
snesPadClockPin: -1,
snesPadDataPin: -1,
AnalogInputEnabled: 0,
BoardLedAddonEnabled: 0,
BuzzerSpeakerAddonEnabled: 0,
Expand All @@ -399,6 +402,7 @@ const defaultValues = {
ReverseInputEnabled: 0,
TurboInputEnabled: 0,
WiiExtensionAddonEnabled: 0,
SNESpadAddonEnabled: 0,
};

const FormContext = ({setStoredData}) => {
Expand Down Expand Up @@ -530,6 +534,12 @@ const sanitizeData = (values) => {
values.wiiExtensionBlock = parseInt(values.wiiExtensionBlock);
if (!!values.wiiExtensionSpeed)
values.wiiExtensionSpeed = parseInt(values.wiiExtensionSpeed);
if (!!values.snesPadLatchPin)
values.snesPadLatchPin = parseInt(values.snesPadLatchPin);
if (!!values.snesPadClockPin)
values.snesPadClockPin = parseInt(values.snesPadClockPin);
if (!!values.snesPadDataPin)
values.snesPadDataPin = parseInt(values.snesPadDataPin);
if (!!values.AnalogInputEnabled)
values.AnalogInputEnabled = parseInt(values.AnalogInputEnabled);
if (!!values.BoardLedAddonEnabled)
Expand Down Expand Up @@ -558,6 +568,8 @@ const sanitizeData = (values) => {
values.TurboInputEnabled = parseInt(values.TurboInputEnabled);
if (!!values.WiiExtensionAddonEnabled)
values.WiiExtensionAddonEnabled = parseInt(values.WiiExtensionAddonEnabled);
if (!!values.SNESpadAddonEnabled)
values.SNESpadAddonEnabled = parseInt(values.SNESpadAddonEnabled);
}

function flattenObject(object) {
Expand Down Expand Up @@ -1564,6 +1576,67 @@ export default function AddonsConfigPage() {
onChange={(e) => {handleCheckbox("WiiExtensionAddonEnabled", values); handleChange(e);}}
/>
</Section>
<Section title="Snes Extension Configuration">
<div
id="SNESpadAddonOptions"
hidden={!values.SNESpadAddonEnabled}>
<Row>
<p>Note: If the Display is enabled at the same time, this Addon will be disabled.</p>
<h3>Currently Supported Controllers</h3>
<p>SNES pad: D-Pad Supported. B = B1, A = B2, Y = B3, X = B4, L = L1, R = R1, Select = S1, Start = S2</p>
<p>SNES mouse: Analog Stick Supported. Left Click = B1, Right Click = B2</p>
<p>NES: D-Pad Supported. B = B1, A = B2, Select = S1, Start = S2</p>
</Row>
<Row className="mb-3">
<FormControl type="number"
label="Latch Pin"
name="snesPadLatchPin"
className="form-control-sm"
groupClassName="col-sm-3 mb-3"
value={values.snesPadLatchPin}
error={errors.snesPadLatchPin}
isInvalid={errors.snesPadLatchPin}
onChange={handleChange}
min={-1}
max={29}
/>
<FormControl type="number"
label="Clock Pin"
name="snesPadClockPin"
className="form-select-sm"
groupClassName="col-sm-3 mb-3"
value={values.snesPadClockPin}
error={errors.snesPadClockPin}
isInvalid={errors.snesPadClockPin}
onChange={handleChange}
min={-1}
max={29}
/>
<FormControl type="number"
label="Data Pin"
name="snesPadDataPin"
className="form-select-sm"
groupClassName="col-sm-3 mb-3"
value={values.snesPadDataPin}
error={errors.snesPadDataPin}
isInvalid={errors.snesPadDataPin}
onChange={handleChange}
min={-1}
max={29}
/>
</Row>
</div>
<FormCheck
label="Enabled"
type="switch"
id="SNESpadButton"
reverse="true"
error={undefined}
isInvalid={false}
checked={Boolean(values.SNESpadAddonEnabled)}
onChange={(e) => {handleCheckbox("SNESpadAddonEnabled", values); handleChange(e);}}
/>
</Section>
<div className="mt-3">
<Button type="submit" id="save">Save</Button>
{saveMessage ? <span className="alert">{saveMessage}</span> : null}
Expand Down

0 comments on commit 81a57cd

Please sign in to comment.