InputDriver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2015 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef ANDROID_INPUT_DRIVER_H
  17. #define ANDROID_INPUT_DRIVER_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include "InputHost.h"
  21. #include <hardware/input.h>
  22. #include <utils/RefBase.h>
  23. #include <utils/String8.h>
  24. namespace android {
  25. class InputHostInterface;
  26. class InputDriverInterface : public virtual RefBase {
  27. protected:
  28. InputDriverInterface() = default;
  29. virtual ~InputDriverInterface() = default;
  30. public:
  31. virtual void init(InputHostInterface* host) = 0;
  32. virtual void dump(String8& result) = 0;
  33. };
  34. class InputDriver : public InputDriverInterface {
  35. public:
  36. InputDriver(const char* name);
  37. virtual ~InputDriver() = default;
  38. virtual void init(InputHostInterface* host) override;
  39. virtual void dump(String8& result) override;
  40. private:
  41. String8 mName;
  42. const input_module_t* mHal;
  43. };
  44. extern "C" {
  45. input_device_identifier_t* create_device_identifier(input_host_t* host,
  46. const char* name, int32_t product_id, int32_t vendor_id,
  47. input_bus_t bus, const char* unique_id);
  48. input_device_definition_t* create_device_definition(input_host_t* host);
  49. input_report_definition_t* create_input_report_definition(input_host_t* host);
  50. input_report_definition_t* create_output_report_definition(input_host_t* host);
  51. void input_device_definition_add_report(input_host_t* host,
  52. input_device_definition_t* d, input_report_definition_t* r);
  53. void input_report_definition_add_collection(input_host_t* host,
  54. input_report_definition_t* report, input_collection_id_t id, int32_t arity);
  55. void input_report_definition_declare_usage_int(input_host_t* host,
  56. input_report_definition_t* report, input_collection_id_t id,
  57. input_usage_t usage, int32_t min, int32_t max, float resolution);
  58. void input_report_definition_declare_usages_bool(input_host_t* host,
  59. input_report_definition_t* report, input_collection_id_t id,
  60. input_usage_t* usage, size_t usage_count);
  61. input_device_handle_t* register_device(input_host_t* host,
  62. input_device_identifier_t* id, input_device_definition_t* d);
  63. void unregister_device(input_host_t* host, input_device_handle_t* handle);
  64. input_report_t* input_allocate_report(input_host_t* host, input_report_definition_t* r);
  65. void input_report_set_usage_int(input_host_t* host, input_report_t* r,
  66. input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index);
  67. void input_report_set_usage_bool(input_host_t* host, input_report_t* r,
  68. input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index);
  69. void report_event(input_host_t* host, input_device_handle_t* d, input_report_t* report);
  70. input_property_map_t* input_get_device_property_map(input_host_t* host,
  71. input_device_identifier_t* id);
  72. input_property_t* input_get_device_property(input_host_t* host, input_property_map_t* map,
  73. const char* key);
  74. const char* input_get_property_key(input_host_t* host, input_property_t* property);
  75. const char* input_get_property_value(input_host_t* host, input_property_t* property);
  76. void input_free_device_property(input_host_t* host, input_property_t* property);
  77. void input_free_device_property_map(input_host_t* host, input_property_map_t* map);
  78. }
  79. } // namespace android
  80. #endif // ANDROID_INPUT_DRIVER_H