X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Finput%2Fdevice.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Finput%2Fdevice.h;h=865e9fe40e089a6559cfc28b4617517b789397f1;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/input/device.h b/src/type3_AndroidCloud/anbox-master/src/anbox/input/device.h new file mode 100644 index 0000000..865e9fe --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/input/device.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_INPUT_DEVICE_H_ +#define ANBOX_INPUT_DEVICE_H_ + +#include "anbox/network/connections.h" +#include "anbox/network/published_socket_connector.h" +#include "anbox/network/socket_connection.h" +#include "anbox/runtime.h" + +#include + +#include + +namespace anbox { +namespace input { +struct Event { + std::uint16_t type; + std::uint16_t code; + std::int32_t value; +}; + +class Device : public std::enable_shared_from_this { + public: + static std::shared_ptr create( + const std::string &path, const std::shared_ptr &runtime); + + Device(); + ~Device(); + + void send_events(const std::vector &events); + void send_event(const std::uint16_t &code, const std::uint16_t &event, + const std::int32_t &value); + + void set_name(const std::string &name); + void set_driver_version(const int &version); + void set_input_id(const struct input_id &id); + void set_physical_location(const std::string &physical_location); + void set_unique_id(const std::string &unique_id); + void set_key_bit(const std::uint64_t &bit); + void set_abs_bit(const std::uint64_t &bit); + void set_rel_bit(const std::uint64_t &bit); + void set_sw_bit(const std::uint64_t &bit); + void set_led_bit(const std::uint64_t &bit); + void set_ff_bit(const std::uint64_t &bit); + void set_prop_bit(const std::uint64_t &bit); + + void set_abs_min(const std::uint64_t &bit, const std::uint32_t &value); + void set_abs_max(const std::uint64_t &bit, const std::uint32_t &value); + + std::string socket_path() const; + + private: + int next_id(); + void new_client(std::shared_ptr< + boost::asio::local::stream_protocol::socket> const &socket); + + // NOTE: If you modify this struct you have to modify the version on + // the Android side too. See + // frameworks/native/services/inputflinger/EventHub.cpp + struct Info { + char name[80]; + int driver_version; + struct input_id id; + char physical_location[80]; + char unique_id[80]; + std::uint8_t key_bitmask[(KEY_MAX + 1) / 8]; + std::uint8_t abs_bitmask[(ABS_MAX + 1) / 8]; + std::uint8_t rel_bitmask[(REL_MAX + 1) / 8]; + std::uint8_t sw_bitmask[(SW_MAX + 1) / 8]; + std::uint8_t led_bitmask[(LED_MAX + 1) / 8]; + std::uint8_t ff_bitmask[(FF_MAX + 1) / 8]; + std::uint8_t prop_bitmask[(INPUT_PROP_MAX + 1) / 8]; + std::uint32_t abs_max[ABS_CNT]; + std::uint32_t abs_min[ABS_CNT]; + }; + + void set_bit(std::uint8_t *array, const std::uint64_t &bit); + + std::shared_ptr connector_; + std::atomic next_connection_id_; + std::shared_ptr> connections_; + Info info_; +}; +} // namespace input +} // namespace anbox + +#endif