-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ControllerEngine Refactoring #3463
ControllerEngine Refactoring #3463
Conversation
* Move src/controllers/engine to src/controllers/scripting * Create src/controllers/scripting/legacy subfolder * Rename ControllerEngine to ControllerScriptHandler * Rename ControllerEngineJSProxy to ControllerScriptInterface
This allows for a clean separation between new and legacy code.
This avoids calling two separate JS functions (one to convert the ArrayBuffer to a Uint8Array then the callback) every time controller input is received.
ArrayBuffer is more useful for HID and perhaps other use cases. For backwards compatibility, continue to convert the ArrayBuffer to a Uint8Array in ControllerScriptEngineLegacy following discussion on https://github.com/mixxxdj/mixxx/pull/2920/files/9363b497e13e39191655441a32b458f0af1727d8..e25bf12ab4bd910745d4359a9b3520b8c7f673c9#diff-69d807d0e5894e9f5bf1bd447ca878ab
Thanks codespell!
This will be reimplemented differently in the future.
m_pJSEngine is never passed to other threads
With the new engine, this should be implement in JavaScript code, e.g. inside the MIDI dispatcher class or something like that.
src/controllers/scripting/legacy/controllerscriptenginelegacy.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviving this branch. I have left some comments.
src/controllers/controllerdebug.h
Outdated
s_testing = true; | ||
} | ||
|
||
static ControlFlags shouldAssertForInvalidControlObjects() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name is a question that can be answered with true or false but not with individual flags.
I would prefer to make this bool, because the flags are an implementation detail of code out of sight.
Alternative we need a new name.
|
||
static ControlFlags shouldAssertForInvalidControlObjects() { | ||
if (s_enabled && !s_testing) { | ||
return ControlFlag::None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None means assert all assumptions. What is the reasoning that we don't want that during tests? Is this correct:
s_testing = true | s_testing = false | |
---|---|---|
s_enabled = true | ignore | assert |
s_enabled = false | ignore | ignore |
Please add a comment why.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may also consider to rename ControlFlag::None to
ControlFlag::AssertAll; Or AssertExeptions:None or such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why.
This was done because some tests are expected to fail. I just pushed the new commits that disable controller testing for these tests.
Thank you LGTM. |
Continuation of #2920 (great work by @Be-ing!) with merge conflicts resolved.
It also adds the comment to make @daschuer happy and moves the C++ style wrapping into the ControllerScriptEngineLegacy class. For the new API, we should just hand out the dataview and do the cast to Uint8Arry in actual JavaScript if necessary, not in an JavaScript-wrapped-in-C++-and-called-by-JavaScript abomination.