Skip to content

Commit

Permalink
Modified gamepad options so vendorID and productID are strings instea…
Browse files Browse the repository at this point in the history
…d of integers when passing data to the web config. Saving is still an integer so we don't have to parse the string on the webconfig.cpp side.
  • Loading branch information
arntsonl committed Jan 2, 2025
1 parent 1fda411 commit b5ce02e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
11 changes: 8 additions & 3 deletions src/configs/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,14 @@ std::string getGamepadOptions()
writeDoc(doc, "usbDescProduct", gamepadOptions.usbDescProduct);
writeDoc(doc, "usbDescVersion", gamepadOptions.usbDescVersion);
writeDoc(doc, "usbOverrideID", gamepadOptions.usbOverrideID);
writeDoc(doc, "usbVendorID", gamepadOptions.usbVendorID);
writeDoc(doc, "usbProductID", gamepadOptions.usbProductID);

// Write USB Vendor ID and Product ID as 4 character hex strings with 0 padding
char idBuffer[5];
snprintf(idBuffer, 4, "%04X", gamepadOptions.usbVendorID);
idBuffer[4] = '\0';
writeDoc(doc, "usbVendorID", idBuffer);
snprintf(idBuffer, 4, "%04X", gamepadOptions.usbProductID);
idBuffer[4] = '\0';
writeDoc(doc, "usbProductID", idBuffer);
writeDoc(doc, "fnButtonPin", -1);
GpioMappingInfo* gpioMappings = Storage::getInstance().getGpioMappings().pins;
for (unsigned int pin = 0; pin < NUM_BANK0_GPIOS; pin++) {
Expand Down
4 changes: 2 additions & 2 deletions www/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ app.get('/api/getGamepadOptions', (req, res) => {
usbDescManufacturer: 'Open Stick Community',
usbDescVersion: '1.0',
usbOverrideID: 0,
usbVendorID: 4292,
usbProductID: 33472,
usbVendorID: '10C4',
usbProductID: '82C0',
hotkey01: {
auxMask: 32768,
buttonsMask: 66304,
Expand Down
6 changes: 4 additions & 2 deletions www/src/Pages/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,11 @@ export default function SettingsPage() {
size="sm"
type="text"
name="usbVendorID"
value={values.usbVendorID.toString(16).toUpperCase()}
value={values.usbVendorID}
error={errors.usbVendorID}
isInvalid={errors?.usbVendorID}
onChange={handleChange}
onBlur={(e)=>{e.target.value = e.target.value.padStart(4,'0'); return handleChange(e)}}
minLength={4}
maxLength={4}
/>
Expand All @@ -1076,10 +1077,11 @@ export default function SettingsPage() {
size="sm"
type="text"
name="usbProductID"
value={values.usbProductID.toString(16).toUpperCase()}
value={values.usbProductID}
error={errors?.usbProductID}
isInvalid={errors?.usbProductID}
onChange={handleChange}
onBlur={(e)=>{e.target.value = e.target.value.padStart(4,'0'); return handleChange(e)}}
minLength={4}
maxLength={4}
/>
Expand Down
4 changes: 0 additions & 4 deletions www/src/Services/WebApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ async function getGamepadOptions(setLoading) {
try {
const response = await Http.get(`${baseUrl}/api/getGamepadOptions`);
setLoading(false);

response.data.usbVendorID = response.data.usbVendorID.toString(16).toUpperCase() || '0000';
response.data.usbProductID = response.data.usbProductID.toString(16).toUpperCase() || '0000';

return response.data;
} catch (error) {
setLoading(false);
Expand Down

0 comments on commit b5ce02e

Please sign in to comment.