Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: components/arc/arc_bridge_input_devices.h

Issue 1408263006: chromeos: Add ArcInputBridge to components/arc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@arcxx
Patch Set: Arc: Extend ArcBridgeService with input bridge Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698