KeyboardApi

Struct KeyboardApi 

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

Implementations§

Source§

impl KeyboardApi

Source

pub fn py_new(vid: u16, pid: u16, usage_page: u16) -> Result<Self>

Source§

impl KeyboardApi

Source

pub fn new(vid: u16, pid: u16, usage_page: u16) -> Result<KeyboardApi>

Source§

impl KeyboardApi

Source

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

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

Source

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

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

Source

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

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

Source

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

Returns the protocol version of the keyboard.

Source

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

Returns the number of layers on the keyboard.

Source

pub fn get_key(&self, layer: Layer, row: Row, col: Column) -> Result<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, ) -> Result<u16>

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

Source

pub fn read_raw_matrix( &self, matrix_info: MatrixInfo, layer: Layer, ) -> Result<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>>, ) -> Result<()>

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, ) -> Result<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>, ) -> Result<()>

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, ) -> Result<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, ) -> Result<()>

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

Source

pub fn get_custom_menu_value(&self, command_bytes: Vec<u8>) -> Result<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>) -> Result<()>

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) -> Result<()>

Saves the custom menu values for the given channel id.

Source

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

Gets the backlight brightness.

Source

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

Sets the backlight brightness.

Source

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

Gets the backlight effect.

Source

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

Sets the backlight effect.

Source

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

Gets the RGB light brightness.

Source

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

Sets the RGB light brightness.

Source

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

Gets the RGB light effect.

Source

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

Sets the RGB light effect.

Source

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

Gets the RGB light effect speed.

Source

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

Sets the RGB light effect speed.

Source

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

Gets the RGB light color.

Source

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

Sets the RGB light color.

Source

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

Gets the RGB matrix brightness.

Source

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

Sets the RGB matrix brightness.

Source

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

Gets the RGB matrix effect.

Source

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

Sets the RGB matrix effect.

Source

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

Gets the RGB matrix effect speed.

Source

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

Sets the RGB matrix effect speed.

Source

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

Gets the RGB matrix color.

Source

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

Sets the RGB matrix color.

Source

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

Gets the LED matrix brightness.

Source

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

Sets the LED matrix brightness.

Source

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

Gets the LED matrix effect.

Source

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

Sets the LED matrix effect.

Source

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

Gets the LED matrix effect speed.

Source

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

Sets the LED matrix effect speed.

Source

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

Saves the lighting settings.

Source

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

Gets the audio enabled state.

Source

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

Sets the audio enabled state.

Source

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

Gets the audio clicky enabled state.

Source

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

Sets the audio clicky enabled state.

Source

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

Gets the macro count.

Source

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

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

Source

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

Sets the macro bytes.

Source

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

Resets all saved macros.

Source

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

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

Source

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

Jumps to the bootloader.

Trait Implementations§

Source§

impl<'py> IntoPyObject<'py> for KeyboardApi

Source§

type Target = KeyboardApi

The Python output type
Source§

type Output = Bound<'py, <KeyboardApi as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

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

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

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§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

const RAW_DOC: &'static CStr = c"\x00"

Docstring for the class provided on the struct or enum. Read more
Source§

const DOC: &'static CStr

Fully rendered class doc, including the text_signature if a constructor is defined. Read more
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = ThreadCheckerImpl

This handles following two situations: Read more
Source§

type Inventory = Pyo3MethodsInventoryForKeyboardApi

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 lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature for KeyboardApi

Source§

const TEXT_SIGNATURE: &'static str = "(vid, pid, usage_page)"

Source§

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

Source§

type Holder = Option<PyClassGuard<'a, KeyboardApi>>

Source§

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

Source§

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

Source§

type Holder = Option<PyClassGuardMut<'a, KeyboardApi>>

Source§

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

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<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn is_type_of(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: &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<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. 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,