mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 12:30:12 +02:00
Implement IPlugView onKey{Up,Down}
This commit is contained in:
@@ -273,6 +273,30 @@ bool Vst3Logger::log_request(bool is_host_vst,
|
||||
});
|
||||
}
|
||||
|
||||
bool Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPlugView::OnKeyDown& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
// This static cast is technically not correct of course but it's
|
||||
// UTF-16, so everything's allowed
|
||||
message << request.owner_instance_id << ": IPlugView::onKeyDown(key = "
|
||||
<< static_cast<char>(request.key)
|
||||
<< ", keyCode = " << request.key_code
|
||||
<< ", modifiers = " << request.modifiers << ")";
|
||||
});
|
||||
}
|
||||
|
||||
bool Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPlugView::OnKeyUp& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
// This static cast is technically not correct of course but it's
|
||||
// UTF-16, so everything's allowed
|
||||
message << request.owner_instance_id << ": IPlugView::onKeyUp(key = "
|
||||
<< static_cast<char>(request.key)
|
||||
<< ", keyCode = " << request.key_code
|
||||
<< ", modifiers = " << request.modifiers << ")";
|
||||
});
|
||||
}
|
||||
|
||||
bool Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaPlugView::GetSize& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
|
||||
@@ -92,6 +92,8 @@ class Vst3Logger {
|
||||
bool log_request(bool is_host_vst, const YaPlugView::Attached&);
|
||||
bool log_request(bool is_host_vst, const YaPlugView::Removed&);
|
||||
bool log_request(bool is_host_vst, const YaPlugView::OnWheel&);
|
||||
bool log_request(bool is_host_vst, const YaPlugView::OnKeyDown&);
|
||||
bool log_request(bool is_host_vst, const YaPlugView::OnKeyUp&);
|
||||
bool log_request(bool is_host_vst, const YaPlugView::GetSize&);
|
||||
bool log_request(bool is_host_vst, const YaPluginBase::Initialize&);
|
||||
bool log_request(bool is_host_vst, const YaPluginBase::Terminate&);
|
||||
|
||||
@@ -81,6 +81,8 @@ using ControlRequest = std::variant<Vst3PlugViewProxy::Destruct,
|
||||
YaPlugView::Attached,
|
||||
YaPlugView::Removed,
|
||||
YaPlugView::OnWheel,
|
||||
YaPlugView::OnKeyDown,
|
||||
YaPlugView::OnKeyUp,
|
||||
YaPlugView::GetSize,
|
||||
YaPluginBase::Initialize,
|
||||
YaPluginBase::Terminate,
|
||||
|
||||
@@ -149,9 +149,55 @@ class YaPlugView : public Steinberg::IPlugView {
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API onWheel(float distance) override = 0;
|
||||
|
||||
/**
|
||||
* Message to pass through a call to `IPlugView::onKeyDown(key, keyCode,
|
||||
* modifiers)` to the Wine plugin host.
|
||||
*/
|
||||
struct OnKeyDown {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t owner_instance_id;
|
||||
|
||||
char16 key;
|
||||
int16 key_code;
|
||||
int16 modifiers;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(owner_instance_id);
|
||||
s.value2b(key);
|
||||
s.value2b(key_code);
|
||||
s.value2b(modifiers);
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API onKeyDown(char16 key,
|
||||
int16 keyCode,
|
||||
int16 modifiers) override = 0;
|
||||
|
||||
/**
|
||||
* Message to pass through a call to `IPlugView::onKeyUp(key, keyCode,
|
||||
* modifiers)` to the Wine plugin host.
|
||||
*/
|
||||
struct OnKeyUp {
|
||||
using Response = UniversalTResult;
|
||||
|
||||
native_size_t owner_instance_id;
|
||||
|
||||
char16 key;
|
||||
int16 key_code;
|
||||
int16 modifiers;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(owner_instance_id);
|
||||
s.value2b(key);
|
||||
s.value2b(key_code);
|
||||
s.value2b(modifiers);
|
||||
}
|
||||
};
|
||||
|
||||
virtual tresult PLUGIN_API onKeyUp(char16 key,
|
||||
int16 keyCode,
|
||||
int16 modifiers) override = 0;
|
||||
|
||||
@@ -71,17 +71,21 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::onWheel(float distance) {
|
||||
tresult PLUGIN_API Vst3PlugViewProxyImpl::onKeyDown(char16 key,
|
||||
int16 keyCode,
|
||||
int16 modifiers) {
|
||||
// TODO: Implement
|
||||
bridge.logger.log("TODO: IPlugView::onKeyDown()");
|
||||
return Steinberg::kNotImplemented;
|
||||
return bridge.send_message(
|
||||
YaPlugView::OnKeyDown{.owner_instance_id = owner_instance_id(),
|
||||
.key = key,
|
||||
.key_code = keyCode,
|
||||
.modifiers = modifiers});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API Vst3PlugViewProxyImpl::onKeyUp(char16 key,
|
||||
int16 keyCode,
|
||||
int16 modifiers) {
|
||||
// TODO: Implement
|
||||
bridge.logger.log("TODO: IPlugView::onKeyUp()");
|
||||
return Steinberg::kNotImplemented;
|
||||
return bridge.send_message(
|
||||
YaPlugView::OnKeyUp{.owner_instance_id = owner_instance_id(),
|
||||
.key = key,
|
||||
.key_code = keyCode,
|
||||
.modifiers = modifiers});
|
||||
}
|
||||
|
||||
tresult PLUGIN_API Vst3PlugViewProxyImpl::getSize(Steinberg::ViewRect* size) {
|
||||
|
||||
@@ -375,6 +375,18 @@ void Vst3Bridge::run() {
|
||||
return object_instances[request.owner_instance_id]
|
||||
.plug_view->onWheel(request.distance);
|
||||
},
|
||||
[&](const YaPlugView::OnKeyDown& request)
|
||||
-> YaPlugView::OnKeyDown::Response {
|
||||
return object_instances[request.owner_instance_id]
|
||||
.plug_view->onKeyDown(request.key, request.key_code,
|
||||
request.modifiers);
|
||||
},
|
||||
[&](const YaPlugView::OnKeyUp& request)
|
||||
-> YaPlugView::OnKeyUp::Response {
|
||||
return object_instances[request.owner_instance_id]
|
||||
.plug_view->onKeyUp(request.key, request.key_code,
|
||||
request.modifiers);
|
||||
},
|
||||
[&](YaPlugView::GetSize& request) -> YaPlugView::GetSize::Response {
|
||||
const tresult result =
|
||||
object_instances[request.owner_instance_id]
|
||||
|
||||
Reference in New Issue
Block a user