-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bitfocus: implement more of the API, show UI elements in the device s…
…ettings and send the first osc message
- Loading branch information
Showing
9 changed files
with
910 additions
and
437 deletions.
There are no files selected for viewing
459 changes: 459 additions & 0 deletions
459
src/plugins/score-plugin-protocols/Protocols/Bitfocus/BitfocusContext.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
496 changes: 95 additions & 401 deletions
496
src/plugins/score-plugin-protocols/Protocols/Bitfocus/BitfocusContext.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/plugins/score-plugin-protocols/Protocols/Bitfocus/BitfocusContext.unix.cpp
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,78 @@ | ||
#include "BitfocusContext.hpp" | ||
|
||
namespace bitfocus | ||
{ | ||
|
||
module_handler_base::module_handler_base(QString module_path) | ||
{ | ||
// Create socketpair | ||
socketpair(PF_LOCAL, SOCK_STREAM, 0, pfd); | ||
|
||
// Create env | ||
auto genv = QProcessEnvironment::systemEnvironment(); | ||
genv.insert("CONNECTION_ID", "connectionId"); | ||
genv.insert("VERIFICATION_TOKEN", "foobar"); | ||
genv.insert("MODULE_MANIFEST", module_path + "/companion/manifest.json"); | ||
genv.insert("NODE_CHANNEL_SERIALIZATION_MODE", "json"); | ||
genv.insert("NODE_CHANNEL_FD", QString::number(pfd[1]).toUtf8()); | ||
|
||
auto socket = new QSocketNotifier(pfd[0], QSocketNotifier::Read, this); | ||
QObject::connect( | ||
socket, &QSocketNotifier::activated, this, &module_handler_base::on_read); | ||
|
||
process.setProcessChannelMode(QProcess::ForwardedChannels); | ||
process.setProgram("node"); | ||
process.setArguments({"main.js"}); // FIXME entrypoint from spec | ||
process.setWorkingDirectory(module_path); | ||
process.setProcessEnvironment(genv); | ||
|
||
process.start(); | ||
|
||
// See https://forum.qt.io/topic/33964/solved-child-qprocess-that-dies-with-parent/10 | ||
|
||
/// Connection flow: | ||
// Create process | ||
// <- register call | ||
// -> register response | ||
|
||
// -> init call | ||
// <- upgradedItems | ||
// <- setActionDefinitions | ||
// <- setVariableDefinitions | ||
// <- etc. | ||
// <- init response | ||
} | ||
|
||
void module_handler_base::on_read(QSocketDescriptor, QSocketNotifier::Type) | ||
{ | ||
ssize_t rl = ::read(pfd[0], buf, sizeof(buf)); | ||
if(rl <= 0) | ||
return; | ||
char* pos = buf; | ||
char* idx = buf; | ||
char* const end = pos + rl; | ||
do | ||
{ | ||
idx = std::find(pos, end, '\n'); | ||
if(idx < end) | ||
{ | ||
std::ptrdiff_t diff = idx - pos; | ||
std::string_view message(pos, diff); | ||
this->processMessage(message); | ||
pos = idx + 1; | ||
continue; | ||
} | ||
} while(idx < end); | ||
} | ||
|
||
void module_handler_base::do_write(std::string_view res) | ||
{ | ||
::write(pfd[0], res.data(), res.size()); | ||
} | ||
|
||
void module_handler_base::do_write(const QByteArray& res) | ||
{ | ||
::write(pfd[0], res.data(), res.size()); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/plugins/score-plugin-protocols/Protocols/Bitfocus/BitfocusContext.win32.cpp
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 @@ | ||
#include "BitfocusContext.hpp" | ||
|
||
namespace bitfocus | ||
{ | ||
|
||
module_handler_base::module_handler_base(QString module_path) | ||
{ | ||
// https://doc.qt.io/qt-6/qwineventnotifier.html | ||
// https://forum.qt.io/topic/146343/qsocketnotifier-with-win32-namedpipes/9 | ||
// Or maybe QLocalSocket just works on windows? | ||
|
||
// FIXME | ||
} | ||
void module_handler_base::do_write(std::string_view res) | ||
{ | ||
// FIXME | ||
} | ||
|
||
void module_handler_base::do_write(const QByteArray& res) | ||
{ | ||
// FIXME | ||
} | ||
|
||
} |
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.