Add the digital interface, running MMTTY under Wine

MMTTY and 2Tone have no socket or pipe interface: N1MM hosts XMMT.ocx and
exchanges window messages with the engine. A Linux process cannot load that
control, so bridge/nonemm-mmtty-bridge.exe hosts it under Wine and passes
lines over its standard input and output. docs/digital-bridge.md states the
protocol and what the control needs.

The window is N1MM's: receive pane with coloured callsigns, grab list, call
stacking, twenty-four macro buttons and the engine controls. One left click
copies what is under it — a callsign to the callsign box, anything else to the
exchange box the contest keeps for that kind of value.

Config > Digital registers XMMT.ocx in the Wine prefix on its own, making the
prefix first if it is not there. The engine, the bridge and the control start
at the copies shipped beside the program.

The bridge reads the control's own events. OnTranslateMessage carries only the
messages the control has no event for, so nothing was ever decoded through it.

hamlib's data mode names read as digital modes now, and a mode typed into the
callsign box changes mode the way a frequency changes band, so a station with
no radio can reach RTTY at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
2026-08-31 21:35:45 +00:00
parent 76b57cee1d
commit c8de74e24a
70 changed files with 4560 additions and 27 deletions

123
bridge/EventSink.cpp Normal file
View File

@@ -0,0 +1,123 @@
#include "EventSink.h"
namespace {
// Turns a dispid into the event name the type library gives it, so the caller
// works in names rather than in numbers the OCX is free to renumber.
class EventSink : public IDispatch {
public:
EventSink(ITypeInfo* events, SinkHandler handler)
: events_(events), handler_(std::move(handler)) {
if (events_ != nullptr) {
events_->AddRef();
}
}
virtual ~EventSink() {
if (events_ != nullptr) {
events_->Release();
}
}
STDMETHODIMP QueryInterface(REFIID iid, void** out) override {
if (iid == IID_IUnknown || iid == IID_IDispatch || iid == source_) {
*out = static_cast<IDispatch*>(this);
AddRef();
return S_OK;
}
*out = nullptr;
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) AddRef() override { return ++references_; }
STDMETHODIMP_(ULONG) Release() override {
ULONG left = --references_;
if (left == 0) {
delete this;
}
return left;
}
STDMETHODIMP GetTypeInfoCount(UINT* count) override {
*count = 0;
return S_OK;
}
STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo**) override { return E_NOTIMPL; }
STDMETHODIMP GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*) override {
return E_NOTIMPL;
}
STDMETHODIMP Invoke(DISPID dispid, REFIID, LCID, WORD, DISPPARAMS* arguments, VARIANT*,
EXCEPINFO*, UINT*) override {
handler_(nameOf(dispid), arguments);
return S_OK;
}
void setSource(REFIID source) { source_ = source; }
private:
std::wstring nameOf(DISPID dispid) {
BSTR name = nullptr;
if (events_ == nullptr ||
FAILED(events_->GetDocumentation(dispid, &name, nullptr, nullptr, nullptr))) {
return L"";
}
std::wstring found(name, SysStringLen(name));
SysFreeString(name);
return found;
}
ITypeInfo* events_;
SinkHandler handler_;
IID source_ = IID_NULL;
ULONG references_ = 1;
};
} // namespace
ITypeInfo* sourceTypeInfo(IDispatch* control, IID* source) {
IProvideClassInfo2* provider = nullptr;
if (FAILED(control->QueryInterface(IID_IProvideClassInfo2,
reinterpret_cast<void**>(&provider)))) {
return nullptr;
}
ITypeInfo* events = nullptr;
if (SUCCEEDED(provider->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID, source))) {
ITypeInfo* coclass = nullptr;
if (SUCCEEDED(provider->GetClassInfo(&coclass))) {
TYPEATTR* attributes = nullptr;
if (SUCCEEDED(coclass->GetTypeAttr(&attributes))) {
for (UINT i = 0; i < attributes->cImplTypes && events == nullptr; i++) {
HREFTYPE reference = 0;
ITypeInfo* implemented = nullptr;
if (FAILED(coclass->GetRefTypeOfImplType(i, &reference)) ||
FAILED(coclass->GetRefTypeInfo(reference, &implemented))) {
continue;
}
TYPEATTR* theirs = nullptr;
if (SUCCEEDED(implemented->GetTypeAttr(&theirs))) {
if (theirs->guid == *source) {
events = implemented;
implemented->AddRef();
}
implemented->ReleaseTypeAttr(theirs);
}
implemented->Release();
}
coclass->ReleaseTypeAttr(attributes);
}
coclass->Release();
}
}
provider->Release();
return events;
}
IDispatch* createEventSink(ITypeInfo* events, REFIID source, SinkHandler handler) {
EventSink* sink = new EventSink(events, std::move(handler));
sink->setSource(source);
return sink;
}