We provide a C, C++, Python, .NET, Node.js and Rust interface to the adapter.
The .NET, Node.js and Rust bindings are published to their language's registry
from 8.1.6 onwards — dotnet add package LibCecSharp, npm install libcec,
cargo add libcec. All three bind the native library rather than carrying it,
so libCEC still has to be installed alongside them. The per-language sections
below cover building them from this tree instead.
- the API can be found in
include/cec.h - an example implementation can be found on https://github.com/Pulse-Eight/libcec/blob/master/src/cec-client/cec-client.cpp
- the API can be found in
include/cecc.h - an example implementation can be found on https://github.com/Pulse-Eight/libcec/blob/master/src/cecc-client/cecc-client.c
dotnet add package LibCecSharpis the usual way in. Alternatively add a reference toLibCecSharp.dll, installed toC:\Program Files (x86)\Pulse-Eight\USB-CEC Adapter\net8.0by default on Windows. On Debian thelibcec-dotnetpackage installs it to/usr/lib/libcec/LibCecSharp.dlland ships the same NuGet package under/usr/share/libcec-dotnetthat downstream projects canPackageReference.LibCecSharpis a single, pure-C# assembly (namespaceCecSharp) that binds libCEC through P/Invoke over the C API. It targets net8.0 and is architecture-neutral (the nativecec.dll/libcec.soit loads is the arch-specific part), so it runs on Windows, Linux, macOS and Raspberry Pi.- it replaces the previous C++/CLI wrappers (
LibCecSharpfor .NET Framework andLibCecSharpCorefor net8.0), which were Windows-only. Consumers keep the sameCecSharpAPI, so existing code compiles unchanged against net8.0. - WinForms/WPF apps target
net8.0-windows; console/service apps targetnet8.0. - an example implementation can be found on https://github.com/Pulse-Eight/cec-dotnet/blob/master/src/CecSharpTester/CecSharpClient.cs
- the API is exported to Python through Swig
- an example implementation can be found on https://github.com/Pulse-Eight/libcec/blob/master/src/pyCecClient/pyCecClient.py
- a native N-API addon in
src/nodejsbinds libCEC over the C API (include/cecc.h), the same surface the .NET binding uses. It exposes anEventEmitter-basedCecAdapterand works anywhere libCEC and a C++ toolchain do (Linux, macOS, Raspberry Pi, Windows). npm install libcecpulls it from npm. The package carries sources, so installing compiles the addon against the libCEC on the machine — one package covers every platform and every Node ≥ 16, because N-API is ABI-stable.- build it from this tree with
cd src/nodejs && npm install(runsnode-gyp, compiling against an installed libCEC found viapkg-config; on Debian that is thelibcec8-devpackage). - an example implementation can be found in src/nodejs/example/simple.js; see src/nodejs/README.md for the full API.
- the
libceccrate insrc/rustbinds libCEC over the C API (include/cecc.h), the same surface the .NET and Node.js bindings use. It has no dependencies of its own and works anywhere libCEC does. libcec::Connectionis the safe API;libcec::ffiis the raw C surface, complete and public, for anything the safe layer does not cover.cargo add libcecpulls it from crates.io.- build it from this tree with
cd src/rust && cargo build.pkg-configfinds an installed libCEC on Unix (on Debian, thelibcec8-devpackage); setLIBCEC_LIB_DIRto build against an uninstalled one, which is also how it findscec.libon Windows. - the crate's major version has to match libCEC's:
libcec_configurationgains fields on every major bump, andbuild.rsrefuses a mismatch rather than letting a wrong-sized struct through. - examples are in src/rust/examples —
simple.rsfor the shape of it,cec_client.rsfor an interactive console; see src/rust/README.md.
If you wish to contribute to this project, you must first sign our contributors agreement. Please see the contributors agreement for more information.