summaryrefslogtreecommitdiffstats
path: root/src/skel
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-10-11 00:18:08 +0200
committerSergeanur <s.anureev@yandex.ua>2020-10-11 00:18:08 +0200
commitf1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98 (patch)
treebe72177b9fd7d8837042b4397a79ffc83fb89bdd /src/skel
parentbug fix (diff)
parentMerge pull request #745 from Tatsh/vscode (diff)
downloadre3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.tar
re3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.tar.gz
re3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.tar.bz2
re3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.tar.lz
re3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.tar.xz
re3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.tar.zst
re3-f1bb09826d0d1e6a1f5ac92ad97c25ecf2843f98.zip
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/crossplatform.cpp10
-rw-r--r--src/skel/crossplatform.h4
-rw-r--r--src/skel/glfw/glfw.cpp89
-rw-r--r--src/skel/win/win.cpp2
4 files changed, 65 insertions, 40 deletions
diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp
index 6188992d..452ad9fa 100644
--- a/src/skel/crossplatform.cpp
+++ b/src/skel/crossplatform.cpp
@@ -84,6 +84,16 @@ void FileTimeToSystemTime(time_t* writeTime, SYSTEMTIME* out) {
}
#endif
+// Because wchar length differs between platforms.
+wchar*
+AllocUnicode(const char* src)
+{
+ wchar *dst = (wchar*)malloc(strlen(src)*2 + 2);
+ wchar *i = dst;
+ while((*i++ = (unsigned char)*src++) != '\0');
+ return dst;
+}
+
// Funcs/features from Windows that we need on other platforms
#ifndef _WIN32
char *strupr(char *s) {
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index 69600385..1635781b 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -67,6 +67,10 @@ void CapturePad(RwInt32 padID);
void joysChangeCB(int jid, int event);
#endif
+#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
+extern char gSelectedJoystickName[128];
+#endif
+
enum eGameState
{
GS_START_UP = 0,
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 0f520cad..08e5c021 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -41,7 +41,6 @@
#include "AnimViewer.h"
#include "Font.h"
-
#define MAX_SUBSYSTEMS (16)
@@ -92,6 +91,11 @@ long _dwOperatingSystemVersion;
#include <signal.h>
#include <errno.h>
#endif
+
+#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
+char gSelectedJoystickName[128] = "";
+#endif
+
/*
*****************************************************************************
*/
@@ -429,6 +433,10 @@ psInitialize(void)
_dwOperatingSystemVersion = OS_WIN95;
}
}
+#else
+ _dwOperatingSystemVersion = OS_WINXP; // To fool other classes
+#endif
+
#ifndef PS2_MENU
@@ -438,6 +446,8 @@ psInitialize(void)
#endif
+
+#ifdef _WIN32
MEMORYSTATUS memstats;
GlobalMemoryStatus(&memstats);
@@ -445,17 +455,22 @@ psInitialize(void)
debug("Physical memory size %u\n", memstats.dwTotalPhys);
debug("Available physical memory %u\n", memstats.dwAvailPhys);
+#elif defined (__APPLE__)
+ uint64_t size = 0;
+ uint64_t page_size = 0;
+ size_t uint64_len = sizeof(uint64_t);
+ size_t ull_len = sizeof(unsigned long long);
+ sysctl((int[]){CTL_HW, HW_PAGESIZE}, 2, &page_size, &ull_len, NULL, 0);
+ sysctl((int[]){CTL_HW, HW_MEMSIZE}, 2, &size, &uint64_len, NULL, 0);
+ vm_statistics_data_t vm_stat;
+ mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
+ host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vm_stat, &count);
+ _dwMemAvailPhys = (uint64_t)(vm_stat.free_count * page_size);
+ debug("Physical memory size %llu\n", _dwMemAvailPhys);
+ debug("Available physical memory %llu\n", size);
#else
-
-#ifndef PS2_MENU
-
-#ifdef GTA3_1_1_PATCH
- FrontEndMenuManager.LoadSettings();
-#endif
-
-#endif
#ifndef __APPLE__
- struct sysinfo systemInfo;
+ struct sysinfo systemInfo;
sysinfo(&systemInfo);
_dwMemAvailPhys = systemInfo.freeram;
debug("Physical memory size %u\n", systemInfo.totalram);
@@ -476,7 +491,8 @@ psInitialize(void)
#endif
_dwOperatingSystemVersion = OS_WINXP; // To fool other classes
#endif
- TheText.Unload();
+
+ TheText.Unload();
return TRUE;
}
@@ -843,35 +859,26 @@ void joysChangeCB(int jid, int event);
bool IsThisJoystickBlacklisted(int i)
{
+#ifndef DONT_TRUST_RECOGNIZED_JOYSTICKS
+ return false;
+#else
if (glfwJoystickIsGamepad(i))
return false;
const char* joyname = glfwGetJoystickName(i);
- // this is just a keyboard and mouse
- // Microsoft Microsoft® 2.4GHz Transceiver v8.0 Consumer Control
- // Microsoft Microsoft® 2.4GHz Transceiver v8.0 System Control
- if (strstr(joyname, "2.4GHz Transceiver"))
- return true;
- // COMPANY USB Device System Control
- // COMPANY USB Device Consumer Control
- if (strstr(joyname, "COMPANY USB"))
- return true;
- // i.e. Synaptics TM2438-005
- if (strstr(joyname, "Synaptics "))
- return true;
- // i.e. ELAN Touchscreen
- if (strstr(joyname, "ELAN "))
- return true;
- // i.e. Primax Electronics, Ltd HP Wireless Keyboard Mouse Kit Consumer Control
- if (strstr(joyname, "Keyboard"))
- return true;
+ if (strncmp(joyname, gSelectedJoystickName, strlen(gSelectedJoystickName)) == 0)
+ return false;
- return false;
+ return true;
+#endif
}
void _InputInitialiseJoys()
{
+ PSGLOBAL(joy1id) = -1;
+ PSGLOBAL(joy2id) = -1;
+
for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) {
if (glfwJoystickPresent(i) && !IsThisJoystickBlacklisted(i)) {
if (PSGLOBAL(joy1id) == -1)
@@ -886,6 +893,9 @@ void _InputInitialiseJoys()
if (PSGLOBAL(joy1id) != -1) {
int count;
glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
+#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
+ strcpy(gSelectedJoystickName, glfwGetJoystickName(PSGLOBAL(joy1id)));
+#endif
ControlsManager.InitDefaultControlConfigJoyPad(count);
}
}
@@ -2104,18 +2114,19 @@ void CapturePad(RwInt32 padID)
void joysChangeCB(int jid, int event)
{
- if (event == GLFW_CONNECTED && !IsThisJoystickBlacklisted(jid))
- {
- if (PSGLOBAL(joy1id) == -1)
+ if (event == GLFW_CONNECTED && !IsThisJoystickBlacklisted(jid)) {
+ if (PSGLOBAL(joy1id) == -1) {
PSGLOBAL(joy1id) = jid;
- else if (PSGLOBAL(joy2id) == -1)
+#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS
+ strcpy(gSelectedJoystickName, glfwGetJoystickName(jid));
+#endif
+ } else if (PSGLOBAL(joy2id) == -1)
PSGLOBAL(joy2id) = jid;
- }
- else if (event == GLFW_DISCONNECTED)
- {
- if (PSGLOBAL(joy1id) == jid)
+
+ } else if (event == GLFW_DISCONNECTED) {
+ if (PSGLOBAL(joy1id) == jid) {
PSGLOBAL(joy1id) = -1;
- else if (PSGLOBAL(joy2id) == jid)
+ } else if (PSGLOBAL(joy2id) == jid)
PSGLOBAL(joy2id) = -1;
}
}
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index b98d5710..1d1037af 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -3414,4 +3414,4 @@ int strncasecmp(const char *str1, const char *str2, size_t len)
return _strnicmp(str1, str2, len);
}
#endif
-#endif \ No newline at end of file
+#endif