Crate vcs_classic_hid[−][src]
VCS Classic Joystick HID library.
This crate uses hidapi
for finding and using Atari VCS classic joysticks.
With this crate, an assortment of facilities are provided for reading the current state of the device and, more importantly, send force feedback and LED manipulation messages.
Finding a device
The functions open, open_serial, and open_all
are helper functions for opening devices for access to a classic controller
via hidapi
.
The result provides an HidDevice
.
let device = vcs_classic_hid::open()?;
Using the device
Raw access to the HID device can still be done
through the interface provided,
but a set of facilities are provided through
the implemented Device
trait
and additional functions and data types.
Receiving input state
A State value represents a possible input state
of the classic controller,
and can be created from a device report via
State::from_report
.
However, this is not very convenient, and may return stale input
The function process_input handles all input state events in queue
and returns a State
instance.
let mut device = vcs_classic_hid::open()?; match vcs_classic_hid::process_input(&mut device)? { Some(state) => { // use state let _fuji_button_down = state.button_fuji; } None => { // no user input } }
Changing LED state
Both the light on the Fuji button and the ring of 24 LEDs
can be manipulated programmatically.
To set an exact state of the LEDs,
create an LedReport
and send it to the device.
For example, to light up all LEDs in the controller’s ring to the maximum:
use vcs_classic_hid::Device; let led = vcs_classic_hid::LedReport::filled(0xFF); Device::write(&mut device, led)?;
To cancel LED manipulation and let the controller itself manipulate them
based on user input
(which is the default behavior), use reset_leds
:
use vcs_classic_hid::Device; device.reset_leds()?;
Re-exports
pub use hidapi; |
pub use force_feedback::FfReport; |
pub use led::LedReport; |
pub use input::State; |
pub use input::StickPosition; |
pub use input::process_input; |
Modules
force_feedback | Force feedback module |
input | Controller input handling module |
led | LED manipulation module |
Traits
Device | Generic interface for human interaction devices. |
Functions
open | Inspect the list of devices available and open the first VCS classic controller device found. |
open_all | Find and open all classic controller devices available into a list. |
open_path | Inspect the list of devices available and open a classic controller device by path. |
open_serial | and open a classic controller device by path. |