-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bmd-videohub: add quad button routing
- Loading branch information
1 parent
e96a63e
commit 79292a2
Showing
11 changed files
with
200 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const express = require("express"); | ||
const buttonSetQuad = require("@services/button-setquad"); | ||
const route = express.Router(); | ||
|
||
route.get("/set/:index/:type", async function (req, res, next) { | ||
try { | ||
res.json({ | ||
status: "success", | ||
data: await buttonSetQuad(req.params?.type, req.params?.index, true), | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
res.json({ | ||
status: "error", | ||
message: "Failed to set quad", | ||
}); | ||
} | ||
}); | ||
|
||
route.get("/unset/:index/:type", async function (req, res, next) { | ||
try { | ||
res.json({ | ||
status: "success", | ||
data: await buttonSetQuad(req.params?.type, req.params?.index, false), | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
res.json({ | ||
status: "error", | ||
message: "Failed to unset quad", | ||
}); | ||
} | ||
}); | ||
|
||
module.exports = route; |
24 changes: 24 additions & 0 deletions
24
src/modules/bmd-videohub/container/services/button-setquad.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
|
||
const configGet = require("@core/config-get"); | ||
const configPutViaCore = require("@core/config-putviacore"); | ||
|
||
module.exports = async (type, buttonIndex, value) => { | ||
const config = await configGet(); | ||
if (!config) { | ||
return false; | ||
} | ||
|
||
// update quad | ||
let typeVar = `${type}Quads`; | ||
if (!config[typeVar]) { | ||
config[typeVar] = []; | ||
} | ||
|
||
if (config[typeVar].length < buttonIndex) { | ||
config[typeVar].fill(config[typeVar].length, buttonIndex); | ||
} | ||
config[typeVar][buttonIndex] = value; | ||
|
||
return await configPutViaCore(config); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.