mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 06:13:09 +02:00
Fixing the review comments and setting the StandardDevice of USerINputMapper in the registeredDevices just like any other, only the ID is special
This commit is contained in:
parent
f0034844e7
commit
0fc04ab297
3 changed files with 19 additions and 18 deletions
|
@ -26,7 +26,7 @@ namespace controller {
|
||||||
|
|
||||||
class VirtualEndpoint : public Endpoint {
|
class VirtualEndpoint : public Endpoint {
|
||||||
public:
|
public:
|
||||||
VirtualEndpoint(const UserInputMapper::Input& id = UserInputMapper::Input(-1))
|
VirtualEndpoint(const UserInputMapper::Input& id = UserInputMapper::Input::INVALID_INPUT)
|
||||||
: Endpoint(id) {
|
: Endpoint(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace controller {
|
||||||
class JSEndpoint : public Endpoint {
|
class JSEndpoint : public Endpoint {
|
||||||
public:
|
public:
|
||||||
JSEndpoint(const QJSValue& callable)
|
JSEndpoint(const QJSValue& callable)
|
||||||
: Endpoint(UserInputMapper::Input(-1)), _callable(callable) {}
|
: Endpoint(UserInputMapper::Input::INVALID_INPUT), _callable(callable) {}
|
||||||
|
|
||||||
virtual float value() {
|
virtual float value() {
|
||||||
float result = (float)_callable.call().toNumber();;
|
float result = (float)_callable.call().toNumber();;
|
||||||
|
@ -59,7 +59,7 @@ namespace controller {
|
||||||
class ScriptEndpoint : public Endpoint {
|
class ScriptEndpoint : public Endpoint {
|
||||||
public:
|
public:
|
||||||
ScriptEndpoint(const QScriptValue& callable)
|
ScriptEndpoint(const QScriptValue& callable)
|
||||||
: Endpoint(UserInputMapper::Input(-1)), _callable(callable) {
|
: Endpoint(UserInputMapper::Input::INVALID_INPUT), _callable(callable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float value() {
|
virtual float value() {
|
||||||
|
@ -78,7 +78,7 @@ namespace controller {
|
||||||
class CompositeEndpoint : public Endpoint, Endpoint::Pair {
|
class CompositeEndpoint : public Endpoint, Endpoint::Pair {
|
||||||
public:
|
public:
|
||||||
CompositeEndpoint(Endpoint::Pointer first, Endpoint::Pointer second)
|
CompositeEndpoint(Endpoint::Pointer first, Endpoint::Pointer second)
|
||||||
: Endpoint(UserInputMapper::Input(-1)), Pair(first, second) { }
|
: Endpoint(UserInputMapper::Input(UserInputMapper::Input::INVALID_INPUT)), Pair(first, second) { }
|
||||||
|
|
||||||
virtual float value() {
|
virtual float value() {
|
||||||
float result = first->value() * -1.0 + second->value();
|
float result = first->value() * -1.0 + second->value();
|
||||||
|
@ -96,7 +96,7 @@ namespace controller {
|
||||||
|
|
||||||
class ActionEndpoint : public Endpoint {
|
class ActionEndpoint : public Endpoint {
|
||||||
public:
|
public:
|
||||||
ActionEndpoint(const UserInputMapper::Input& id = UserInputMapper::Input(-1))
|
ActionEndpoint(const UserInputMapper::Input& id = UserInputMapper::Input::INVALID_INPUT)
|
||||||
: Endpoint(id) {
|
: Endpoint(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,9 +156,7 @@ namespace controller {
|
||||||
QString cleanActionName = QString(actionName).remove(ScriptingInterface::SANITIZE_NAME_EXPRESSION);
|
QString cleanActionName = QString(actionName).remove(ScriptingInterface::SANITIZE_NAME_EXPRESSION);
|
||||||
_actions.insert(cleanActionName, actionInput.getID());
|
_actions.insert(cleanActionName, actionInput.getID());
|
||||||
|
|
||||||
// Create the endpoints
|
// Create the action endpoints
|
||||||
// FIXME action endpoints need to accumulate values, and have them cleared at each frame
|
|
||||||
// _endpoints[actionInput] = std::make_shared<VirtualEndpoint>();
|
|
||||||
_endpoints[actionInput] = std::make_shared<ActionEndpoint>(actionInput);
|
_endpoints[actionInput] = std::make_shared<ActionEndpoint>(actionInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ const uint16_t UserInputMapper::Input::INVALID_DEVICE = INVALID_INPUT.getDevice(
|
||||||
const uint16_t UserInputMapper::Input::INVALID_CHANNEL = INVALID_INPUT.getChannel();
|
const uint16_t UserInputMapper::Input::INVALID_CHANNEL = INVALID_INPUT.getChannel();
|
||||||
const uint16_t UserInputMapper::Input::INVALID_TYPE = (uint16_t)INVALID_INPUT.getType();
|
const uint16_t UserInputMapper::Input::INVALID_TYPE = (uint16_t)INVALID_INPUT.getType();
|
||||||
const uint16_t UserInputMapper::Input::ACTIONS_DEVICE = INVALID_DEVICE - (uint16)1;
|
const uint16_t UserInputMapper::Input::ACTIONS_DEVICE = INVALID_DEVICE - (uint16)1;
|
||||||
|
const uint16_t UserInputMapper::Input::STANDARD_DEVICE = 0;
|
||||||
|
|
||||||
// Default contruct allocate the poutput size with the current hardcoded action channels
|
// Default contruct allocate the poutput size with the current hardcoded action channels
|
||||||
UserInputMapper::UserInputMapper() {
|
UserInputMapper::UserInputMapper() {
|
||||||
|
@ -38,6 +39,13 @@ bool UserInputMapper::registerDevice(uint16 deviceID, const DeviceProxy::Pointer
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UserInputMapper::registerStandardDevice(const DeviceProxy::Pointer& device) {
|
||||||
|
device->_name = "Standard"; // Just to make sure
|
||||||
|
_registeredDevices[getStandardDeviceID()] = device;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UserInputMapper::DeviceProxy::Pointer UserInputMapper::getDeviceProxy(const Input& input) {
|
UserInputMapper::DeviceProxy::Pointer UserInputMapper::getDeviceProxy(const Input& input) {
|
||||||
auto device = _registeredDevices.find(input.getDevice());
|
auto device = _registeredDevices.find(input.getDevice());
|
||||||
if (device != _registeredDevices.end()) {
|
if (device != _registeredDevices.end()) {
|
||||||
|
@ -69,10 +77,6 @@ void UserInputMapper::resetDevice(uint16 deviceID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int UserInputMapper::findDevice(QString name) const {
|
int UserInputMapper::findDevice(QString name) const {
|
||||||
if (_standardDevice && (_standardDevice->getName() == name)) {
|
|
||||||
return getStandardDeviceID();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto device : _registeredDevices) {
|
for (auto device : _registeredDevices) {
|
||||||
if (device.second->_name.split(" (")[0] == name) {
|
if (device.second->_name.split(" (")[0] == name) {
|
||||||
return device.first;
|
return device.first;
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
static const uint16 INVALID_CHANNEL;
|
static const uint16 INVALID_CHANNEL;
|
||||||
static const uint16 INVALID_TYPE;
|
static const uint16 INVALID_TYPE;
|
||||||
static const uint16 ACTIONS_DEVICE;
|
static const uint16 ACTIONS_DEVICE;
|
||||||
|
static const uint16 STANDARD_DEVICE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ public:
|
||||||
uint16 getFreeDeviceID() { return _nextFreeDeviceID++; }
|
uint16 getFreeDeviceID() { return _nextFreeDeviceID++; }
|
||||||
|
|
||||||
bool registerDevice(uint16 deviceID, const DeviceProxy::Pointer& device);
|
bool registerDevice(uint16 deviceID, const DeviceProxy::Pointer& device);
|
||||||
bool registerStandardDevice(const DeviceProxy::Pointer& device) { _standardDevice = device; _registeredDevices[getStandardDeviceID()] = device; return true; }
|
bool registerStandardDevice(const DeviceProxy::Pointer& device);
|
||||||
DeviceProxy::Pointer getDeviceProxy(const Input& input);
|
DeviceProxy::Pointer getDeviceProxy(const Input& input);
|
||||||
QString getDeviceName(uint16 deviceID);
|
QString getDeviceName(uint16 deviceID);
|
||||||
QVector<InputPair> getAvailableInputs(uint16 deviceID) { return _registeredDevices[deviceID]->getAvailabeInputs(); }
|
QVector<InputPair> getAvailableInputs(uint16 deviceID) { return _registeredDevices[deviceID]->getAvailabeInputs(); }
|
||||||
|
@ -275,8 +276,8 @@ public:
|
||||||
typedef std::map<int, DeviceProxy::Pointer> DevicesMap;
|
typedef std::map<int, DeviceProxy::Pointer> DevicesMap;
|
||||||
DevicesMap getDevices() { return _registeredDevices; }
|
DevicesMap getDevices() { return _registeredDevices; }
|
||||||
|
|
||||||
uint16 getStandardDeviceID() const { return _standardDeviceID; }
|
uint16 getStandardDeviceID() const { return Input::STANDARD_DEVICE; }
|
||||||
DeviceProxy::Pointer getStandardDevice() { return _standardDevice; }
|
DeviceProxy::Pointer getStandardDevice() { return _registeredDevices[getStandardDeviceID()]; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void actionEvent(int action, float state);
|
void actionEvent(int action, float state);
|
||||||
|
@ -284,12 +285,10 @@ signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void registerStandardDevice();
|
void registerStandardDevice();
|
||||||
uint16 _standardDeviceID = 0;
|
|
||||||
DeviceProxy::Pointer _standardDevice;
|
|
||||||
StandardControllerPointer _standardController;
|
StandardControllerPointer _standardController;
|
||||||
|
|
||||||
DevicesMap _registeredDevices;
|
DevicesMap _registeredDevices;
|
||||||
uint16 _nextFreeDeviceID = 1;
|
uint16 _nextFreeDeviceID = Input::STANDARD_DEVICE + 1;
|
||||||
|
|
||||||
typedef std::map<int, Modifiers> InputToMoModifiersMap;
|
typedef std::map<int, Modifiers> InputToMoModifiersMap;
|
||||||
InputToMoModifiersMap _inputToModifiersMap;
|
InputToMoModifiersMap _inputToModifiersMap;
|
||||||
|
|
Loading…
Reference in a new issue