Use the appropriate variant of IntToString in //remoting
[chromium-blink-merge.git] / remoting / protocol / input_event_tracker.h
blobc1f87ae7795de23d41381b85fc6ffe4c603c2637
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_INPUT_EVENT_TRACKER_H_
6 #define REMOTING_PROTOCOL_INPUT_EVENT_TRACKER_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "remoting/protocol/input_stub.h"
13 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
15 namespace remoting {
16 namespace protocol {
18 // Filtering InputStub which tracks mouse and keyboard input events before
19 // passing them on to |input_stub|, and can dispatch release events to
20 // |input_stub| for all currently-pressed keys and buttons when necessary.
21 class InputEventTracker : public InputStub {
22 public:
23 explicit InputEventTracker(protocol::InputStub* input_stub);
24 ~InputEventTracker() override;
26 // Returns true if the key with the specified USB code is currently pressed.
27 bool IsKeyPressed(uint32 usb_keycode) const;
29 // Returns the count of keys currently pressed.
30 int PressedKeyCount() const;
32 // Dispatch release events for all currently-pressed keys, mouse buttons, and
33 // touch points to the InputStub.
34 void ReleaseAll();
36 // Similar to ReleaseAll, but conditional on a modifier key tracked by this
37 // class being pressed without the corresponding parameter indicating that it
38 // should be.
39 void ReleaseAllIfModifiersStuck(bool alt_expected, bool ctrl_expected,
40 bool os_expected, bool shift_expected);
42 // InputStub interface.
43 void InjectKeyEvent(const KeyEvent& event) override;
44 void InjectTextEvent(const TextEvent& event) override;
45 void InjectMouseEvent(const MouseEvent& event) override;
46 void InjectTouchEvent(const TouchEvent& event) override;
48 private:
49 protocol::InputStub* input_stub_;
51 std::set<uint32> pressed_keys_;
53 webrtc::DesktopVector mouse_pos_;
54 uint32 mouse_button_state_;
56 std::set<uint32> touch_point_ids_;
58 DISALLOW_COPY_AND_ASSIGN(InputEventTracker);
61 } // namespace protocol
62 } // namespace remoting
64 #endif // REMOTING_PROTOCOL_INPUT_EVENT_TRACKER_H_