2015-06-29 00:17:35 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
#include <libevdev/libevdev.h>
|
2015-06-29 00:17:35 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-07-14 15:50:35 +00:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
|
|
|
2015-06-29 00:17:35 +00:00
|
|
|
namespace ciface
|
|
|
|
{
|
|
|
|
namespace evdev
|
|
|
|
{
|
2016-06-12 15:08:04 +00:00
|
|
|
void Init();
|
2016-07-14 15:50:35 +00:00
|
|
|
void Shutdown();
|
2015-06-29 00:17:35 +00:00
|
|
|
|
|
|
|
class evdevDevice : public Core::Device
|
|
|
|
{
|
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
class Button : public Core::Device::Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const override;
|
|
|
|
Button(u8 index, u16 code, libevdev* dev) : m_index(index), m_code(code), m_dev(dev) {}
|
|
|
|
ControlState GetState() const override;
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
private:
|
|
|
|
const u8 m_index;
|
|
|
|
const u16 m_code;
|
|
|
|
libevdev* m_dev;
|
|
|
|
};
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
class Axis : public Core::Device::Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const override;
|
|
|
|
Axis(u8 index, u16 code, bool upper, libevdev* dev);
|
|
|
|
ControlState GetState() const override;
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
private:
|
|
|
|
const u16 m_code;
|
|
|
|
const u8 m_index;
|
|
|
|
const bool m_upper;
|
|
|
|
int m_range;
|
|
|
|
int m_min;
|
|
|
|
libevdev* m_dev;
|
|
|
|
};
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
class ForceFeedback : public Core::Device::Output
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const override;
|
|
|
|
ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_id(-1) { m_fd = libevdev_get_fd(dev); }
|
|
|
|
~ForceFeedback();
|
|
|
|
void SetState(ControlState state) override;
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
private:
|
|
|
|
const u16 m_type;
|
|
|
|
int m_fd;
|
|
|
|
int m_id;
|
|
|
|
};
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
public:
|
|
|
|
void UpdateInput() override;
|
2016-07-14 15:50:35 +00:00
|
|
|
bool IsValid() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-07-14 08:25:52 +00:00
|
|
|
evdevDevice(const std::string& devnode);
|
2016-06-24 08:43:46 +00:00
|
|
|
~evdevDevice();
|
2015-06-29 00:17:35 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string GetName() const override { return m_name; }
|
|
|
|
std::string GetSource() const override { return "evdev"; }
|
|
|
|
bool IsInteresting() const { return m_initialized && m_interesting; }
|
2015-06-29 00:17:35 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
const std::string m_devfile;
|
|
|
|
int m_fd;
|
|
|
|
libevdev* m_dev;
|
|
|
|
std::string m_name;
|
|
|
|
bool m_initialized;
|
|
|
|
bool m_interesting;
|
2015-06-29 00:17:35 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|