Skip to content

Commit

Permalink
debug iohid
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkens committed Jul 3, 2024
1 parent 894e962 commit 7f8c511
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- '**'
tags-ignore:
- 'v*'
paths:
- .github/workflows/*.yml
- Cargo.toml
Expand Down Expand Up @@ -39,3 +41,4 @@ jobs:
with:
name: macmon-${{ github.ref_name }}.tar.gz
path: macmon-${{ github.ref_name }}.tar.gz
retention-days: 7
12 changes: 12 additions & 0 deletions src/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,23 +627,35 @@ impl IOHIDSensors {
unsafe {
let system = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
if system.is_null() {
eprintln!("Failed to create event system");
return vec![];
}

IOHIDEventSystemClientSetMatching(system, self.sensors);
let services = IOHIDEventSystemClientCopyServices(system);
if services.is_null() {
eprintln!("Failed to get services");
return vec![];
}

let mut items = vec![] as Vec<(String, f32)>;
for i in 0..CFArrayGetCount(services) {
let sc = CFArrayGetValueAtIndex(services, i) as IOHIDServiceClientRef;
if sc.is_null() {
eprintln!("Failed to get service client");
continue;
}

let name = IOHIDServiceClientCopyProperty(sc, cfstr("Product"));
if name.is_null() {
eprintln!("Failed to get product name");
continue;
}
let name = from_cfstr(name);

let event = IOHIDServiceClientCopyEvent(sc, kIOHIDEventTypeTemperature, 0, 0);
if !event.is_null() {
eprintln!("Failed to get event. Sensor: {}. Skipping...", name);
let temp = IOHIDEventGetFloatValue(event, kIOHIDEventTypeTemperature << 16);
CFRelease(event as _);
items.push((name, temp as f32));
Expand Down

0 comments on commit 7f8c511

Please sign in to comment.