forked from str1k3r/4JLibs-VS2012
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40d5709317 | ||
|
|
62c8f66bbe | ||
|
|
0c24c663ef | ||
|
|
842fb91443 | ||
|
|
4110db8572 | ||
|
|
88a26c82a6 | ||
|
|
26a297f1de | ||
|
|
a9df365c5c | ||
|
|
fdef90f8e7 |
@@ -32,6 +32,7 @@ CKeyboard InternalKeyboard;
|
|||||||
void C_4JInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC)
|
void C_4JInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC)
|
||||||
{
|
{
|
||||||
InternalInputManager.Initialise(iInputStateC, ucMapC, ucActionC, ucMenuActionC);
|
InternalInputManager.Initialise(iInputStateC, ucMapC, ucActionC, ucMenuActionC);
|
||||||
|
InternalKeyboard.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_4JInput::Tick(void)
|
void C_4JInput::Tick(void)
|
||||||
@@ -39,6 +40,10 @@ void C_4JInput::Tick(void)
|
|||||||
InternalInputManager.Tick();
|
InternalInputManager.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_4JInput::TickKBM(void)
|
||||||
|
{
|
||||||
|
InternalKeyboard.Tick();
|
||||||
|
}
|
||||||
void C_4JInput::SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax)
|
void C_4JInput::SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax)
|
||||||
{
|
{
|
||||||
InternalInputManager.SetDeadzoneAndMovementRange(uiDeadzone, uiMovementRangeMax);
|
InternalInputManager.SetDeadzoneAndMovementRange(uiDeadzone, uiMovementRangeMax);
|
||||||
@@ -74,6 +79,11 @@ unsigned int C_4JInput::GetValue(int iPad, unsigned char ucAction, bool bRepeat)
|
|||||||
return InternalInputManager.GetValue(iPad, ucAction, bRepeat);
|
return InternalInputManager.GetValue(iPad, ucAction, bRepeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_4JInput::MapTouchInput(int iPad, int button)
|
||||||
|
{
|
||||||
|
InternalInputManager.MapTouchInput(iPad, button);
|
||||||
|
}
|
||||||
|
|
||||||
bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction)
|
bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction)
|
||||||
{
|
{
|
||||||
return InternalInputManager.ButtonPressed(iPad, ucAction);
|
return InternalInputManager.ButtonPressed(iPad, ucAction);
|
||||||
@@ -119,6 +129,11 @@ bool C_4JInput::IsPadConnected(int iPad)
|
|||||||
return InternalInputManager.IsPadConnected(iPad);
|
return InternalInputManager.IsPadConnected(iPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsPadActive(int iPad)
|
||||||
|
{
|
||||||
|
return InternalInputManager.IsPadActive(iPad);
|
||||||
|
}
|
||||||
|
|
||||||
float C_4JInput::GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay)
|
float C_4JInput::GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay)
|
||||||
{
|
{
|
||||||
return InternalInputManager.GetJoypadStick_LX(iPad, bCheckMenuDisplay);
|
return InternalInputManager.GetJoypadStick_LX(iPad, bCheckMenuDisplay);
|
||||||
@@ -154,6 +169,171 @@ void C_4JInput::SetMenuDisplayed(int iPad, bool bVal)
|
|||||||
InternalInputManager.SetMenuDisplayed(iPad, bVal);
|
InternalInputManager.SetMenuDisplayed(iPad, bVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnKeyDown(int vkCode)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnKeyDown(vkCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnKeyUp(int vkCode)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnKeyUp(vkCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnChar(wchar_t ch)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnChar(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsKeyDown(int vkCode) const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsKeyDown(vkCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsKeyPressed(int vkCode) const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsKeyPressed(vkCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsKeyReleased(int vkCode) const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsKeyReleased(vkCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetMouseX() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetMouseX();
|
||||||
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetMouseY() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetMouseY();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsMouseLDown() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsLButtonDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsLButtonPressed() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsLButtonPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsLButtonReleased() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsLButtonReleased();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsMouseRDown() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsRButtonDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsRButtonPressed() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsRButtonPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsRButtonReleased() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsRButtonReleased();
|
||||||
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetMouseWheelDelta() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetMouseWheelDelta();
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t C_4JInput::GetLastChar() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetLastChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::HasChar() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.HasChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t C_4JInput::GetChar(int index) const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetChar(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnMouseMove(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnMouseMove(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnRawMouseDelta(int dx, int dy)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnRawMouseDelta(dx, dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnLButtonDown(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnLButtonDown(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnLButtonUp(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnLButtonUp(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnRButtonDown(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnRButtonDown(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnRButtonUp(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnRButtonUp(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnMButtonDown(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnMButtonDown(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnMButtonUp(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnMButtonUp(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::OnMouseWheel(int delta, int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.OnMouseWheel(delta, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::SetMouseCaptured(bool captured)
|
||||||
|
{
|
||||||
|
InternalKeyboard.SetMouseCaptured(captured);
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::SetWindowFocused(bool focused)
|
||||||
|
{
|
||||||
|
InternalKeyboard.SetWindowFocused(focused);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::IsMouseCaptured() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.IsMouseCaptured();
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_4JInput::SetMousePos(int x, int y)
|
||||||
|
{
|
||||||
|
InternalKeyboard.SetMousePos(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetRawMouseX() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetRawMouseX();
|
||||||
|
}
|
||||||
|
|
||||||
|
int C_4JInput::GetRawMouseY() const
|
||||||
|
{
|
||||||
|
return InternalKeyboard.GetRawMouseY();
|
||||||
|
}
|
||||||
|
|
||||||
EKeyboardResult C_4JInput::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
EKeyboardResult C_4JInput::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
||||||
C_4JInput::EKeyboardMode eMode)
|
C_4JInput::EKeyboardMode eMode)
|
||||||
{
|
{
|
||||||
@@ -165,6 +345,23 @@ void C_4JInput::GetText(uint16_t *UTF16String)
|
|||||||
InternalKeyboard.GetText(UTF16String);
|
InternalKeyboard.GetText(UTF16String);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* C_4JInput::PollControllerType(int ipad) {
|
||||||
|
const char* GamepadType = InternalInputManager.GetGamepadType(ipad);
|
||||||
|
|
||||||
|
if (!GamepadType)
|
||||||
|
return "UNKNOWN";
|
||||||
|
|
||||||
|
if (strcmp(GamepadType, "SWITCH_PRO") == 0 ||
|
||||||
|
strcmp(GamepadType, "JOYCON_PAIR") == 0 ||
|
||||||
|
strcmp(GamepadType, "JOYCON_L") == 0 ||
|
||||||
|
strcmp(GamepadType, "JOYCON_R") == 0)
|
||||||
|
{
|
||||||
|
return "SWITCH";
|
||||||
|
}
|
||||||
|
|
||||||
|
return GamepadType; // str1k3r - if not one of the switch types, return the type itself
|
||||||
|
}
|
||||||
|
|
||||||
bool C_4JInput::VerifyStrings(WCHAR **pwStringA, int iStringC, int (*Func)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID lpParam)
|
bool C_4JInput::VerifyStrings(WCHAR **pwStringA, int iStringC, int (*Func)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,231 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "INP_Keyboard.h"
|
#include "INP_Keyboard.h"
|
||||||
|
|
||||||
void CKeyboard::Tick(void) {}
|
CKeyboard::CKeyboard()
|
||||||
|
{
|
||||||
|
m_lParam = nullptr;
|
||||||
|
m_onInput = nullptr;
|
||||||
|
ZeroMemory(m_chrText, sizeof(m_chrText));
|
||||||
|
|
||||||
|
memset(m_keysPrev, 0, sizeof(m_keysPrev));
|
||||||
|
memset(m_keysCurr, 0, sizeof(m_keysCurr));
|
||||||
|
m_mouseX = m_mouseY = 0;
|
||||||
|
m_lButtonPrev = m_lButtonCurr = false;
|
||||||
|
m_rButtonPrev = m_rButtonCurr = false;
|
||||||
|
m_mButtonPrev = m_mButtonCurr = false;
|
||||||
|
m_mouseWheel = 0;
|
||||||
|
memset(m_charBuffer, 0, sizeof(m_charBuffer));
|
||||||
|
m_charCount = 0;
|
||||||
|
m_mouseCaptured = false;
|
||||||
|
m_mouseDeltaX = m_mouseDeltaY = 0;
|
||||||
|
m_windowFocused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::Init()
|
||||||
|
{
|
||||||
|
RAWINPUTDEVICE rid;
|
||||||
|
rid.usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC
|
||||||
|
rid.usUsage = 0x02; // HID_USAGE_GENERIC_MOUSE
|
||||||
|
rid.dwFlags = 0;
|
||||||
|
rid.hwndTarget = g_hWnd;
|
||||||
|
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::Tick(void)
|
||||||
|
{
|
||||||
|
memcpy(m_keysPrev, m_keysCurr, sizeof(m_keysCurr));
|
||||||
|
m_lButtonPrev = m_lButtonCurr;
|
||||||
|
m_rButtonPrev = m_rButtonCurr;
|
||||||
|
m_mButtonPrev = m_mButtonCurr;
|
||||||
|
m_mouseWheel = 0;
|
||||||
|
m_charCount = 0;
|
||||||
|
m_mouseDeltaX = m_mouseDeltaAccumX;
|
||||||
|
m_mouseDeltaY = m_mouseDeltaAccumY;
|
||||||
|
m_mouseDeltaAccumX = 0;
|
||||||
|
m_mouseDeltaAccumY = 0;
|
||||||
|
|
||||||
|
if (m_mouseCaptured && g_hWnd && m_windowFocused && g_hWnd)
|
||||||
|
{
|
||||||
|
RECT rc;
|
||||||
|
GetClientRect(g_hWnd, &rc);
|
||||||
|
POINT center;
|
||||||
|
center.x = (rc.right - rc.left) / 2;
|
||||||
|
center.y = (rc.bottom - rc.top) / 2;
|
||||||
|
ClientToScreen(g_hWnd, ¢er);
|
||||||
|
SetCursorPos(center.x, center.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnKeyDown(int vkCode)
|
||||||
|
{
|
||||||
|
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||||
|
{
|
||||||
|
m_keysCurr[vkCode] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnKeyUp(int vkCode)
|
||||||
|
{
|
||||||
|
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||||
|
{
|
||||||
|
m_keysCurr[vkCode] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnChar(wchar_t ch)
|
||||||
|
{
|
||||||
|
if (m_charCount < MAX_CHARS_PER_FRAME)
|
||||||
|
{
|
||||||
|
m_charBuffer[m_charCount++] = ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CKeyboard::IsKeyDown(int vkCode) const
|
||||||
|
{
|
||||||
|
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||||
|
return m_keysCurr[vkCode];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CKeyboard::IsKeyPressed(int vkCode) const
|
||||||
|
{
|
||||||
|
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||||
|
return m_keysCurr[vkCode] && !m_keysPrev[vkCode];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CKeyboard::IsKeyReleased(int vkCode) const
|
||||||
|
{
|
||||||
|
if (vkCode >= 0 && vkCode < MAX_KEYS)
|
||||||
|
return !m_keysCurr[vkCode] && m_keysPrev[vkCode];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnMouseMove(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnRawMouseDelta(int dx, int dy)
|
||||||
|
{
|
||||||
|
m_mouseDeltaAccumX += dx;
|
||||||
|
m_mouseDeltaAccumY += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnLButtonDown(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_lButtonCurr = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnLButtonUp(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_lButtonCurr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnRButtonDown(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_rButtonCurr = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnRButtonUp(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_rButtonCurr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnMButtonDown(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_mButtonCurr = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnMButtonUp(int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_mButtonCurr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::OnMouseWheel(int delta, int x, int y)
|
||||||
|
{
|
||||||
|
m_mouseX = x;
|
||||||
|
m_mouseY = y;
|
||||||
|
m_mouseWheel += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::SetMouseCaptured(bool grabbed)
|
||||||
|
{
|
||||||
|
if (m_mouseCaptured == grabbed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_mouseCaptured = grabbed;
|
||||||
|
if (grabbed && g_hWnd)
|
||||||
|
{
|
||||||
|
while (ShowCursor(FALSE) >= 0) {}
|
||||||
|
RECT rc;
|
||||||
|
GetClientRect(g_hWnd, &rc);
|
||||||
|
POINT topLeft = { rc.left, rc.top };
|
||||||
|
POINT bottomRight = { rc.right, rc.bottom };
|
||||||
|
ClientToScreen(g_hWnd, &topLeft);
|
||||||
|
ClientToScreen(g_hWnd, &bottomRight);
|
||||||
|
RECT clipRect = { topLeft.x, topLeft.y, bottomRight.x, bottomRight.y };
|
||||||
|
ClipCursor(&clipRect);
|
||||||
|
|
||||||
|
GetClientRect(g_hWnd, &rc);
|
||||||
|
POINT center;
|
||||||
|
center.x = (rc.right - rc.left) / 2;
|
||||||
|
center.y = (rc.bottom - rc.top) / 2;
|
||||||
|
ClientToScreen(g_hWnd, ¢er);
|
||||||
|
SetCursorPos(center.x, center.y);
|
||||||
|
|
||||||
|
m_mouseDeltaAccumX = 0;
|
||||||
|
m_mouseDeltaAccumY = 0;
|
||||||
|
}
|
||||||
|
else if (!grabbed && g_hWnd)
|
||||||
|
{
|
||||||
|
while (ShowCursor(TRUE) < 0) {}
|
||||||
|
ClipCursor(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboard::SetWindowFocused(bool focused)
|
||||||
|
{
|
||||||
|
m_windowFocused = focused;
|
||||||
|
if (focused)
|
||||||
|
{
|
||||||
|
if (m_mouseCaptured)
|
||||||
|
{
|
||||||
|
while (ShowCursor(FALSE) >= 0) {}
|
||||||
|
RECT rc;
|
||||||
|
GetClientRect(g_hWnd, &rc);
|
||||||
|
POINT center;
|
||||||
|
center.x = (rc.right - rc.left) / 2;
|
||||||
|
center.y = (rc.bottom - rc.top) / 2;
|
||||||
|
ClientToScreen(g_hWnd, ¢er);
|
||||||
|
SetCursorPos(center.x, center.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (ShowCursor(TRUE) < 0) {}
|
||||||
|
ClipCursor(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (ShowCursor(TRUE) < 0) {}
|
||||||
|
ClipCursor(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
||||||
C_4JInput::EKeyboardMode eMode)
|
C_4JInput::EKeyboardMode eMode)
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ void SeedEditBox();
|
|||||||
class CKeyboard
|
class CKeyboard
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CKeyboard();
|
||||||
|
|
||||||
enum EKeyboardProcessState
|
enum EKeyboardProcessState
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@@ -40,11 +42,83 @@ public:
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
void Tick(void);
|
void Init();
|
||||||
|
void Tick();
|
||||||
|
|
||||||
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
void OnKeyDown(int vkCode);
|
||||||
|
void OnKeyUp(int vkCode);
|
||||||
|
void OnChar(wchar_t ch);
|
||||||
|
|
||||||
|
void OnMouseMove(int x, int y);
|
||||||
|
void OnRawMouseDelta(int dx, int dy);
|
||||||
|
void OnLButtonDown(int x, int y);
|
||||||
|
void OnLButtonUp(int x, int y);
|
||||||
|
void OnRButtonDown(int x, int y);
|
||||||
|
void OnRButtonUp(int x, int y);
|
||||||
|
void OnMButtonDown(int x, int y);
|
||||||
|
void OnMButtonUp(int x, int y);
|
||||||
|
void OnMouseWheel(int delta, int x, int y);
|
||||||
|
|
||||||
|
bool IsKeyDown(int vkCode) const;
|
||||||
|
bool IsKeyPressed(int vkCode) const;
|
||||||
|
bool IsKeyReleased(int vkCode) const;
|
||||||
|
|
||||||
|
int GetMouseX() const { return m_mouseX; }
|
||||||
|
int GetMouseY() const { return m_mouseY; }
|
||||||
|
|
||||||
|
int GetRawMouseX() const { return m_mouseDeltaX; }
|
||||||
|
int GetRawMouseY() const { return m_mouseDeltaY; }
|
||||||
|
|
||||||
|
bool IsLButtonDown() const { return m_lButtonCurr; }
|
||||||
|
bool IsLButtonPressed() const { return m_lButtonCurr && !m_lButtonPrev; }
|
||||||
|
bool IsLButtonReleased() const { return !m_lButtonCurr && m_lButtonPrev; }
|
||||||
|
|
||||||
|
bool IsRButtonDown() const { return m_rButtonCurr; }
|
||||||
|
bool IsRButtonPressed() const { return m_rButtonCurr && !m_rButtonPrev; }
|
||||||
|
bool IsRButtonReleased() const { return !m_rButtonCurr && m_rButtonPrev; }
|
||||||
|
|
||||||
|
int GetMouseWheelDelta() const { return m_mouseWheel; }
|
||||||
|
|
||||||
|
wchar_t GetLastChar() const { return m_charCount > 0 ? m_charBuffer[0] : 0; }
|
||||||
|
bool HasChar() const { return m_charCount > 0; }
|
||||||
|
int GetCharCount() const { return m_charCount; }
|
||||||
|
wchar_t GetChar(int index) const { return (index >= 0 && index < m_charCount) ? m_charBuffer[index] : 0; }
|
||||||
|
|
||||||
|
void SetMouseCaptured(bool captured);
|
||||||
|
void SetWindowFocused(bool focused);
|
||||||
|
bool IsMouseCaptured() const { return m_mouseCaptured; }
|
||||||
|
|
||||||
|
void SetMousePos(int x, int y) { m_mouseX = x; m_mouseY = y; }
|
||||||
|
|
||||||
|
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
||||||
C_4JInput::EKeyboardMode eMode);
|
C_4JInput::EKeyboardMode eMode);
|
||||||
void GetText(uint16_t *UTF16String);
|
void GetText(uint16_t *UTF16String);
|
||||||
|
|
||||||
|
|
||||||
BYTE gap0[0x68];
|
BYTE gap0[0x68];
|
||||||
|
private:
|
||||||
|
static const int MAX_KEYS = 256;
|
||||||
|
static const int MAX_CHARS_PER_FRAME = 32;
|
||||||
|
|
||||||
|
bool m_keysPrev[MAX_KEYS];
|
||||||
|
bool m_keysCurr[MAX_KEYS];
|
||||||
|
|
||||||
|
int m_mouseX, m_mouseY;
|
||||||
|
bool m_lButtonPrev, m_lButtonCurr;
|
||||||
|
bool m_rButtonPrev, m_rButtonCurr;
|
||||||
|
bool m_mButtonPrev, m_mButtonCurr;
|
||||||
|
int m_mouseWheel;
|
||||||
|
|
||||||
|
wchar_t m_charBuffer[MAX_CHARS_PER_FRAME];
|
||||||
|
int m_charCount;
|
||||||
|
|
||||||
|
bool m_windowFocused;
|
||||||
|
bool m_mouseCaptured;
|
||||||
|
int m_mouseDeltaX, m_mouseDeltaY;
|
||||||
|
int m_mouseDeltaAccumX, m_mouseDeltaAccumY;
|
||||||
|
|
||||||
|
wchar_t m_chrText[128];
|
||||||
|
LPVOID m_lParam;
|
||||||
|
int (*m_onInput)(LPVOID, LPCWSTR);
|
||||||
|
|
||||||
};
|
};
|
||||||
+121
-41
@@ -26,12 +26,9 @@ SOFTWARE.
|
|||||||
#include "vendor\SDL\include\SDL3\SDL.h"
|
#include "vendor\SDL\include\SDL3\SDL.h"
|
||||||
|
|
||||||
CInput InternalInputManager;
|
CInput InternalInputManager;
|
||||||
SDL_Event event;
|
|
||||||
|
|
||||||
CInput::CInput()
|
CInput::CInput()
|
||||||
{
|
{
|
||||||
m_Keyboard = CKeyboard();
|
|
||||||
|
|
||||||
m_uiSigninJoypadMask = 0;
|
m_uiSigninJoypadMask = 0;
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
m_bIsMenuDisplayed[i] = 0;
|
m_bIsMenuDisplayed[i] = 0;
|
||||||
@@ -78,6 +75,8 @@ void CInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char uc
|
|||||||
m_Joypads[i].m_pucLeftTriggerAxisMap = &m_Joypads[i].m_ucLeftTriggerState;
|
m_Joypads[i].m_pucLeftTriggerAxisMap = &m_Joypads[i].m_ucLeftTriggerState;
|
||||||
m_Joypads[i].m_pucRightTriggerAxisMap = &m_Joypads[i].m_ucRightTriggerState;
|
m_Joypads[i].m_pucRightTriggerAxisMap = &m_Joypads[i].m_ucRightTriggerState;
|
||||||
m_Joypads[i].m_fSensitivity = 1.0f;
|
m_Joypads[i].m_fSensitivity = 1.0f;
|
||||||
|
|
||||||
|
m_iTouchInputButton[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_JoypadMap = (unsigned int **)operator new[](ucMapC * sizeof(int *));
|
m_JoypadMap = (unsigned int **)operator new[](ucMapC * sizeof(int *));
|
||||||
@@ -96,7 +95,6 @@ void CInput::Tick(void)
|
|||||||
{
|
{
|
||||||
HandleGamepadEvents();
|
HandleGamepadEvents();
|
||||||
UpdateJoypads();
|
UpdateJoypads();
|
||||||
m_Keyboard.Tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInput::SetJoypadValues(JOYPAD *pThisPad)
|
void CInput::SetJoypadValues(JOYPAD *pThisPad)
|
||||||
@@ -277,15 +275,11 @@ void CInput::SetJoypadValues(JOYPAD *pThisPad)
|
|||||||
pThisPad->m_iLeftThumbY = sThumbLY - m_iDeadzone;
|
pThisPad->m_iLeftThumbY = sThumbLY - m_iDeadzone;
|
||||||
}
|
}
|
||||||
|
|
||||||
pThisPad->m_iNormalizedLeftThumbX = pThisPad->m_iLeftThumbX / m_iEffectiveRange;
|
//str1k3r - silly piebot this was duplicated, also make these floats :3
|
||||||
pThisPad->m_iNormalizedLeftThumbY = pThisPad->m_iLeftThumbY / m_iEffectiveRange;
|
pThisPad->m_fNormalizedLeftThumbX = (float)pThisPad->m_iLeftThumbX / m_fEffectiveRange;
|
||||||
pThisPad->m_iNormalizedRightThumbX = pThisPad->m_iRightThumbX / m_iEffectiveRange;
|
pThisPad->m_fNormalizedLeftThumbY = (float)pThisPad->m_iLeftThumbY / m_fEffectiveRange;
|
||||||
pThisPad->m_iNormalizedRightThumbY = pThisPad->m_iRightThumbY / m_iEffectiveRange;
|
pThisPad->m_fNormalizedRightThumbX = (float)pThisPad->m_iRightThumbX / m_fEffectiveRange;
|
||||||
|
pThisPad->m_fNormalizedRightThumbY = (float)pThisPad->m_iRightThumbY / m_fEffectiveRange;
|
||||||
pThisPad->m_fNormalizedLeftThumbX = pThisPad->m_iLeftThumbX / m_fEffectiveRange;
|
|
||||||
pThisPad->m_fNormalizedLeftThumbY = pThisPad->m_iLeftThumbY / m_fEffectiveRange;
|
|
||||||
pThisPad->m_fNormalizedRightThumbX = pThisPad->m_iRightThumbX / m_fEffectiveRange;
|
|
||||||
pThisPad->m_fNormalizedRightThumbY = pThisPad->m_iRightThumbY / m_fEffectiveRange;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInput::SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax)
|
void CInput::SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax)
|
||||||
@@ -317,6 +311,16 @@ unsigned int CInput::GetGameJoypadMaps(unsigned char ucMap, unsigned char ucActi
|
|||||||
return m_JoypadMap[ucMap][ucAction];
|
return m_JoypadMap[ucMap][ucAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* CInput::GetGamepadType(int iPad)
|
||||||
|
{
|
||||||
|
if (!m_Joypads[iPad].m_pGamepad)
|
||||||
|
{
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
|
return GamepadTypeName(SDL_GetGamepadType(m_Joypads[iPad].m_pGamepad));
|
||||||
|
}
|
||||||
|
|
||||||
void CInput::SetJoypadMapVal(int iPad, unsigned char ucMap)
|
void CInput::SetJoypadMapVal(int iPad, unsigned char ucMap)
|
||||||
{
|
{
|
||||||
m_bJoypadMapArrayIsSetup = true;
|
m_bJoypadMapArrayIsSetup = true;
|
||||||
@@ -328,6 +332,11 @@ unsigned char CInput::GetJoypadMapVal(int iPad)
|
|||||||
return m_Joypads[iPad].m_ucMappingValue;
|
return m_Joypads[iPad].m_ucMappingValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInput::MapTouchInput(int iPad, int button)
|
||||||
|
{
|
||||||
|
m_iTouchInputButton[iPad] |= button;
|
||||||
|
}
|
||||||
|
|
||||||
void CInput::SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo)
|
void CInput::SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo)
|
||||||
{
|
{
|
||||||
float *pfTo = nullptr;
|
float *pfTo = nullptr;
|
||||||
@@ -395,6 +404,11 @@ bool CInput::IsPadConnected(int iPad)
|
|||||||
return m_Joypads[iPad].m_bIsConnected;
|
return m_Joypads[iPad].m_bIsConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CInput::IsPadActive(int iPad)
|
||||||
|
{
|
||||||
|
return m_Joypads[iPad].m_bControllerActive;
|
||||||
|
}
|
||||||
|
|
||||||
void CInput::SetSigninJoypadMask(unsigned int mask)
|
void CInput::SetSigninJoypadMask(unsigned int mask)
|
||||||
{
|
{
|
||||||
m_uiSigninJoypadMask = mask;
|
m_uiSigninJoypadMask = mask;
|
||||||
@@ -615,21 +629,25 @@ FLOAT CInput::GetIdleSeconds(int iPad)
|
|||||||
|
|
||||||
void CInput::HandleGamepadEvents()
|
void CInput::HandleGamepadEvents()
|
||||||
{
|
{
|
||||||
while (SDL_PollEvent(&event))
|
//str1k3r - writing/reading a global can make stuff stutter alot
|
||||||
|
SDL_Event localEvent;
|
||||||
|
|
||||||
|
while (SDL_PollEvent(&localEvent))
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (localEvent.type)
|
||||||
{
|
{
|
||||||
case SDL_EVENT_GAMEPAD_ADDED:
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
for (int i = 0; i < MAX_JOYPADS; i++)
|
for (int i = 0; i < MAX_JOYPADS; i++)
|
||||||
{
|
{
|
||||||
if (!m_Joypads[i].m_pGamepad)
|
if (!m_Joypads[i].m_pGamepad)
|
||||||
{
|
{
|
||||||
SDL_Gamepad *pad = SDL_OpenGamepad(event.gdevice.which);
|
SDL_Gamepad *pad = SDL_OpenGamepad(localEvent.gdevice.which);
|
||||||
|
|
||||||
if (pad)
|
if (pad)
|
||||||
{
|
{
|
||||||
SDL_SetGamepadPlayerIndex(pad, i);
|
SDL_SetGamepadPlayerIndex(pad, i);
|
||||||
m_Joypads[i].m_pGamepad = pad;
|
m_Joypads[i].m_pGamepad = pad;
|
||||||
|
m_Joypads[i].m_bIsConnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -637,23 +655,73 @@ void CInput::HandleGamepadEvents()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
for (int i = 0; i < MAX_JOYPADS; i++)
|
{
|
||||||
{
|
int removedIndex = -1;
|
||||||
if (m_Joypads[i].m_pGamepad &&
|
|
||||||
SDL_GetGamepadID(m_Joypads[i].m_pGamepad) == event.gdevice.which)
|
|
||||||
{
|
|
||||||
SDL_CloseGamepad(m_Joypads[i].m_pGamepad);
|
|
||||||
m_Joypads[i].m_pGamepad = nullptr;
|
|
||||||
m_Joypads[i].m_bIsConnected = false;
|
|
||||||
|
|
||||||
break;
|
for (int i = 0; i < MAX_JOYPADS; i++)
|
||||||
|
{
|
||||||
|
if (m_Joypads[i].m_pGamepad &&
|
||||||
|
SDL_GetGamepadID(m_Joypads[i].m_pGamepad) == localEvent.gdevice.which)
|
||||||
|
{
|
||||||
|
SDL_CloseGamepad(m_Joypads[i].m_pGamepad);
|
||||||
|
m_Joypads[i].m_pGamepad = nullptr;
|
||||||
|
m_Joypads[i].m_bIsConnected = false;
|
||||||
|
removedIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (removedIndex == 0)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < MAX_JOYPADS; i++)
|
||||||
|
{
|
||||||
|
//str1k3r - since we used to never set m_bIsConnected when a gamepad was added this never ran
|
||||||
|
if (m_Joypads[i].m_bIsConnected && m_Joypads[i].m_pGamepad)
|
||||||
|
{
|
||||||
|
ShiftGamepadData(0, i);
|
||||||
|
SDL_SetGamepadPlayerIndex(m_Joypads[0].m_pGamepad, 0);
|
||||||
|
ClearGamepadSlot(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInput::ShiftGamepadData(int destIndex, int srcIndex)
|
||||||
|
{
|
||||||
|
m_Joypads[destIndex] = m_Joypads[srcIndex];
|
||||||
|
|
||||||
|
m_Joypads[destIndex].m_pfLeftThumbXAxisMap = &m_Joypads[destIndex].m_fNormalizedLeftThumbX;
|
||||||
|
m_Joypads[destIndex].m_pfLeftThumbYAxisMap = &m_Joypads[destIndex].m_fNormalizedLeftThumbY;
|
||||||
|
m_Joypads[destIndex].m_pfRightThumbXAxisMap = &m_Joypads[destIndex].m_fNormalizedRightThumbX;
|
||||||
|
m_Joypads[destIndex].m_pfRightThumbYAxisMap = &m_Joypads[destIndex].m_fNormalizedRightThumbY;
|
||||||
|
m_Joypads[destIndex].m_pucLeftTriggerAxisMap = &m_Joypads[destIndex].m_ucLeftTriggerState;
|
||||||
|
m_Joypads[destIndex].m_pucRightTriggerAxisMap = &m_Joypads[destIndex].m_ucRightTriggerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInput::ClearGamepadSlot(int index)
|
||||||
|
{
|
||||||
|
m_Joypads[index].m_pGamepad = nullptr;
|
||||||
|
m_Joypads[index].m_bIsConnected = false;
|
||||||
|
m_Joypads[index].m_uiButtons = 0;
|
||||||
|
m_Joypads[index].m_ucInputStateIndex = -1;
|
||||||
|
m_Joypads[index].m_ucLeftTriggerState = 0;
|
||||||
|
m_Joypads[index].m_ucRightTriggerState = 0;
|
||||||
|
m_Joypads[index].m_iRightThumbX = 0;
|
||||||
|
m_Joypads[index].m_iRightThumbY = 0;
|
||||||
|
|
||||||
|
m_Joypads[index].m_pfLeftThumbXAxisMap = &m_Joypads[index].m_fNormalizedLeftThumbX;
|
||||||
|
m_Joypads[index].m_pfLeftThumbYAxisMap = &m_Joypads[index].m_fNormalizedLeftThumbY;
|
||||||
|
m_Joypads[index].m_pfRightThumbXAxisMap = &m_Joypads[index].m_fNormalizedRightThumbX;
|
||||||
|
m_Joypads[index].m_pfRightThumbYAxisMap = &m_Joypads[index].m_fNormalizedRightThumbY;
|
||||||
|
m_Joypads[index].m_pucLeftTriggerAxisMap = &m_Joypads[index].m_ucLeftTriggerState;
|
||||||
|
m_Joypads[index].m_pucRightTriggerAxisMap = &m_Joypads[index].m_ucRightTriggerState;
|
||||||
|
}
|
||||||
|
|
||||||
bool CInput::UpdateJoypads()
|
bool CInput::UpdateJoypads()
|
||||||
{
|
{
|
||||||
assert(m_bJoypadMapArrayIsSetup);
|
assert(m_bJoypadMapArrayIsSetup);
|
||||||
@@ -697,27 +765,39 @@ bool CInput::UpdateJoypads()
|
|||||||
if (pThisPad->m_bIsConnected)
|
if (pThisPad->m_bIsConnected)
|
||||||
{
|
{
|
||||||
SetJoypadValues(pThisPad);
|
SetJoypadValues(pThisPad);
|
||||||
|
|
||||||
pThisPad->m_uiButtonsPressed = ~pThisPad->m_uiOldButtons & pThisPad->m_uiButtons;
|
|
||||||
pThisPad->m_uiButtonsReleased = ~pThisPad->m_uiButtons & pThisPad->m_uiOldButtons;
|
|
||||||
|
|
||||||
for (int bit = 0; bit < 24; ++bit)
|
|
||||||
{
|
|
||||||
if ((pThisPad->m_uiButtonsPressed & (1 << bit)) != 0)
|
|
||||||
{
|
|
||||||
GetStartTime(i, bit);
|
|
||||||
}
|
|
||||||
else if ((pThisPad->m_uiButtons & (1 << bit)) != 0)
|
|
||||||
{
|
|
||||||
UpdateTime(i, bit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (pThisPad->m_bWasConnected)
|
else if (pThisPad->m_bWasConnected)
|
||||||
{
|
{
|
||||||
ClearJoypadValues(pThisPad);
|
ClearJoypadValues(pThisPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_iTouchInputButton[i])
|
||||||
|
{
|
||||||
|
pThisPad->m_uiButtons |= m_iTouchInputButton[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
m_iTouchInputButton[i] = 0;
|
||||||
|
|
||||||
|
pThisPad->m_uiButtonsPressed = ~pThisPad->m_uiOldButtons & pThisPad->m_uiButtons;
|
||||||
|
pThisPad->m_uiButtonsReleased = ~pThisPad->m_uiButtons & pThisPad->m_uiOldButtons;
|
||||||
|
|
||||||
|
for (int bit = 0; bit < 24; ++bit)
|
||||||
|
{
|
||||||
|
if ((pThisPad->m_uiButtonsPressed & (1 << bit)) != 0)
|
||||||
|
{
|
||||||
|
GetStartTime(i, bit);
|
||||||
|
}
|
||||||
|
else if ((pThisPad->m_uiButtons & (1 << bit)) != 0)
|
||||||
|
{
|
||||||
|
UpdateTime(i, bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pThisPad->m_uiButtonsPressed)
|
||||||
|
pThisPad->m_bControllerActive = true;
|
||||||
|
else
|
||||||
|
pThisPad->m_bControllerActive = false;
|
||||||
|
|
||||||
if (m_pDebugSequenceFn && (pThisPad->m_uiButtonsPressed & (_360_JOY_BUTTON_A | _360_JOY_BUTTON_B | _360_JOY_BUTTON_X | _360_JOY_BUTTON_Y |
|
if (m_pDebugSequenceFn && (pThisPad->m_uiButtonsPressed & (_360_JOY_BUTTON_A | _360_JOY_BUTTON_B | _360_JOY_BUTTON_X | _360_JOY_BUTTON_Y |
|
||||||
_360_JOY_BUTTON_RB | _360_JOY_BUTTON_LB)) != 0)
|
_360_JOY_BUTTON_RB | _360_JOY_BUTTON_LB)) != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,26 @@ SOFTWARE.
|
|||||||
|
|
||||||
class CInput
|
class CInput
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
const char* GamepadTypeName(SDL_GamepadType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case SDL_GAMEPAD_TYPE_UNKNOWN: return "UNKNOWN";
|
||||||
|
case SDL_GAMEPAD_TYPE_GAMECUBE: return "GAMECUBE";
|
||||||
|
case SDL_GAMEPAD_TYPE_STANDARD: return "STANDARD";
|
||||||
|
case SDL_GAMEPAD_TYPE_XBOX360: return "XBOX360";
|
||||||
|
case SDL_GAMEPAD_TYPE_XBOXONE: return "XBOXONE";
|
||||||
|
case SDL_GAMEPAD_TYPE_PS3: return "PS3";
|
||||||
|
case SDL_GAMEPAD_TYPE_PS4: return "PS4";
|
||||||
|
case SDL_GAMEPAD_TYPE_PS5: return "PS5";
|
||||||
|
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO: return "SWITCH_PRO";
|
||||||
|
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT: return "JOYCON_L";
|
||||||
|
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT: return "JOYCON_R";
|
||||||
|
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR: return "JOYCON_PAIR";
|
||||||
|
default: return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
struct JOYPAD
|
struct JOYPAD
|
||||||
{
|
{
|
||||||
@@ -38,6 +58,7 @@ public:
|
|||||||
bool m_bIsConnected;
|
bool m_bIsConnected;
|
||||||
bool m_bWasConnected;
|
bool m_bWasConnected;
|
||||||
bool m_bHasConnected;
|
bool m_bHasConnected;
|
||||||
|
bool m_bControllerActive;
|
||||||
|
|
||||||
unsigned int m_uiButtons;
|
unsigned int m_uiButtons;
|
||||||
unsigned int m_uiOldButtons;
|
unsigned int m_uiOldButtons;
|
||||||
@@ -101,13 +122,16 @@ public:
|
|||||||
|
|
||||||
void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal);
|
void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal);
|
||||||
unsigned int GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction);
|
unsigned int GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction);
|
||||||
|
const char* GetGamepadType(int iPad);
|
||||||
void SetJoypadMapVal(int iPad, unsigned char ucMap);
|
void SetJoypadMapVal(int iPad, unsigned char ucMap);
|
||||||
unsigned char GetJoypadMapVal(int iPad);
|
unsigned char GetJoypadMapVal(int iPad);
|
||||||
|
|
||||||
|
void MapTouchInput(int iPad, int button);
|
||||||
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
|
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
|
||||||
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
|
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
|
||||||
|
|
||||||
bool IsPadConnected(int iPad);
|
bool IsPadConnected(int iPad);
|
||||||
|
bool IsPadActive(int iPad);
|
||||||
void SetSigninJoypadMask(unsigned int mask);
|
void SetSigninJoypadMask(unsigned int mask);
|
||||||
unsigned int GetValue(int iPad, unsigned char ucAction, bool bRepeat = false);
|
unsigned int GetValue(int iPad, unsigned char ucAction, bool bRepeat = false);
|
||||||
bool IsSet(int iPad, unsigned char ucAction);
|
bool IsSet(int iPad, unsigned char ucAction);
|
||||||
@@ -137,6 +161,8 @@ public:
|
|||||||
FLOAT GetIdleSeconds(int iPad);
|
FLOAT GetIdleSeconds(int iPad);
|
||||||
|
|
||||||
void HandleGamepadEvents();
|
void HandleGamepadEvents();
|
||||||
|
void ShiftGamepadData(int destIndex, int srcIndex);
|
||||||
|
void ClearGamepadSlot(int index);
|
||||||
bool UpdateJoypads(void);
|
bool UpdateJoypads(void);
|
||||||
void ClearJoypadValues(JOYPAD *pThisPad);
|
void ClearJoypadValues(JOYPAD *pThisPad);
|
||||||
|
|
||||||
@@ -179,6 +205,8 @@ public:
|
|||||||
unsigned int m_uiDebugSequenceIndex;
|
unsigned int m_uiDebugSequenceIndex;
|
||||||
int (*m_pDebugSequenceFn)(void *);
|
int (*m_pDebugSequenceFn)(void *);
|
||||||
LPVOID m_pDebugSequenceParam;
|
LPVOID m_pDebugSequenceParam;
|
||||||
|
|
||||||
|
unsigned int m_iTouchInputButton[MAX_JOYPADS];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
|
|||||||
@@ -160,10 +160,6 @@
|
|||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
<PreLinkEvent>
|
|
||||||
<Command>
|
|
||||||
</Command>
|
|
||||||
</PreLinkEvent>
|
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
<Command>./Windows64/shaders/build.bat</Command>
|
<Command>./Windows64/shaders/build.bat</Command>
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
@@ -208,6 +204,9 @@
|
|||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>./Windows64/shaders/build.bat</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public:
|
|||||||
|
|
||||||
void Initialise( int iInputStateC, unsigned char ucMapC,unsigned char ucActionC, unsigned char ucMenuActionC );
|
void Initialise( int iInputStateC, unsigned char ucMapC,unsigned char ucActionC, unsigned char ucMenuActionC );
|
||||||
void Tick(void);
|
void Tick(void);
|
||||||
|
void TickKBM(void);
|
||||||
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax );
|
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax );
|
||||||
void SetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction,unsigned int uiActionVal);
|
void SetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction,unsigned int uiActionVal);
|
||||||
unsigned int GetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction);
|
unsigned int GetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction);
|
||||||
@@ -108,6 +109,7 @@ public:
|
|||||||
unsigned char GetJoypadMapVal(int iPad);
|
unsigned char GetJoypadMapVal(int iPad);
|
||||||
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
||||||
unsigned int GetValue(int iPad,unsigned char ucAction, bool bRepeat=false);
|
unsigned int GetValue(int iPad,unsigned char ucAction, bool bRepeat=false);
|
||||||
|
void MapTouchInput(int iPad, int button);
|
||||||
bool ButtonPressed(int iPad,unsigned char ucAction=255); // toggled
|
bool ButtonPressed(int iPad,unsigned char ucAction=255); // toggled
|
||||||
bool ButtonReleased(int iPad,unsigned char ucAction); //toggled
|
bool ButtonReleased(int iPad,unsigned char ucAction); //toggled
|
||||||
bool ButtonDown(int iPad,unsigned char ucAction=255); // button held down
|
bool ButtonDown(int iPad,unsigned char ucAction=255); // button held down
|
||||||
@@ -118,8 +120,8 @@ public:
|
|||||||
void SetDebugSequence( const char *chSequenceA,int( *Func)(LPVOID),LPVOID lpParam );
|
void SetDebugSequence( const char *chSequenceA,int( *Func)(LPVOID),LPVOID lpParam );
|
||||||
FLOAT GetIdleSeconds(int iPad);
|
FLOAT GetIdleSeconds(int iPad);
|
||||||
bool IsPadConnected(int iPad);
|
bool IsPadConnected(int iPad);
|
||||||
|
bool IsPadActive(int iPad);
|
||||||
bool IsCircleCrossSwapped();
|
bool IsCircleCrossSwapped();
|
||||||
|
|
||||||
// In-Game values which may have been remapped due to Southpaw, swap triggers, etc
|
// In-Game values which may have been remapped due to Southpaw, swap triggers, etc
|
||||||
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true);
|
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true);
|
||||||
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true);
|
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true);
|
||||||
@@ -130,11 +132,57 @@ public:
|
|||||||
|
|
||||||
void SetMenuDisplayed(int iPad, bool bVal);
|
void SetMenuDisplayed(int iPad, bool bVal);
|
||||||
|
|
||||||
|
void OnKeyDown(int vkCode);
|
||||||
|
void OnKeyUp(int vkCode);
|
||||||
|
void OnChar(wchar_t ch);
|
||||||
|
|
||||||
|
void OnMouseMove(int x, int y);
|
||||||
|
void OnRawMouseDelta(int dx, int dy);
|
||||||
|
void OnLButtonDown(int x, int y);
|
||||||
|
void OnLButtonUp(int x, int y);
|
||||||
|
void OnRButtonDown(int x, int y);
|
||||||
|
void OnRButtonUp(int x, int y);
|
||||||
|
void OnMButtonDown(int x, int y);
|
||||||
|
void OnMButtonUp(int x, int y);
|
||||||
|
void OnMouseWheel(int delta, int x, int y);
|
||||||
|
|
||||||
|
bool IsKeyDown(int vkCode) const;
|
||||||
|
bool IsKeyPressed(int vkCode) const;
|
||||||
|
bool IsKeyReleased(int vkCode) const;
|
||||||
|
|
||||||
|
int GetMouseX() const;
|
||||||
|
int GetMouseY() const;
|
||||||
|
|
||||||
|
// PIEBOT: Used to be IsLButtonDown, changed so it doesnt conflict with windowx.h
|
||||||
|
bool IsMouseLDown() const;
|
||||||
|
bool IsLButtonPressed() const;
|
||||||
|
bool IsLButtonReleased() const;
|
||||||
|
|
||||||
|
bool IsMouseRDown() const;
|
||||||
|
bool IsRButtonPressed() const;
|
||||||
|
bool IsRButtonReleased() const;
|
||||||
|
|
||||||
|
int GetMouseWheelDelta() const;
|
||||||
|
|
||||||
|
wchar_t GetLastChar() const;
|
||||||
|
bool HasChar() const;
|
||||||
|
int GetCharCount() const;
|
||||||
|
wchar_t GetChar(int index) const;
|
||||||
|
|
||||||
|
void SetMouseCaptured(bool captured);
|
||||||
|
void SetWindowFocused(bool focused);
|
||||||
|
bool IsMouseCaptured() const;
|
||||||
|
|
||||||
|
void SetMousePos(int x, int y);
|
||||||
|
|
||||||
|
int GetRawMouseX() const;
|
||||||
|
int GetRawMouseY() const;
|
||||||
// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
|
// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
|
||||||
// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
|
// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
|
||||||
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode);
|
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode);
|
||||||
void DestroyKeyboard();
|
void DestroyKeyboard();
|
||||||
void GetText(uint16_t *UTF16String);
|
void GetText(uint16_t *UTF16String);
|
||||||
|
const char* PollControllerType(int ipad);
|
||||||
|
|
||||||
void SetLostInputControlCallback(void( *Func)(LPVOID, bool),LPVOID lpParam);
|
void SetLostInputControlCallback(void( *Func)(LPVOID, bool),LPVOID lpParam);
|
||||||
|
|
||||||
@@ -165,4 +213,5 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
extern C_4JInput InputManager;
|
extern C_4JInput InputManager;
|
||||||
|
extern HWND g_hWnd;
|
||||||
Reference in New Issue
Block a user