summaryrefslogtreecommitdiffstats
path: root/src/skel
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2021-01-26 00:25:47 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2021-01-26 00:25:47 +0100
commit46e63da4d8e6b4c50a663e98d150bd83e0eefb83 (patch)
treee7a03e5010280216424260da796151cc8c235e15 /src/skel
parentgarage stuff (diff)
parentMerge pull request #992 from ForeverL95/ForeverL95-patch-1 (diff)
downloadre3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.gz
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.bz2
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.lz
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.xz
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.tar.zst
re3-46e63da4d8e6b4c50a663e98d150bd83e0eefb83.zip
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/crossplatform.h6
-rw-r--r--src/skel/glfw/glfw.cpp31
-rw-r--r--src/skel/win/win.cpp12
3 files changed, 36 insertions, 13 deletions
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index bfc03913..009b17c7 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -21,7 +21,11 @@ char *_strdate(char *buf);
// As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, we only need type definitions so let's include <IntSafe.h>.
// NOTE: It's perfectly fine to include <Windows.h> here, but it can increase build size and time in *some* conditions, and maybe substantially in future if we'll use crossplatform.h more.
#ifndef _INC_WINDOWS
- #include <IntSafe.h>
+ #ifndef __MWERKS__
+ #include <IntSafe.h>
+ #else
+ #include <Windows.h>
+ #endif
#endif
#if defined RW_D3D9 || defined RWLIBS
#include "win.h"
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 3e7ba0ab..887ac6dc 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -2099,22 +2099,30 @@ void CapturePad(RwInt32 padID)
const float *axes = glfwGetJoystickAxes(glfwPad, &numAxes);
GLFWgamepadstate gamepadState;
- if (ControlsManager.m_bFirstCapture == false)
- {
+ if (ControlsManager.m_bFirstCapture == false) {
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
+ } else {
+ // In case connected gamepad doesn't have L-R trigger axes.
+ ControlsManager.m_NewState.mappedButtons[15] = ControlsManager.m_NewState.mappedButtons[16] = 0;
}
ControlsManager.m_NewState.buttons = (uint8*)buttons;
ControlsManager.m_NewState.numButtons = numButtons;
ControlsManager.m_NewState.id = glfwPad;
- ControlsManager.m_NewState.isGamepad = glfwJoystickIsGamepad(glfwPad);
+ ControlsManager.m_NewState.isGamepad = glfwGetGamepadState(glfwPad, &gamepadState);
if (ControlsManager.m_NewState.isGamepad) {
- glfwGetGamepadState(glfwPad, &gamepadState);
memcpy(&ControlsManager.m_NewState.mappedButtons, gamepadState.buttons, sizeof(gamepadState.buttons));
- ControlsManager.m_NewState.mappedButtons[15] = gamepadState.axes[4] > -0.8f;
- ControlsManager.m_NewState.mappedButtons[16] = gamepadState.axes[5] > -0.8f;
+ float lt = gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER], rt = gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER];
+
+ // glfw returns 0.0 for non-existent axises(which is bullocks) so we treat it as deadzone, and keep value of previous frame.
+ // otherwise if this axis is present, -1 = released, 1 = pressed
+ if (lt != 0.0f)
+ ControlsManager.m_NewState.mappedButtons[15] = lt > -0.8f;
+
+ if (rt != 0.0f)
+ ControlsManager.m_NewState.mappedButtons[16] = rt > -0.8f;
}
- // TODO I'm not sure how to find/what to do with L2-R2, if joystick isn't registered in SDL database.
+ // TODO? L2-R2 axes(not buttons-that's fine) on joysticks that don't have SDL gamepad mapping AREN'T handled, and I think it's impossible to do without mapping.
if (ControlsManager.m_bFirstCapture == true) {
memcpy(&ControlsManager.m_OldState, &ControlsManager.m_NewState, sizeof(ControlsManager.m_NewState));
@@ -2128,12 +2136,13 @@ void CapturePad(RwInt32 padID)
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);
// Gamepad axes are guaranteed to return 0.0f if that particular gamepad doesn't have that axis.
+ // And that's really good for sticks, because gamepads return 0.0 for them when sticks are in released state.
if ( glfwPad != -1 ) {
- leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[0] : numAxes >= 1 ? axes[0] : 0.0f;
- leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[1] : numAxes >= 2 ? axes[1] : 0.0f;
+ leftStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_X] : numAxes >= 1 ? axes[0] : 0.0f;
+ leftStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y] : numAxes >= 2 ? axes[1] : 0.0f;
- rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[2] : numAxes >= 3 ? axes[2] : 0.0f;
- rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[3] : numAxes >= 4 ? axes[3] : 0.0f;
+ rightStickPos.x = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_X] : numAxes >= 3 ? axes[2] : 0.0f;
+ rightStickPos.y = ControlsManager.m_NewState.isGamepad ? gamepadState.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y] : numAxes >= 4 ? axes[3] : 0.0f;
}
{
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 87c3846a..650f1648 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -1,4 +1,4 @@
-#if defined RW_D3D9 || defined RWLIBS
+#if defined RW_D3D9 || defined RWLIBS || defined __MWERKS__
#define _WIN32_WINDOWS 0x0500
#define WINVER 0x0500
@@ -19,6 +19,10 @@
#pragma warning( push )
#pragma warning( disable : 4005)
+#ifdef __MWERKS__
+#define MAPVK_VK_TO_CHAR (2) // this is missing from codewarrior win32 headers - but it gets used ... how?
+#endif
+
#include <ddraw.h>
#include <DShow.h>
#pragma warning( pop )
@@ -573,6 +577,9 @@ _RETEX:
}
}
+#ifdef __MWERKS__
+#pragma dont_inline on
+#endif
void _psPrintCpuInfo()
{
RwUInt32 features = _psGetCpuFeatures();
@@ -587,6 +594,9 @@ void _psPrintCpuInfo()
if ( FeaturesEx & 0x80000000 )
debug("with 3DNow");
}
+#ifdef __MWERKS__
+#pragma dont_inline off
+#endif
#endif
/*