pub struct KeyboardApi { /* private fields */ }
Implementations§
Source§impl KeyboardApi
impl KeyboardApi
pub fn new(vid: u16, pid: u16, usage_page: u16) -> PyResult<Self>
Sourcepub fn hid_command(
&self,
command: ViaCommandId,
bytes: Vec<u8>,
) -> Option<Vec<u8>>
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.
Sourcepub fn hid_read(&self) -> Option<Vec<u8>>
pub fn hid_read(&self) -> Option<Vec<u8>>
Reads from the HID device. Returns None if the read fails.
Sourcepub fn hid_send(&self, bytes: Vec<u8>) -> Option<()>
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.
Sourcepub fn get_protocol_version(&self) -> Option<u16>
pub fn get_protocol_version(&self) -> Option<u16>
Returns the protocol version of the keyboard.
Sourcepub fn get_layer_count(&self) -> Option<u8>
pub fn get_layer_count(&self) -> Option<u8>
Returns the number of layers on the keyboard.
Sourcepub fn get_key(&self, layer: Layer, row: Row, col: Column) -> Option<u16>
pub fn get_key(&self, layer: Layer, row: Row, col: Column) -> Option<u16>
Returns the keycode at the given layer, row, and column.
Sourcepub fn set_key(
&self,
layer: Layer,
row: Row,
column: Column,
val: u16,
) -> Option<u16>
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.
Sourcepub fn read_raw_matrix(
&self,
matrix_info: MatrixInfo,
layer: Layer,
) -> Option<Vec<u16>>
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.
Sourcepub fn write_raw_matrix(
&self,
matrix_info: MatrixInfo,
keymap: Vec<Vec<u16>>,
) -> Option<()>
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).
Sourcepub fn get_keyboard_value(
&self,
command: KeyboardValue,
parameters: Vec<u8>,
result_length: usize,
) -> Option<Vec<u8>>
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.
Sourcepub fn set_keyboard_value(
&self,
command: KeyboardValue,
parameters: Vec<u8>,
) -> Option<()>
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.
Sourcepub fn get_encoder_value(
&self,
layer: Layer,
id: u8,
is_clockwise: bool,
) -> Option<u16>
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.
Sourcepub fn set_encoder_value(
&self,
layer: Layer,
id: u8,
is_clockwise: bool,
keycode: u16,
) -> Option<()>
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.
Get a custom menu value. This is a generic function that can be used to get any value specific to arbitrary keyboard functionalities.
Set a custom menu value. This is a generic function that can be used to set any value specific to arbitrary keyboard functionalities.
Saves the custom menu values for the given channel id.
Sourcepub fn get_backlight_brightness(&self) -> Option<u8>
pub fn get_backlight_brightness(&self) -> Option<u8>
Gets the backlight brightness.
Sourcepub fn set_backlight_brightness(&self, brightness: u8) -> Option<()>
pub fn set_backlight_brightness(&self, brightness: u8) -> Option<()>
Sets the backlight brightness.
Sourcepub fn get_backlight_effect(&self) -> Option<u8>
pub fn get_backlight_effect(&self) -> Option<u8>
Gets the backlight effect.
Sourcepub fn set_backlight_effect(&self, effect: u8) -> Option<()>
pub fn set_backlight_effect(&self, effect: u8) -> Option<()>
Sets the backlight effect.
Sourcepub fn get_rgblight_brightness(&self) -> Option<u8>
pub fn get_rgblight_brightness(&self) -> Option<u8>
Gets the RGB light brightness.
Sourcepub fn set_rgblight_brightness(&self, brightness: u8) -> Option<()>
pub fn set_rgblight_brightness(&self, brightness: u8) -> Option<()>
Sets the RGB light brightness.
Sourcepub fn get_rgblight_effect(&self) -> Option<u8>
pub fn get_rgblight_effect(&self) -> Option<u8>
Gets the RGB light effect.
Sourcepub fn set_rgblight_effect(&self, effect: u8) -> Option<()>
pub fn set_rgblight_effect(&self, effect: u8) -> Option<()>
Sets the RGB light effect.
Sourcepub fn get_rgblight_effect_speed(&self) -> Option<u8>
pub fn get_rgblight_effect_speed(&self) -> Option<u8>
Gets the RGB light effect speed.
Sourcepub fn set_rgblight_effect_speed(&self, speed: u8) -> Option<()>
pub fn set_rgblight_effect_speed(&self, speed: u8) -> Option<()>
Sets the RGB light effect speed.
Sourcepub fn get_rgblight_color(&self) -> Option<(u8, u8)>
pub fn get_rgblight_color(&self) -> Option<(u8, u8)>
Gets the RGB light color.
Sourcepub fn get_rgb_matrix_brightness(&self) -> Option<u8>
pub fn get_rgb_matrix_brightness(&self) -> Option<u8>
Gets the RGB matrix brightness.
Sourcepub fn set_rgb_matrix_brightness(&self, brightness: u8) -> Option<()>
pub fn set_rgb_matrix_brightness(&self, brightness: u8) -> Option<()>
Sets the RGB matrix brightness.
Sourcepub fn get_rgb_matrix_effect(&self) -> Option<u8>
pub fn get_rgb_matrix_effect(&self) -> Option<u8>
Gets the RGB matrix effect.
Sourcepub fn set_rgb_matrix_effect(&self, effect: u8) -> Option<()>
pub fn set_rgb_matrix_effect(&self, effect: u8) -> Option<()>
Sets the RGB matrix effect.
Sourcepub fn get_rgb_matrix_effect_speed(&self) -> Option<u8>
pub fn get_rgb_matrix_effect_speed(&self) -> Option<u8>
Gets the RGB matrix effect speed.
Sourcepub fn set_rgb_matrix_effect_speed(&self, speed: u8) -> Option<()>
pub fn set_rgb_matrix_effect_speed(&self, speed: u8) -> Option<()>
Sets the RGB matrix effect speed.
Sourcepub fn get_rgb_matrix_color(&self) -> Option<(u8, u8)>
pub fn get_rgb_matrix_color(&self) -> Option<(u8, u8)>
Gets the RGB matrix color.
Sourcepub fn get_led_matrix_brightness(&self) -> Option<u8>
pub fn get_led_matrix_brightness(&self) -> Option<u8>
Gets the LED matrix brightness.
Sourcepub fn set_led_matrix_brightness(&self, brightness: u8) -> Option<()>
pub fn set_led_matrix_brightness(&self, brightness: u8) -> Option<()>
Sets the LED matrix brightness.
Sourcepub fn get_led_matrix_effect(&self) -> Option<u8>
pub fn get_led_matrix_effect(&self) -> Option<u8>
Gets the LED matrix effect.
Sourcepub fn set_led_matrix_effect(&self, effect: u8) -> Option<()>
pub fn set_led_matrix_effect(&self, effect: u8) -> Option<()>
Sets the LED matrix effect.
Sourcepub fn get_led_matrix_effect_speed(&self) -> Option<u8>
pub fn get_led_matrix_effect_speed(&self) -> Option<u8>
Gets the LED matrix effect speed.
Sourcepub fn set_led_matrix_effect_speed(&self, speed: u8) -> Option<()>
pub fn set_led_matrix_effect_speed(&self, speed: u8) -> Option<()>
Sets the LED matrix effect speed.
Sourcepub fn save_lighting(&self) -> Option<()>
pub fn save_lighting(&self) -> Option<()>
Saves the lighting settings.
Sourcepub fn get_audio_enabled(&self) -> Option<bool>
pub fn get_audio_enabled(&self) -> Option<bool>
Gets the audio enabled state.
Sourcepub fn set_audio_enabled(&self, enabled: bool) -> Option<()>
pub fn set_audio_enabled(&self, enabled: bool) -> Option<()>
Sets the audio enabled state.
Sourcepub fn get_audio_clicky_enabled(&self) -> Option<bool>
pub fn get_audio_clicky_enabled(&self) -> Option<bool>
Gets the audio clicky enabled state.
Sourcepub fn set_audio_clicky_enabled(&self, enabled: bool) -> Option<()>
pub fn set_audio_clicky_enabled(&self, enabled: bool) -> Option<()>
Sets the audio clicky enabled state.
Sourcepub fn get_macro_count(&self) -> Option<u8>
pub fn get_macro_count(&self) -> Option<u8>
Gets the macro count.
Sourcepub fn get_macro_bytes(&self) -> Option<Vec<u8>>
pub fn get_macro_bytes(&self) -> Option<Vec<u8>>
Gets the macro bytes. All macros are separated by 0x00.
Sourcepub fn reset_macros(&self) -> Option<()>
pub fn reset_macros(&self) -> Option<()>
Resets all saved macros.
Sourcepub fn reset_eeprom(&self) -> Option<()>
pub fn reset_eeprom(&self) -> Option<()>
Resets the EEPROM, clearing all settings like keymaps and macros.
Sourcepub fn jump_to_bootloader(&self) -> Option<()>
pub fn jump_to_bootloader(&self) -> Option<()>
Jumps to the bootloader.
Trait Implementations§
Source§impl HasPyGilRef for KeyboardApi
impl HasPyGilRef for KeyboardApi
Source§type AsRefTarget = PyCell<KeyboardApi>
type AsRefTarget = PyCell<KeyboardApi>
Source§impl PyClass for KeyboardApi
impl PyClass for KeyboardApi
Source§impl PyClassImpl for KeyboardApi
impl PyClassImpl for KeyboardApi
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<KeyboardApi>
type ThreadChecker = SendablePyClass<KeyboardApi>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<KeyboardApi> for PyClassImplCollector<KeyboardApi>
impl PyClassNewTextSignature<KeyboardApi> for PyClassImplCollector<KeyboardApi>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a KeyboardApi
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a KeyboardApi
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut KeyboardApi
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut KeyboardApi
Source§impl PyMethods<KeyboardApi> for PyClassImplCollector<KeyboardApi>
impl PyMethods<KeyboardApi> for PyClassImplCollector<KeyboardApi>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for KeyboardApi
impl PyTypeInfo for KeyboardApi
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
PyTypeInfo::type_object
will be replaced by PyTypeInfo::type_object_bound
in a future PyO3 versionSource§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
Source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
PyTypeInfo::is_type_of
will be replaced by PyTypeInfo::is_type_of_bound
in a future PyO3 versionobject
is an instance of this type or a subclass of this type.Source§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.Source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
PyTypeInfo::is_exact_type_of
will be replaced by PyTypeInfo::is_exact_type_of_bound
in a future PyO3 versionobject
is an instance of this type.impl DerefToPyAny for KeyboardApi
Auto Trait Implementations§
impl Freeze for KeyboardApi
impl !RefUnwindSafe for KeyboardApi
impl Send for KeyboardApi
impl !Sync for KeyboardApi
impl Unpin for KeyboardApi
impl !UnwindSafe for KeyboardApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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