init files from local folder
init with all my previous files
This commit is contained in:
commit
82c36314d1
23 changed files with 1023 additions and 0 deletions
1
hs80/Corsair-HS80-GNOME-extension
Submodule
1
hs80/Corsair-HS80-GNOME-extension
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 013b790a0ca9ca4d54bf38e7c64ff4f9f6a2ab33
|
||||
BIN
hs80/Corsairev2
Executable file
BIN
hs80/Corsairev2
Executable file
Binary file not shown.
BIN
hs80/corsair_working1.0
Executable file
BIN
hs80/corsair_working1.0
Executable file
Binary file not shown.
55
hs80/corsairev2.rs
Normal file
55
hs80/corsairev2.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
use hidapi::{HidApi};
|
||||
|
||||
const CORSAIR_VID: u16 = 0x1B1C;
|
||||
const HS80_PID: u16 = 0x0A6B;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("VID/PID : ");
|
||||
println!("{}",CORSAIR_VID);
|
||||
println!("{}",HS80_PID);
|
||||
|
||||
let api = HidApi::new()?;
|
||||
|
||||
let device = api.open(CORSAIR_VID, HS80_PID)?;
|
||||
let mut buffer = [0u8; 64];
|
||||
|
||||
println!("Reading from device");
|
||||
|
||||
loop {
|
||||
match device.read(&mut buffer) {
|
||||
Ok(size) => {
|
||||
/*for i in 0..size {
|
||||
print!("{:02X} ", buffer[i]);
|
||||
}*/
|
||||
if size > 2 {
|
||||
match buffer[3] {
|
||||
0x0f => {
|
||||
println!("Received battery change event");
|
||||
let percentage = (buffer[5] as u16 | (buffer[6] as u16) << 8) as f64 / 10.0;
|
||||
println!("Battery Percentage: {:.1}%", percentage);
|
||||
}
|
||||
0x10 => {
|
||||
println!("Received charging state change event");
|
||||
let charging = buffer[5] == 1;
|
||||
println!("Charging: {}", charging);
|
||||
}
|
||||
0xA6 => {
|
||||
println!("Received mic state change event");
|
||||
let micro = buffer[5] == 0;
|
||||
println!("Micro actif: {}", micro);
|
||||
}
|
||||
_ => {
|
||||
println!("Unsupported event");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Error reading from device: {}", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
0
hs80/hs80-kde-extension/package/contents/config/main.xml
Normal file
0
hs80/hs80-kde-extension/package/contents/config/main.xml
Normal file
9
hs80/hs80-kde-extension/package/contents/ui/main.qml
Normal file
9
hs80/hs80-kde-extension/package/contents/ui/main.qml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import QtQuick
|
||||
import org.kde.plasma.plasmoid
|
||||
import org.kde.plasma.components as PlasmaComponents
|
||||
|
||||
PlasmoidItem{
|
||||
PlasmaComponents.Label {
|
||||
text: "Hello World!"
|
||||
}
|
||||
}
|
||||
20
hs80/hs80-kde-extension/package/metadata.json
Normal file
20
hs80/hs80-kde-extension/package/metadata.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"KPlugin": {
|
||||
"Authors": [
|
||||
{
|
||||
"Email": "vbriday@gmail.com",
|
||||
"Name": "Victor Briday"
|
||||
}
|
||||
],
|
||||
"Category": "System Information",
|
||||
"Description": "hs80 status tray",
|
||||
"Icon": "headset",
|
||||
"Id": "com.example.hs80tray",
|
||||
"Name": "hs80tray",
|
||||
"Version": "1",
|
||||
"Website": "https://example.com/user/plasmoid-helloworldplugin",
|
||||
"BugReportUrl": "https://example.com/user/plasmoid-helloworldplugin/bugs"
|
||||
},
|
||||
"X-Plasma-API-Minimum-Version": "6.0",
|
||||
"KPackageStructure": "Plasma/Applet"
|
||||
}
|
||||
BIN
hs80/hw
Executable file
BIN
hs80/hw
Executable file
Binary file not shown.
3
hs80/hw.rs
Normal file
3
hs80/hw.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello world!!");
|
||||
}
|
||||
81
hs80/main.rs
Normal file
81
hs80/main.rs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
use hidapi::{HidApi};
|
||||
use dbus::blocking::{Connection};
|
||||
use dbus::channel::Sender;
|
||||
use dbus::{Message, Path};
|
||||
use dbus::strings::{Interface, Member};
|
||||
|
||||
const CORSAIR_VID: u16 = 0x1B1C;
|
||||
const HS80_PID: u16 = 0x0A6B;
|
||||
|
||||
struct DBusSignalSender {
|
||||
connection: Connection,
|
||||
path: Path<'static>,
|
||||
interface: Interface<'static>
|
||||
}
|
||||
|
||||
impl DBusSignalSender {
|
||||
|
||||
fn new(path: &str, interface: &str) -> Self {
|
||||
|
||||
let connection = Connection::new_session().expect("Failed to connect to DBus");
|
||||
|
||||
Self {
|
||||
connection,
|
||||
path: Path::new(path).expect("Invalid Path"),
|
||||
interface: Interface::new(interface).expect("Invalid Interface")
|
||||
}
|
||||
}
|
||||
|
||||
fn send_update(&self, update: i32) {
|
||||
let msg = Message::signal(
|
||||
&self.path,
|
||||
&self.interface,
|
||||
&Member::new("HS80").expect("Invalid Signal name"),
|
||||
).append1(update);
|
||||
|
||||
self.connection.send(msg).expect("Failed to send Signal");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Initialize the sender with borrowed string literals
|
||||
let sender = DBusSignalSender::new(
|
||||
"/com/h0psej0ch/corsair", // Object path
|
||||
"com.h0psej0ch.corsair.Interface", // Interface
|
||||
);
|
||||
|
||||
// Initialize the HID interface with the VID and PID of the HS-80 Headset
|
||||
let api = HidApi::new()?;
|
||||
let device = api.open(CORSAIR_VID, HS80_PID)?;
|
||||
let mut buffer = [0u8; 64];
|
||||
|
||||
// Indefinitely loop and read the device
|
||||
loop {
|
||||
match device.read(&mut buffer) {
|
||||
Ok(size) => {
|
||||
|
||||
if size > 2 {
|
||||
match buffer[3] {
|
||||
0x0f => {
|
||||
let percentage = (buffer[5] as u16 | (buffer[6] as u16) << 8) as f64 / 10.0;
|
||||
sender.send_update(percentage as i32);
|
||||
}
|
||||
0x10 => {
|
||||
let charging = buffer[5] == 1;
|
||||
sender.send_update(if charging {-1} else {-2});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Error reading from device: {}", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
52
hs80/main_working1.0.rs
Normal file
52
hs80/main_working1.0.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
use hidapi::{HidApi};
|
||||
|
||||
const CORSAIR_VID: u16 = 0x1B1C;
|
||||
const HS80_PID: u16 = 0x0A6B;
|
||||
|
||||
//fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("VID/PID : ");
|
||||
println!("{}",CORSAIR_VID);
|
||||
println!("{}",HS80_PID);
|
||||
|
||||
let api = HidApi::new()?;
|
||||
|
||||
let device = api.open(CORSAIR_VID, HS80_PID)?;
|
||||
let mut buffer = [0u8; 64];
|
||||
|
||||
println!("Reading from device");
|
||||
|
||||
loop {
|
||||
match device.read(&mut buffer) {
|
||||
Ok(size) => {
|
||||
for i in 0..size {
|
||||
print!("{:02X} ", buffer[i]);
|
||||
}
|
||||
if size > 2 {
|
||||
match buffer[3] {
|
||||
0x0f => {
|
||||
println!("Received battery change event");
|
||||
let percentage = (buffer[5] as u16 | (buffer[6] as u16) << 8) as f64 / 10.0;
|
||||
println!("Battery Percentage: {:.1}%", percentage);
|
||||
}
|
||||
0x10 => {
|
||||
println!("Received charging state change event");
|
||||
let charging = buffer[5] == 1;
|
||||
println!("Charging: {}", charging);
|
||||
}
|
||||
_ => {
|
||||
println!("Unsupported event");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Error reading from device: {}", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue