| // Copyright 2024 Google LLC |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| #pragma once |
| #include "libusb.hpp" |
| |
| #include <stdplus/handle/managed.hpp> |
| |
| #include <chrono> |
| #include <cstdint> |
| #include <utility> |
| #include <vector> |
| |
| namespace google |
| { |
| namespace hoth |
| { |
| |
| class LibusbImpl : public LibusbIntf |
| { |
| public: |
| int release_interface(libusb_device_handle* handle, |
| int interface_num) override; |
| int claim_interface(libusb_device_handle* handle, |
| int interface_num) override; |
| int bulk_transfer(libusb_device_handle* dev_handle, unsigned char endpoint, |
| unsigned char* data, int length, int* transferred, |
| unsigned int timeout) override; |
| void close(libusb_device_handle* dev_handle) override; |
| int get_active_config_descriptor( |
| libusb_device* dev, libusb_config_descriptor** config) override; |
| int get_bus_number(libusb_device* dev) override; |
| int get_port_numbers(libusb_device* dev, uint8_t* port_numbers, |
| int port_numbers_len) override; |
| int open(libusb_device* dev, libusb_device_handle** handle) override; |
| libusb_device* ref_device(libusb_device* dev) override; |
| void unref_device(libusb_device* dev) override; |
| ssize_t get_device_list(libusb_context* ctx, |
| libusb_device*** list) override; |
| void free_device_list(libusb_device** list, int unref_devices) override; |
| void exit(libusb_context* ctx) override; |
| int init(libusb_context** ctx) override; |
| }; |
| |
| extern LibusbImpl libusb_impl; |
| |
| } // namespace hoth |
| } // namespace google |