blob: 4f72ea67941255357e46bd7960cc444ec6090db4 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "base/macros.h"
#include "ui/events/devices/events_devices_export.h"
#include "ui/events/devices/input_device.h"
#include "ui/events/devices/input_device_event_observer.h"
#include "ui/events/devices/touchscreen_device.h"
namespace ui {
// Interface to query available input devices. The implementation, which is a
// singleton, could be DeviceDataManager or something that mirrors the necessary
// state if DeviceDataManager is in a different process.
class EVENTS_DEVICES_EXPORT InputDeviceManager {
InputDeviceManager() = default;
virtual ~InputDeviceManager() = default;
static InputDeviceManager* GetInstance();
static bool HasInstance();
virtual const std::vector<InputDevice>& GetKeyboardDevices() const = 0;
virtual const std::vector<TouchscreenDevice>& GetTouchscreenDevices()
const = 0;
virtual const std::vector<InputDevice>& GetMouseDevices() const = 0;
virtual const std::vector<InputDevice>& GetTouchpadDevices() const = 0;
virtual bool AreDeviceListsComplete() const = 0;
virtual bool AreTouchscreensEnabled() const = 0;
// Returns true if the |target_display_id| of the TouchscreenDevices returned
// from GetTouchscreenDevices() is valid.
virtual bool AreTouchscreenTargetDisplaysValid() const = 0;
virtual void AddObserver(InputDeviceEventObserver* observer) = 0;
virtual void RemoveObserver(InputDeviceEventObserver* observer) = 0;
// Sets the instance. This should only be set once per thread.
static void SetInstance(InputDeviceManager* instance);
// Clears the instance. InputDeviceManager doesn't own the instance and won't
// destroy it, so it should be cleared before it is destroyed elsewhere.
static void ClearInstance();
static InputDeviceManager* instance_; // Not owned.
} // namespace ui