mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-19 01:44:53 +00:00
partially added analog controls
This commit is contained in:
parent
57c65cadb8
commit
48d6ccd9bb
4 changed files with 73 additions and 26 deletions
|
@ -8,11 +8,28 @@
|
|||
|
||||
namespace Input {
|
||||
|
||||
enum class Axis {
|
||||
LeftX = 0,
|
||||
LeftY = 1,
|
||||
RightX = 2,
|
||||
RightY = 3,
|
||||
TriggerLeft = 4,
|
||||
TriggerRight = 5,
|
||||
|
||||
AxisMax
|
||||
};
|
||||
|
||||
struct State {
|
||||
u32 buttonsState = 0;
|
||||
u64 time = 0;
|
||||
int axes[static_cast<int>(Axis::AxisMax)] = {128, 128, 128, 128, 0, 0};
|
||||
};
|
||||
|
||||
inline int GetAxis(int min, int max, int value) {
|
||||
int v = (255 * (value - min)) / (max - min);
|
||||
return (v < 0 ? 0 : (v > 255 ? 255 : v));
|
||||
}
|
||||
|
||||
constexpr u32 MAX_STATES = 64;
|
||||
|
||||
class GameController {
|
||||
|
@ -20,11 +37,12 @@ public:
|
|||
GameController();
|
||||
virtual ~GameController() = default;
|
||||
|
||||
void readState(State* state, bool* isConnected, int* connectedCount);
|
||||
void ReadState(State* state, bool* isConnected, int* connectedCount);
|
||||
int ReadStates(State* states, int states_num, bool* isConnected, int* connectedCount);
|
||||
State getLastState() const;
|
||||
void checkButton(int id, u32 button, bool isPressed);
|
||||
void addState(const State& state);
|
||||
State GetLastState() const;
|
||||
void CheckButton(int id, u32 button, bool isPressed);
|
||||
void AddState(const State& state);
|
||||
void Axis(int id, Input::Axis axis, int value);
|
||||
|
||||
private:
|
||||
struct StateInternal {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue