OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_ARC_INPUT_ARC_INPUT_BRIDGE_IMPL_H_ | 5 #ifndef COMPONENTS_EXO_ARC_INPUT_ARC_INPUT_BRIDGE_IMPL_H_ |
6 #define COMPONENTS_ARC_INPUT_ARC_INPUT_BRIDGE_IMPL_H_ | 6 #define COMPONENTS_EXO_ARC_INPUT_ARC_INPUT_BRIDGE_IMPL_H_ |
7 | |
8 #include <stdint.h> | |
9 #include <string> | |
10 #include <vector> | |
11 | 7 |
12 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
13 #include "base/macros.h" | 9 #include "base/macros.h" |
14 #include "components/arc/input/arc_input_bridge.h" | 10 #include "components/arc/input/arc_input_bridge.h" |
15 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
16 #include "ui/aura/env_observer.h" | 12 #include "ui/aura/env_observer.h" |
17 #include "ui/aura/window_tracker.h" | 13 #include "ui/aura/window_tracker.h" |
18 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
19 #include "ui/events/event_handler.h" | 15 #include "ui/events/event_handler.h" |
20 | 16 |
(...skipping 21 matching lines...) Expand all Loading... |
42 explicit ArcInputBridgeImpl(ArcBridgeService* arc_bridge_service); | 38 explicit ArcInputBridgeImpl(ArcBridgeService* arc_bridge_service); |
43 ~ArcInputBridgeImpl() override; | 39 ~ArcInputBridgeImpl() override; |
44 | 40 |
45 // Overridden from ui::EventHandler: | 41 // Overridden from ui::EventHandler: |
46 void OnEvent(ui::Event* event) override; | 42 void OnEvent(ui::Event* event) override; |
47 | 43 |
48 // Overridden from aura::EnvObserver: | 44 // Overridden from aura::EnvObserver: |
49 void OnWindowInitialized(aura::Window* new_window) override; | 45 void OnWindowInitialized(aura::Window* new_window) override; |
50 | 46 |
51 // Overridden from ArcBridgeService::Observer: | 47 // Overridden from ArcBridgeService::Observer: |
52 void OnInputInstanceReady() override; | 48 void OnInstanceBootPhase(InstanceBootPhase phase) override; |
53 | 49 |
54 private: | 50 private: |
55 // Specialized method to translate and send events to the right file | 51 // Specialized method to translate and send events to the right file |
56 // descriptor. | 52 // descriptor. |
57 void SendKeyEvent(ui::KeyEvent* event); | 53 void SendKeyEvent(ui::KeyEvent* event); |
58 void SendTouchEvent(ui::TouchEvent* event); | 54 void SendTouchEvent(ui::TouchEvent* event); |
59 void SendMouseEvent(ui::MouseEvent* event); | 55 void SendMouseEvent(ui::MouseEvent* event); |
60 | 56 |
61 // Helper method to send a struct input_event to the file descriptor. This | 57 // Helper method to send a struct input_event to the file descriptor. This |
62 // method is to be called on the ui thread and will post a request to send | 58 // method is to be called on the ui thread and will post a request to send |
63 // the event to the io thread. | 59 // the event to the io thread. |
64 // The parameters map directly to the members of input_event as | 60 // The parameters map directly to the members of input_event as |
65 // defined by the evdev protocol. | 61 // defined by the evdev protocol. |
66 // |type| is the type of event to sent, such as EV_SYN, EV_KEY, EV_ABS. | 62 // |type| is the type of event to sent, such as EV_SYN, EV_KEY, EV_ABS. |
67 // |code| is either interpreted as axis (ABS_X, ABS_Y, ...) or as key-code | 63 // |code| is either interpreted as axis (ABS_X, ABS_Y, ...) or as key-code |
68 // (KEY_A, KEY_B, ...). | 64 // (KEY_A, KEY_B, ...). |
69 // |value| is either the value of that axis or the boolean value of the key | 65 // |value| is either the value of that axis or the boolean value of the key |
70 // as in 0 (released), 1 (pressed) or 2 (repeated press). | 66 // as in 0 (released), 1 (pressed) or 2 (repeated press). |
71 void SendKernelEvent(const base::ScopedFD& fd, | 67 void SendKernelEvent(const base::ScopedFD& fd, |
72 base::TimeDelta timestamp, | 68 base::TimeDelta timestamp, |
73 uint16_t type, | 69 unsigned short type, |
74 uint16_t code, | 70 unsigned short code, |
75 int value); | 71 int value); |
76 | 72 |
77 // Shorthand for sending EV_SYN/SYN_REPORT | 73 // Shorthand for sending EV_SYN/SYN_REPORT |
78 void SendSynReport(const base::ScopedFD& fd, base::TimeDelta timestamp); | 74 void SendSynReport(const base::ScopedFD& fd, base::TimeDelta timestamp); |
79 | 75 |
80 // Return existing or new slot for this event. | 76 // Return existing or new slot for this event. |
81 int AcquireTouchSlot(ui::TouchEvent* event); | 77 int AcquireTouchSlot(ui::TouchEvent* event); |
82 | 78 |
83 // Return touch slot for tracking id. | 79 // Return touch slot for tracking id. |
84 int FindTouchSlot(int tracking_id); | 80 int FindTouchSlot(int tracking_id); |
85 | 81 |
86 // Maps DOM key codes to evdev key codes | 82 // Maps DOM key codes to evdev key codes |
87 uint16_t DomCodeToEvdevCode(ui::DomCode dom_code); | 83 unsigned short DomCodeToEvdevCode(ui::DomCode dom_code); |
| 84 |
88 | 85 |
89 // Setup bridge devices on the instance side. This needs to be called after | 86 // Setup bridge devices on the instance side. This needs to be called after |
90 // the InstanceBootPhase::SYSTEM_SERVICES_READY has been reached. | 87 // the InstanceBootPhase::SYSTEM_SERVICES_READY has been reached. |
91 void SetupBridgeDevices(); | 88 void SetupBridgeDevices(); |
92 | 89 |
93 // Creates and registers file descriptor pair with the ARC bridge service, | 90 // Creates and registers file descriptor pair with the ARC bridge service, |
94 // the write end is returned while the read end is sent through the bridge | 91 // the write end is returned while the read end is sent through the bridge |
95 // to the ARC instance. | 92 // to the ARC instance. |
96 // TODO(denniskempin): Make this interface more typesafe. | 93 // TODO(denniskempin): Make this interface more typesafe. |
97 // |name| should be the displayable name of the emulated device (e.g. "Chrome | 94 // |name| should be the displayable name of the emulated device (e.g. "Chrome |
(...skipping 28 matching lines...) Expand all Loading... |
126 aura::WindowTracker arc_windows_; | 123 aura::WindowTracker arc_windows_; |
127 | 124 |
128 // WeakPtrFactory to use for callbacks. | 125 // WeakPtrFactory to use for callbacks. |
129 base::WeakPtrFactory<ArcInputBridgeImpl> weak_factory_; | 126 base::WeakPtrFactory<ArcInputBridgeImpl> weak_factory_; |
130 | 127 |
131 DISALLOW_COPY_AND_ASSIGN(ArcInputBridgeImpl); | 128 DISALLOW_COPY_AND_ASSIGN(ArcInputBridgeImpl); |
132 }; | 129 }; |
133 | 130 |
134 } // namespace arc | 131 } // namespace arc |
135 | 132 |
136 #endif // COMPONENTS_ARC_INPUT_ARC_INPUT_BRIDGE_IMPL_H_ | 133 #endif // COMPONENTS_EXO_ARC_INPUT_ARC_INPUT_BRIDGE_IMPL_H_ |
OLD | NEW |