hid_preparsed_data.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_HID_HID_PREPARSED_DATA_H_
  5. #define SERVICES_DEVICE_HID_HID_PREPARSED_DATA_H_
  6. #include <windows.h>
  7. // NOTE: <hidsdi.h> must be included before <hidpi.h>. clang-format will want to
  8. // reorder them.
  9. // clang-format off
  10. extern "C" {
  11. #include <hidsdi.h>
  12. #include <hidpi.h>
  13. }
  14. // clang-format on
  15. #include <memory>
  16. #include <vector>
  17. #include "services/device/hid/hid_service_win.h"
  18. namespace device {
  19. class HidPreparsedData : public HidServiceWin::PreparsedData {
  20. public:
  21. // Return a HidPreparsedData constructed from an open |device_handle|, or
  22. // nullptr if the handle is invalid or the device data could not be read.
  23. static std::unique_ptr<HidPreparsedData> Create(HANDLE device_handle);
  24. HidPreparsedData(const HidPreparsedData&) = delete;
  25. HidPreparsedData& operator=(const HidPreparsedData&) = delete;
  26. ~HidPreparsedData() override;
  27. // HidServiceWin::PreparsedData implementation.
  28. const HIDP_CAPS& GetCaps() const override;
  29. std::vector<ReportItem> GetReportItems(
  30. HIDP_REPORT_TYPE report_type) const override;
  31. private:
  32. HidPreparsedData(PHIDP_PREPARSED_DATA preparsed_data, HIDP_CAPS capabilities);
  33. const PHIDP_PREPARSED_DATA preparsed_data_;
  34. const HIDP_CAPS capabilities_;
  35. };
  36. } // namespace device
  37. #endif // SERVICES_DEVICE_HID_HID_PREPARSED_DATA_H_