1pub mod api;
2pub mod api_commands;
3pub mod error;
4pub mod keycodes;
5pub mod scan;
6pub mod utils;
7
8#[cfg(feature = "python")]
9use pyo3::create_exception;
10#[cfg(feature = "python")]
11use pyo3::exceptions::PyException;
12#[cfg(feature = "python")]
13use pyo3::prelude::*;
14
15pub use error::*;
16
17#[cfg(feature = "python")]
18create_exception!(qmk_via_api, QmkViaError, PyException);
19#[cfg(feature = "python")]
20create_exception!(qmk_via_api, HidError, QmkViaError);
21#[cfg(feature = "python")]
22create_exception!(qmk_via_api, DeviceNotFoundError, QmkViaError);
23#[cfg(feature = "python")]
24create_exception!(qmk_via_api, UnsupportedProtocolError, QmkViaError);
25#[cfg(feature = "python")]
26create_exception!(qmk_via_api, SizeMismatchError, QmkViaError);
27#[cfg(feature = "python")]
28create_exception!(qmk_via_api, CommandResponseError, QmkViaError);
29#[cfg(feature = "python")]
30create_exception!(qmk_via_api, InvalidArgumentError, QmkViaError);
31
32#[cfg(feature = "python")]
33#[pymodule]
34fn qmk_via_api(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
35 m.add_class::<api::KeyboardApi>()?;
36 m.add_class::<api_commands::ViaCommandId>()?;
37 m.add_class::<api::MatrixInfo>()?;
38 m.add_class::<scan::KeyboardDeviceInfo>()?;
39 m.add("QmkViaError", _py.get_type::<QmkViaError>())?;
40 m.add("HidError", _py.get_type::<HidError>())?;
41 m.add("DeviceNotFoundError", _py.get_type::<DeviceNotFoundError>())?;
42 m.add(
43 "UnsupportedProtocolError",
44 _py.get_type::<UnsupportedProtocolError>(),
45 )?;
46 m.add("SizeMismatchError", _py.get_type::<SizeMismatchError>())?;
47 m.add(
48 "CommandResponseError",
49 _py.get_type::<CommandResponseError>(),
50 )?;
51 m.add(
52 "InvalidArgumentError",
53 _py.get_type::<InvalidArgumentError>(),
54 )?;
55 m.add_function(wrap_pyfunction!(scan::scan_keyboards, m)?)?;
56 Ok(())
57}