Struct KeyboardApi

Source
pub struct KeyboardApi { /* private fields */ }

Implementations§

Source§

impl KeyboardApi

Source

pub fn new(vid: u16, pid: u16, usage_page: u16) -> PyResult<Self>

Source

pub fn hid_command( &self, command: ViaCommandId, bytes: Vec<u8>, ) -> Option<Vec<u8>>

Sends a raw HID command prefixed with the command byte and returns the response if successful.

Source

pub fn hid_read(&self) -> Option<Vec<u8>>

Reads from the HID device. Returns None if the read fails.

Source

pub fn hid_send(&self, bytes: Vec<u8>) -> Option<()>

Sends a raw HID command prefixed with the command byte. Returns None if the send fails.

Source

pub fn get_protocol_version(&self) -> Option<u16>

Returns the protocol version of the keyboard.

Source

pub fn get_layer_count(&self) -> Option<u8>

Returns the number of layers on the keyboard.

Source

pub fn get_key(&self, layer: Layer, row: Row, col: Column) -> Option<u16>

Returns the keycode at the given layer, row, and column.

Source

pub fn set_key( &self, layer: Layer, row: Row, column: Column, val: u16, ) -> Option<u16>

Sets the keycode at the given layer, row, and column.

Source

pub fn read_raw_matrix( &self, matrix_info: MatrixInfo, layer: Layer, ) -> Option<Vec<u16>>

Returns the keycodes for the given matrix info (number of rows and columns) and layer.

Source

pub fn write_raw_matrix( &self, matrix_info: MatrixInfo, keymap: Vec<Vec<u16>>, ) -> Option<()>

Writes a keymap to the keyboard for the given matrix info (number of rows and columns).

Source

pub fn get_keyboard_value( &self, command: KeyboardValue, parameters: Vec<u8>, result_length: usize, ) -> Option<Vec<u8>>

Returns a keyboard value. This can be used to retrieve keyboard information like uptime, layout options, switch matrix state and firmware version.

Source

pub fn set_keyboard_value( &self, command: KeyboardValue, parameters: Vec<u8>, ) -> Option<()>

Sets a keyboard value. This can be used to set keyboard values like layout options or device indication.

Source

pub fn get_encoder_value( &self, layer: Layer, id: u8, is_clockwise: bool, ) -> Option<u16>

Gets the encoder value for the given layer, id, and direction.

Source

pub fn set_encoder_value( &self, layer: Layer, id: u8, is_clockwise: bool, keycode: u16, ) -> Option<()>

Sets the encoder value for the given layer, id, direction, and keycode.

Source

pub fn get_custom_menu_value(&self, command_bytes: Vec<u8>) -> Option<Vec<u8>>

Get a custom menu value. This is a generic function that can be used to get any value specific to arbitrary keyboard functionalities.

Source

pub fn set_custom_menu_value(&self, args: Vec<u8>) -> Option<()>

Set a custom menu value. This is a generic function that can be used to set any value specific to arbitrary keyboard functionalities.

Source

pub fn save_custom_menu(&self, channel: u8) -> Option<()>

Saves the custom menu values for the given channel id.

Source

pub fn get_backlight_brightness(&self) -> Option<u8>

Gets the backlight brightness.

Source

pub fn set_backlight_brightness(&self, brightness: u8) -> Option<()>

Sets the backlight brightness.

Source

pub fn get_backlight_effect(&self) -> Option<u8>

Gets the backlight effect.

Source

pub fn set_backlight_effect(&self, effect: u8) -> Option<()>

Sets the backlight effect.

Source

pub fn get_rgblight_brightness(&self) -> Option<u8>

Gets the RGB light brightness.

Source

pub fn set_rgblight_brightness(&self, brightness: u8) -> Option<()>

Sets the RGB light brightness.

Source

pub fn get_rgblight_effect(&self) -> Option<u8>

Gets the RGB light effect.

Source

pub fn set_rgblight_effect(&self, effect: u8) -> Option<()>

Sets the RGB light effect.

Source

pub fn get_rgblight_effect_speed(&self) -> Option<u8>

Gets the RGB light effect speed.

Source

pub fn set_rgblight_effect_speed(&self, speed: u8) -> Option<()>

Sets the RGB light effect speed.

Source

pub fn get_rgblight_color(&self) -> Option<(u8, u8)>

Gets the RGB light color.

Source

pub fn set_rgblight_color(&self, hue: u8, sat: u8) -> Option<()>

Sets the RGB light color.

Source

pub fn get_rgb_matrix_brightness(&self) -> Option<u8>

Gets the RGB matrix brightness.

Source

pub fn set_rgb_matrix_brightness(&self, brightness: u8) -> Option<()>

Sets the RGB matrix brightness.

Source

pub fn get_rgb_matrix_effect(&self) -> Option<u8>

Gets the RGB matrix effect.

Source

pub fn set_rgb_matrix_effect(&self, effect: u8) -> Option<()>

Sets the RGB matrix effect.

Source

pub fn get_rgb_matrix_effect_speed(&self) -> Option<u8>

Gets the RGB matrix effect speed.

Source

pub fn set_rgb_matrix_effect_speed(&self, speed: u8) -> Option<()>

Sets the RGB matrix effect speed.

Source

pub fn get_rgb_matrix_color(&self) -> Option<(u8, u8)>

Gets the RGB matrix color.

Source

pub fn set_rgb_matrix_color(&self, hue: u8, sat: u8) -> Option<()>

Sets the RGB matrix color.

Source

pub fn get_led_matrix_brightness(&self) -> Option<u8>

Gets the LED matrix brightness.

Source

pub fn set_led_matrix_brightness(&self, brightness: u8) -> Option<()>

Sets the LED matrix brightness.

Source

pub fn get_led_matrix_effect(&self) -> Option<u8>

Gets the LED matrix effect.

Source

pub fn set_led_matrix_effect(&self, effect: u8) -> Option<()>

Sets the LED matrix effect.

Source

pub fn get_led_matrix_effect_speed(&self) -> Option<u8>

Gets the LED matrix effect speed.

Source

pub fn set_led_matrix_effect_speed(&self, speed: u8) -> Option<()>

Sets the LED matrix effect speed.

Source

pub fn save_lighting(&self) -> Option<()>

Saves the lighting settings.

Source

pub fn get_audio_enabled(&self) -> Option<bool>

Gets the audio enabled state.

Source

pub fn set_audio_enabled(&self, enabled: bool) -> Option<()>

Sets the audio enabled state.

Source

pub fn get_audio_clicky_enabled(&self) -> Option<bool>

Gets the audio clicky enabled state.

Source

pub fn set_audio_clicky_enabled(&self, enabled: bool) -> Option<()>

Sets the audio clicky enabled state.

Source

pub fn get_macro_count(&self) -> Option<u8>

Gets the macro count.

Source

pub fn get_macro_bytes(&self) -> Option<Vec<u8>>

Gets the macro bytes. All macros are separated by 0x00.

Source

pub fn set_macro_bytes(&self, data: Vec<u8>) -> Option<()>

Sets the macro bytes.

Source

pub fn reset_macros(&self) -> Option<()>

Resets all saved macros.

Source

pub fn reset_eeprom(&self) -> Option<()>

Resets the EEPROM, clearing all settings like keymaps and macros.

Source

pub fn jump_to_bootloader(&self) -> Option<()>

Jumps to the bootloader.

Trait Implementations§

Source§

impl HasPyGilRef for KeyboardApi

Source§

type AsRefTarget = PyCell<KeyboardApi>

Utility type to make Py::as_ref work.
Source§

impl IntoPy<Py<PyAny>> for KeyboardApi

Source§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
Source§

impl PyClass for KeyboardApi

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for KeyboardApi

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<KeyboardApi>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature<KeyboardApi> for PyClassImplCollector<KeyboardApi>

Source§

fn new_text_signature(self) -> Option<&'static str>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a KeyboardApi

Source§

type Holder = Option<PyRef<'py, KeyboardApi>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut KeyboardApi

Source§

type Holder = Option<PyRefMut<'py, KeyboardApi>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<KeyboardApi> for PyClassImplCollector<KeyboardApi>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for KeyboardApi

Source§

const NAME: &'static str = "KeyboardApi"

Class name.
Source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
Source§

fn type_object(py: Python<'_>) -> &PyType

👎Deprecated since 0.21.0: PyTypeInfo::type_object will be replaced by PyTypeInfo::type_object_bound in a future PyO3 version
Returns the safe abstraction over the type object.
Source§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn is_type_of(object: &PyAny) -> bool

👎Deprecated since 0.21.0: PyTypeInfo::is_type_of will be replaced by PyTypeInfo::is_type_of_bound in a future PyO3 version
Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_exact_type_of(object: &PyAny) -> bool

👎Deprecated since 0.21.0: PyTypeInfo::is_exact_type_of will be replaced by PyTypeInfo::is_exact_type_of_bound in a future PyO3 version
Checks if object is an instance of this type.
Source§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl DerefToPyAny for KeyboardApi

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

Source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
Source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Ungil for T
where T: Send,