Index: components/arc/arc_bridge_input_devices.h |
diff --git a/components/arc/arc_bridge_input_devices.h b/components/arc/arc_bridge_input_devices.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9f41b2827b152c60867e9c746f0c344da437a66a |
--- /dev/null |
+++ b/components/arc/arc_bridge_input_devices.h |
@@ -0,0 +1,71 @@ |
+#ifndef CHROMEOS_ARC_BRIDGE_INPUT_DEVICES_H_ |
+#define CHROMEOS_ARC_BRIDGE_INPUT_DEVICES_H_ |
+ |
+#include "base/files/scoped_file.h" |
+#include "base/macros.h" |
+#include "base/memory/scoped_vector.h" |
+#include "ui/events/event.h" |
+#include "ui/events/event_handler.h" |
+ |
+#include <linux/types.h> |
+ |
+namespace arc { |
+ |
+class BridgeInputDevice : public ui::EventHandler { |
+ public: |
+ BridgeInputDevice(base::ScopedFD fd); |
+ |
+ // Send input_event through file descriptor. |
+ void SendEvent(base::TimeDelta time, __u16 type, __u16 code, __s32 value); |
+ |
+ // Shorthand for sending a SYN_REPORT input_event. |
+ void SendSynReport(base::TimeDelta time); |
+ |
+ private: |
+ base::ScopedFD fd_; |
+}; |
+ |
+// BridgeInputDevice for handling keyboard events |
+class KeyboardBridgeInputDevice : public BridgeInputDevice { |
+ // input_event values for keyboard events |
+ static const int kKeyReleased = 0; |
+ static const int kKeyPressed = 1; |
+ static const int kKeyRepeated = 2; |
+ |
+ public: |
+ void OnKeyEvent(ui::KeyEvent* event) override; |
+}; |
+ |
+// BridgeInputDevice for handling mouse events |
+class MouseBridgeInputDevice : public BridgeInputDevice { |
+ public: |
+ void OnMouseEvent(ui::MouseEvent* event) override; |
+ |
+ private: |
+ void SendMouseButton(ui::MouseEvent* event, int flag, int evdev_code); |
+}; |
+ |
+ |
+// BridgeDevice for handling touch events |
+class TouchscreenBridgeInputDevice : public BridgeInputDevice { |
+ static const int kEmptySlot = -1; |
+ static const int kMaxSlots = 32; |
+ |
+ public: |
+ TouchscreenBridgeInputDevice(base::ScopedFD fd); |
+ |
+ virtual void OnTouchEvent(ui::TouchEvent* event) override; |
+ |
+ private: |
+ // Manages available slot id's and returns slot assigned to this touch event. |
+ int AcquireSlot(ui::TouchEvent* event); |
+ // Locates slot for tracking id |
+ int FindSlot(int tracking_id); |
+ |
+ std::vector<uint8_t> current_slot_tracking_ids_; |
+ uint8_t current_slot_; |
+}; |
+ |
+} |
+ |
+#endif // CHROMEOS_ARC_BRIDGE_INPUT_DEVICES_H_ |