add a function to initialize output LED buffer
This commit is contained in:
parent
98e6f5cf76
commit
c6f3fb529b
@ -22,12 +22,14 @@ pub const OUTPUT_MEMORY_SIZE: usize = 1;
|
|||||||
///
|
///
|
||||||
/// Both bit masks are active-high.
|
/// Both bit masks are active-high.
|
||||||
#[cfg(any(chuni, amdaemon))]
|
#[cfg(any(chuni, amdaemon))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn jvs_poll(_input: &[u8]) -> (u8, u8) {
|
pub fn jvs_poll(_input: &[u8]) -> (u8, u8) {
|
||||||
(0, 0)
|
(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks the current state of the coin button (if there is one).
|
/// Checks the current state of the coin button (if there is one).
|
||||||
#[cfg(any(chuni, amdaemon))]
|
#[cfg(any(chuni, amdaemon))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn is_coin_button_pressed(_input: &[u8]) -> bool {
|
pub fn is_coin_button_pressed(_input: &[u8]) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -51,13 +53,23 @@ pub fn is_coin_button_pressed(_input: &[u8]) -> bool {
|
|||||||
/// ----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|
/// ----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn read_pressure_data(_input: &[u8]) -> [u8; 32] {
|
pub fn read_pressure_data(_input: &[u8]) -> [u8; 32] {
|
||||||
[0u8; 32]
|
[0u8; 32]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Do some one-time initialization to the USB out buffer
|
||||||
|
/// (e.g. set magic bytes).
|
||||||
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn init_output_buffer(_output: &mut [u8]) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Update the RGB lighting on the slider. A slice `rgb` is provided, alternating
|
/// Update the RGB lighting on the slider. A slice `rgb` is provided, alternating
|
||||||
/// between 16 touch pad pixels and 15 divider pixels, going from right to left.
|
/// between 16 touch pad pixels and 15 divider pixels, going from right to left.
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn set_slider_leds<T: UsbContext>(
|
pub fn set_slider_leds<T: UsbContext>(
|
||||||
_device: &DeviceHandle<T>,
|
_device: &DeviceHandle<T>,
|
||||||
_output: &mut [u8],
|
_output: &mut [u8],
|
||||||
@ -77,6 +89,7 @@ pub fn set_slider_leds<T: UsbContext>(
|
|||||||
/// Note that billboard strips have alternating direction (bottom to top, top
|
/// Note that billboard strips have alternating direction (bottom to top, top
|
||||||
/// to bottom...)
|
/// to bottom...)
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn set_led_colors<T: UsbContext>(
|
pub fn set_led_colors<T: UsbContext>(
|
||||||
_device: &DeviceHandle<T>,
|
_device: &DeviceHandle<T>,
|
||||||
_output: &mut [u8],
|
_output: &mut [u8],
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
//! - Content length: 240 bytes
|
//! - Content length: 240 bytes
|
||||||
//! - Bytes 0..3: magic bytes [0x42, 0x4C, 0x00]
|
//! - Bytes 0..3: magic bytes [0x42, 0x4C, 0x00]
|
||||||
//! - Bytes 3..96: Slider LED (GRB order, right -> left)
|
//! - Bytes 3..96: Slider LED (GRB order, right -> left)
|
||||||
//! - Bytes 96..240: Nothing.
|
//! - Bytes 96..168: Left tower LED (GRB)
|
||||||
|
//! - Bytes 168..240: Right tower LED (GRB)
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -100,6 +101,14 @@ pub fn read_pressure_data(input: &[u8]) -> [u8; 32] {
|
|||||||
pressure
|
pressure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn init_output_buffer(output: &mut [u8]) {
|
||||||
|
output[0] = 0x42;
|
||||||
|
output[1] = 0x4C;
|
||||||
|
output[2] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn set_slider_leds<T: UsbContext>(
|
pub fn set_slider_leds<T: UsbContext>(
|
||||||
@ -107,10 +116,6 @@ pub fn set_slider_leds<T: UsbContext>(
|
|||||||
output: &mut [u8],
|
output: &mut [u8],
|
||||||
rgb: &[u8],
|
rgb: &[u8],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
output[0] = 0x42;
|
|
||||||
output[1] = 0x4C;
|
|
||||||
output[2] = 0;
|
|
||||||
|
|
||||||
for (buf_chunk, state_chunk) in output[3..96].chunks_mut(3).take(31).zip(rgb.chunks(3)) {
|
for (buf_chunk, state_chunk) in output[3..96].chunks_mut(3).take(31).zip(rgb.chunks(3)) {
|
||||||
buf_chunk[0] = state_chunk[1];
|
buf_chunk[0] = state_chunk[1];
|
||||||
buf_chunk[1] = state_chunk[0];
|
buf_chunk[1] = state_chunk[0];
|
||||||
@ -134,10 +139,6 @@ pub fn set_led_colors<T: UsbContext>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
output[0] = 0x42;
|
|
||||||
output[1] = 0x4C;
|
|
||||||
output[2] = 0;
|
|
||||||
|
|
||||||
let air_rgb = if board == 0 { 0x96 } else { 0xB4 };
|
let air_rgb = if board == 0 { 0x96 } else { 0xB4 };
|
||||||
let output_start = if board == 0 { 96 } else { 168 };
|
let output_start = if board == 0 { 96 } else { 168 };
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
//! - Content length: 240 bytes
|
//! - Content length: 240 bytes
|
||||||
//! - Bytes 0..3: magic bytes [0x42, 0x4C, 0x00]
|
//! - Bytes 0..3: magic bytes [0x42, 0x4C, 0x00]
|
||||||
//! - Bytes 3..96: Slider LED (GRB order, right -> left)
|
//! - Bytes 3..96: Slider LED (GRB order, right -> left)
|
||||||
//! - Bytes 96..240: Nothing.
|
//! - Bytes 96..168: Left tower LED (GRB)
|
||||||
|
//! - Bytes 168..240: Right tower LED (GRB)
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -65,6 +66,14 @@ pub fn read_pressure_data(input: &[u8]) -> [u8; 32] {
|
|||||||
pressure
|
pressure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn init_output_buffer(output: &mut [u8]) {
|
||||||
|
output[0] = 0x42;
|
||||||
|
output[1] = 0x4C;
|
||||||
|
output[2] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn set_slider_leds<T: UsbContext>(
|
pub fn set_slider_leds<T: UsbContext>(
|
||||||
@ -72,10 +81,6 @@ pub fn set_slider_leds<T: UsbContext>(
|
|||||||
output: &mut [u8],
|
output: &mut [u8],
|
||||||
rgb: &[u8],
|
rgb: &[u8],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
output[0] = 0x42;
|
|
||||||
output[1] = 0x4C;
|
|
||||||
output[2] = 0;
|
|
||||||
|
|
||||||
for (buf_chunk, state_chunk) in output[3..96].chunks_mut(3).take(31).zip(rgb.chunks(3)) {
|
for (buf_chunk, state_chunk) in output[3..96].chunks_mut(3).take(31).zip(rgb.chunks(3)) {
|
||||||
buf_chunk[0] = state_chunk[1];
|
buf_chunk[0] = state_chunk[1];
|
||||||
buf_chunk[1] = state_chunk[0];
|
buf_chunk[1] = state_chunk[0];
|
||||||
@ -99,10 +104,6 @@ pub fn set_led_colors<T: UsbContext>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
output[0] = 0x42;
|
|
||||||
output[1] = 0x4C;
|
|
||||||
output[2] = 0;
|
|
||||||
|
|
||||||
let air_rgb = if board == 0 { 0x96 } else { 0xB4 };
|
let air_rgb = if board == 0 { 0x96 } else { 0xB4 };
|
||||||
let output_start = if board == 0 { 96 } else { 168 };
|
let output_start = if board == 0 { 96 } else { 168 };
|
||||||
|
|
||||||
|
@ -46,16 +46,19 @@ pub const INPUT_MEMORY_SIZE: usize = 45;
|
|||||||
pub const OUTPUT_MEMORY_SIZE: usize = 122;
|
pub const OUTPUT_MEMORY_SIZE: usize = 122;
|
||||||
|
|
||||||
#[cfg(any(chuni, amdaemon))]
|
#[cfg(any(chuni, amdaemon))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn jvs_poll(input: &[u8]) -> (u8, u8) {
|
pub fn jvs_poll(input: &[u8]) -> (u8, u8) {
|
||||||
(input[1] & 3, input[0])
|
(input[1] & 3, input[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(chuni, amdaemon))]
|
#[cfg(any(chuni, amdaemon))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn is_coin_button_pressed(input: &[u8]) -> bool {
|
pub fn is_coin_button_pressed(input: &[u8]) -> bool {
|
||||||
(input[1] & 4) != 0
|
(input[1] & 4) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn read_pressure_data(input: &[u8]) -> [u8; 32] {
|
pub fn read_pressure_data(input: &[u8]) -> [u8; 32] {
|
||||||
let mut pressure = [0u8; 32];
|
let mut pressure = [0u8; 32];
|
||||||
|
|
||||||
@ -67,14 +70,19 @@ pub fn read_pressure_data(input: &[u8]) -> [u8; 32] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn init_output_buffer(output: &mut [u8]) {
|
||||||
|
output[0] = 0;
|
||||||
|
output[61] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn set_slider_leds<T: UsbContext>(
|
pub fn set_slider_leds<T: UsbContext>(
|
||||||
device: &DeviceHandle<T>,
|
device: &DeviceHandle<T>,
|
||||||
output: &mut [u8],
|
output: &mut [u8],
|
||||||
rgb: &[u8],
|
rgb: &[u8],
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
output[0] = 0;
|
|
||||||
output[61] = 1;
|
|
||||||
|
|
||||||
for (buf_chunk, state_chunk) in output[1..61].chunks_mut(3).zip(rgb.chunks(3).take(20)) {
|
for (buf_chunk, state_chunk) in output[1..61].chunks_mut(3).zip(rgb.chunks(3).take(20)) {
|
||||||
buf_chunk[0] = state_chunk[0];
|
buf_chunk[0] = state_chunk[0];
|
||||||
buf_chunk[1] = state_chunk[1];
|
buf_chunk[1] = state_chunk[1];
|
||||||
@ -97,6 +105,7 @@ pub fn set_slider_leds<T: UsbContext>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(chuni, chusanapp))]
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
#[inline(always)]
|
||||||
pub fn set_led_colors<T: UsbContext>(
|
pub fn set_led_colors<T: UsbContext>(
|
||||||
device: &DeviceHandle<T>,
|
device: &DeviceHandle<T>,
|
||||||
output: &mut [u8],
|
output: &mut [u8],
|
||||||
@ -107,8 +116,6 @@ pub fn set_led_colors<T: UsbContext>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
output[61] = 1;
|
|
||||||
|
|
||||||
match board {
|
match board {
|
||||||
0 => {
|
0 => {
|
||||||
output[95] = rgb[150];
|
output[95] = rgb[150];
|
||||||
|
11
src/lib.rs
11
src/lib.rs
@ -296,6 +296,17 @@ pub unsafe extern "C" fn chuni_io_slider_set_leds(rgb: *const u8) {
|
|||||||
pub extern "C" fn chuni_io_slider_set_leds(_rgb: *const u8) {}
|
pub extern "C" fn chuni_io_slider_set_leds(_rgb: *const u8) {}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
#[cfg(any(chuni, chusanapp))]
|
||||||
|
pub extern "C" fn chuni_io_led_init() -> HRESULT {
|
||||||
|
let mut output = SLIDER_OUTPUT.write();
|
||||||
|
|
||||||
|
con_impl::init_output_buffer(output.as_mut_slice());
|
||||||
|
|
||||||
|
S_OK
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
#[cfg(amdaemon)]
|
||||||
pub extern "C" fn chuni_io_led_init() -> HRESULT {
|
pub extern "C" fn chuni_io_led_init() -> HRESULT {
|
||||||
S_OK
|
S_OK
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user