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