Léo Lam 788e19f54d ControllerInterface: Make the ID assigning code common
This makes the device ID assigning code common to all backends, by
moving it to AddDevice() instead of copy-pasting or replicating
the logic in the backends.

Also, to prepare for hotplugging, instead of relying on a name usage
count, the new ID assigning system always starts from ID 0 and tries
to assign the first ID that is not used.
2016-07-14 10:50:53 +02:00

56 lines
1.1 KiB
C++

// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "jni/ButtonManager.h"
namespace ciface
{
namespace Android
{
void Init();
class Touchscreen : public Core::Device
{
private:
class Button : public Input
{
public:
std::string GetName() const;
Button(int padID, ButtonManager::ButtonType index) : _padID(padID), _index(index) {}
ControlState GetState() const;
private:
const int _padID;
const ButtonManager::ButtonType _index;
};
class Axis : public Input
{
public:
std::string GetName() const;
Axis(int padID, ButtonManager::ButtonType index, float neg = 1.0f)
: _padID(padID), _index(index), _neg(neg)
{
}
ControlState GetState() const;
private:
const int _padID;
const ButtonManager::ButtonType _index;
const float _neg;
};
public:
Touchscreen(int padID);
~Touchscreen() {}
std::string GetName() const;
std::string GetSource() const;
private:
const int _padID;
};
}
}