| Index: ui/events/ozone/evdev/gamepad_event_converter_evdev.h
|
| diff --git a/ui/events/ozone/evdev/gamepad_event_converter_evdev.h b/ui/events/ozone/evdev/gamepad_event_converter_evdev.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..626f2b3f1c116e327a4c6cdeb41cb3d1aee4b7c0
|
| --- /dev/null
|
| +++ b/ui/events/ozone/evdev/gamepad_event_converter_evdev.h
|
| @@ -0,0 +1,78 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#ifndef UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
|
| +#define UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
|
| +
|
| +#include <vector>
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "base/macros.h"
|
| +#include "ui/events/devices/input_device.h"
|
| +#include "ui/events/event.h"
|
| +#include "ui/events/ozone/evdev/event_converter_evdev.h"
|
| +#include "ui/events/ozone/evdev/event_device_info.h"
|
| +#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
|
| +#include "ui/events/ozone/evdev/scoped_input_device.h"
|
| +#include "ui/events/ozone/gamepad/gamepad_mapping.h"
|
| +
|
| +struct input_event;
|
| +
|
| +namespace ui {
|
| +
|
| +class DeviceEventDispatcherEvdev;
|
| +
|
| +class EVENTS_OZONE_EVDEV_EXPORT GamepadEventConverterEvdev
|
| + : public EventConverterEvdev {
|
| + public:
|
| + GamepadEventConverterEvdev(ScopedInputDevice fd,
|
| + base::FilePath path,
|
| + int id,
|
| + const EventDeviceInfo& info,
|
| + DeviceEventDispatcherEvdev* dispatcher);
|
| +
|
| + ~GamepadEventConverterEvdev() override;
|
| +
|
| + // EventConverterEvdev:
|
| + void OnFileCanReadWithoutBlocking(int fd) override;
|
| + bool HasGamepad() const override;
|
| + void OnDisabled() override;
|
| +
|
| + // This function process one input_event from evdev.
|
| + void ProcessEvent(const struct input_event& input);
|
| +
|
| + private:
|
| + // This function release all the keys and reset all the axis.
|
| + void ResetGamepad();
|
| + void OnButtonChange(unsigned int code,
|
| + double value,
|
| + const base::TimeTicks& timestamp);
|
| + void OnAbsChange(unsigned int code,
|
| + double value,
|
| + const base::TimeTicks& timestamp);
|
| + void OnSync(const base::TimeTicks& timestamp);
|
| +
|
| + // Sometimes, we want to drop abs values, when we do so, we no longer want to
|
| + // send gamepad frame event when we see next sync. This flag is set to false
|
| + // when each frame is sent. It is set to true when Btn or Abs event is sent.
|
| + bool will_send_frame_;
|
| +
|
| + // This is the abs_info for this gamepad. It will be used to map abs values.
|
| + struct input_absinfo abs_info_[ABS_CNT];
|
| +
|
| + // This is the mapper for this gamepad.
|
| + GamepadMapper mapper_;
|
| +
|
| + // Input device file descriptor.
|
| + ScopedInputDevice input_device_fd_;
|
| +
|
| + // Callbacks for dispatching events.
|
| + DeviceEventDispatcherEvdev* dispatcher_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev);
|
| +};
|
| +
|
| +} // namespace ui
|
| +
|
| +#endif // UI_EVENTS_OZONE_GAMEPAD_EVENT_CONVERTER_EVDEV_H_
|
|
|