mirror of
https://github.com/Patoke/4JLibs.git
synced 2026-05-30 09:34:31 +00:00
159 lines
4.8 KiB
C++
159 lines
4.8 KiB
C++
#pragma once
|
|
#include "INP_ForceFeedback.h"
|
|
#include "INP_Keyboard.h"
|
|
|
|
#define MAX_JOYPADS 4
|
|
|
|
class CInput
|
|
{
|
|
public:
|
|
struct JOYPAD
|
|
{
|
|
bool m_bIsDisabled;
|
|
bool m_bIsConnected;
|
|
bool m_bWasConnected;
|
|
bool m_bHasConnected;
|
|
|
|
unsigned int m_uiButtons;
|
|
unsigned int m_uiOldButtons;
|
|
int m_uiButtonsPressed;
|
|
int m_uiButtonsReleased;
|
|
|
|
int m_iRightThumbX;
|
|
int m_iRightThumbY;
|
|
int m_iLeftThumbX;
|
|
int m_iLeftThumbY;
|
|
|
|
DWORD m_iNormalizedRightThumbX;
|
|
DWORD m_iNormalizedRightThumbY;
|
|
DWORD m_iNormalizedLeftThumbX;
|
|
DWORD m_iNormalizedLeftThumbY;
|
|
|
|
float m_fNormalizedRightThumbX;
|
|
float m_fNormalizedRightThumbY;
|
|
float m_fNormalizedLeftThumbX;
|
|
float m_fNormalizedLeftThumbY;
|
|
|
|
unsigned char m_ucLeftTriggerState;
|
|
unsigned char m_ucRightTriggerState;
|
|
|
|
float *m_pfLeftThumbXAxisMap;
|
|
float *m_pfLeftThumbYAxisMap;
|
|
float *m_pfRightThumbXAxisMap;
|
|
float *m_pfRightThumbYAxisMap;
|
|
|
|
float m_fSensitivity;
|
|
|
|
BYTE *m_pucLeftTriggerAxisMap;
|
|
BYTE *m_pucRightTriggerAxisMap;
|
|
|
|
unsigned char m_ucMappingValue;
|
|
unsigned char m_ucInputStateIndex;
|
|
XINPUT_STATE *m_pInputStates;
|
|
};
|
|
|
|
struct JOYPADS
|
|
{
|
|
};
|
|
|
|
struct TimeInfo
|
|
{
|
|
LARGE_INTEGER m_qwStartTime;
|
|
LARGE_INTEGER m_qwTotalHoldTicks;
|
|
float m_fTotalHoldTime;
|
|
float m_fLastRepeatTime;
|
|
bool m_bInitialPressHandled;
|
|
};
|
|
|
|
CInput();
|
|
|
|
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
|
|
void Tick(void);
|
|
|
|
void SetJoypadValues(JOYPAD *pThisPad);
|
|
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax);
|
|
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
|
|
|
void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal);
|
|
unsigned int GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction);
|
|
void SetJoypadMapVal(int iPad, unsigned char ucMap);
|
|
unsigned char GetJoypadMapVal(int iPad);
|
|
|
|
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
|
|
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
|
|
|
|
bool IsPadConnected(int iPad);
|
|
void SetSigninJoypadMask(unsigned int mask);
|
|
unsigned int GetValue(int iPad, unsigned char ucAction, bool bRepeat = false);
|
|
bool IsSet(int iPad, unsigned char ucAction);
|
|
|
|
bool ButtonPressed(int iPad, unsigned char ucAction = 255); // toggled
|
|
bool ButtonReleased(int iPad, unsigned char ucAction); // toggled
|
|
bool ButtonDown(int iPad, unsigned char ucAction = 255); // button held down
|
|
|
|
float GetJoypadStick_Menu_LX(unsigned char ucPad);
|
|
float GetJoypadStick_Menu_LY(unsigned char ucPad);
|
|
float GetJoypadStick_Menu_RX(unsigned char ucPad);
|
|
float GetJoypadStick_Menu_RY(unsigned char ucPad);
|
|
unsigned char GetJoypadLTrigger_Menu(unsigned char ucPad);
|
|
unsigned char GetJoypadRTrigger_Menu(unsigned char ucPad);
|
|
|
|
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay = true);
|
|
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay = true);
|
|
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay = true);
|
|
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay = true);
|
|
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay = true);
|
|
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay = true);
|
|
|
|
void SetMenuDisplayed(int iPad, bool bVal);
|
|
|
|
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
|
|
void SetDebugSequence(const char *chSequenceA, int (*Func)(LPVOID), LPVOID lpParam);
|
|
FLOAT GetIdleSeconds(int iPad);
|
|
|
|
bool UpdateJoypads(void);
|
|
void ClearJoypadValues(JOYPAD *pThisPad);
|
|
|
|
void InitTime(void);
|
|
void GetStartTime(int iPad, int iKey);
|
|
void UpdateTime(int iPad, int iKey);
|
|
|
|
BYTE gap0[16];
|
|
|
|
JOYPAD m_Joypads[MAX_JOYPADS];
|
|
|
|
int m_iDeadzone;
|
|
int m_iMovementRangeMax;
|
|
int m_iEffectiveRange;
|
|
int m_iHalfRange;
|
|
float m_fEffectiveRange;
|
|
|
|
unsigned char m_ucInputStateC;
|
|
unsigned char m_ucJoypadMapC;
|
|
unsigned char m_ucJoypadMapActionC;
|
|
unsigned char m_ucMenuActionC;
|
|
|
|
unsigned int **m_JoypadMap;
|
|
|
|
bool m_bJoypadMapArrayIsSetup;
|
|
unsigned int m_uiSigninJoypadMask;
|
|
bool m_bIsMenuDisplayed[MAX_JOYPADS];
|
|
|
|
CForceFeedback m_ForceFeedback;
|
|
CKeyboard m_Keyboard;
|
|
|
|
float m_fTickToSeconds;
|
|
float m_fRepeatDelaySecs;
|
|
float m_fRepeatRateSecs;
|
|
|
|
TimeInfo m_Timers[MAX_JOYPADS][24];
|
|
LARGE_INTEGER m_LastActivityTime[MAX_JOYPADS];
|
|
|
|
char *m_sDebugSequenceName;
|
|
unsigned int m_uiDebugSequenceIndex;
|
|
int (*m_pDebugSequenceFn)(void *);
|
|
LPVOID m_pDebugSequenceParam;
|
|
};
|
|
|
|
// Singleton
|
|
extern CInput InternalInputManager; |