mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
4d32dde83e
The old pages UI was not intuitive and often led to questions like: * How do I bind multiple controllers to a single input?? (failure to discover) * I have a ghost input that won't go away, how do I fix this? Is this a bug? (non-intuitive UI - there are too many pages and finding out where each binding is potentially requires scrolling through 100 pages) * Potential perf issue - user binds too many by accident, or puts bindings all the way in page 99, requiring us to walk each element in the vector, wasting precious CPU cycles during an input poll. This PR removes the multiple pages, and puts everything on a single page, showing multiple binds in a tree structure. It also puts a hard limit on how many alternate bindings can be made (8 for buttons, 16 for lights), though if the user has configured more in older version they will be respected.
92 lines
1.9 KiB
C++
92 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace rawinput {
|
|
class RawInputManager;
|
|
}
|
|
|
|
class Light {
|
|
private:
|
|
std::vector<Light> alternatives;
|
|
std::string lightName;
|
|
std::string deviceIdentifier = "";
|
|
unsigned int index = 0;
|
|
bool is_temporary = false;
|
|
|
|
public:
|
|
float last_state = 0.f;
|
|
|
|
// overrides
|
|
bool override_enabled = false;
|
|
float override_state = 0.f;
|
|
|
|
explicit Light(std::string lightName) : lightName(std::move(lightName)) {};
|
|
|
|
std::string getDisplayString(rawinput::RawInputManager* manager);
|
|
|
|
inline std::vector<Light> &getAlternatives() {
|
|
return this->alternatives;
|
|
}
|
|
|
|
inline bool isSet() const {
|
|
if (this->override_enabled) {
|
|
return true;
|
|
}
|
|
if (!this->deviceIdentifier.empty()) {
|
|
return true;
|
|
}
|
|
|
|
for (auto &alternative : this->alternatives) {
|
|
if (!alternative.deviceIdentifier.empty()) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
inline const std::string &getName() const {
|
|
return this->lightName;
|
|
}
|
|
|
|
inline const std::string &getDeviceIdentifier() const {
|
|
return this->deviceIdentifier;
|
|
}
|
|
|
|
inline void setDeviceIdentifier(std::string deviceIdentifier) {
|
|
this->deviceIdentifier = std::move(deviceIdentifier);
|
|
}
|
|
|
|
inline unsigned int getIndex() const {
|
|
return this->index;
|
|
}
|
|
|
|
inline void setIndex(unsigned int index) {
|
|
this->index = index;
|
|
}
|
|
|
|
inline bool isTemporary() const {
|
|
return this->is_temporary;
|
|
}
|
|
|
|
inline void setTemporary(bool is_temporary) {
|
|
this->is_temporary = is_temporary;
|
|
}
|
|
|
|
inline bool isValid() {
|
|
// temporarily created by UI
|
|
if (isTemporary()) {
|
|
return true;
|
|
}
|
|
|
|
// nothing is set
|
|
if (getDeviceIdentifier().empty()) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
};
|