Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable send/get feature report #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions lib/hid_api/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,27 @@ def write(data)
end

def get_feature_report(data)
raise NotImplementedError
buffer = clear_buffer data.length
case data
when String then buffer.put_bytes 0, data
when Array then buffer.put_array_of_char 0, data
end

with_hid_error_handling do
HidApi.hid_get_feature_report self, buffer, buffer.length
end
end

def send_feature_report(data)
raise NotImplementedError
buffer = clear_buffer data.length
case data
when String then buffer.put_bytes 0, data
when Array then buffer.put_array_of_char 0, data
end

with_hid_error_handling do
HidApi.hid_send_feature_report self, buffer, buffer.length
end
end

def error
Expand Down Expand Up @@ -92,4 +108,4 @@ def with_hid_error_handling
end
end
end
end
end