mirror of https://github.com/PCSX2/pcsx2.git
lilypad: make it compile on linux
* Ifdef windows code * Add a windows crap to linux crap translation layer
This commit is contained in:
parent
3661f51bcb
commit
156f66ef62
|
@ -33,12 +33,14 @@ void EnumDevices(int hideDXXinput) {
|
|||
InputDeviceManager *oldDm = dm;
|
||||
dm = new InputDeviceManager();
|
||||
|
||||
#ifdef _MSC_VER
|
||||
EnumHookDevices();
|
||||
EnumWindowsMessagingDevices();
|
||||
EnumRawInputDevices();
|
||||
EnumDualShock3s();
|
||||
EnumXInputDevices();
|
||||
EnumDirectInputDevices(hideDXXinput);
|
||||
#endif
|
||||
|
||||
dm->CopyBindings(oldDm->numDevices, oldDm->devices);
|
||||
|
||||
|
|
|
@ -20,6 +20,67 @@
|
|||
// dll size by over 100k while avoiding any dependencies on updated CRT dlls.
|
||||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
// Seriously why there is no standard
|
||||
#include "stdint.h"
|
||||
typedef uint32_t DWORD;
|
||||
typedef uint16_t USHORT;
|
||||
typedef int64_t __int64;
|
||||
|
||||
#define MAX_PATH (256) // random value
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#define VK_SHIFT XK_Shift_L
|
||||
#define VK_LSHIFT XK_Shift_L
|
||||
#define VK_RSHIFT XK_Shift_R
|
||||
#define VK_LMENU XK_Menu
|
||||
#define VK_RMENU XK_Menu
|
||||
#define VK_MENU XK_Menu
|
||||
#define VK_CONTROL XK_Control_L
|
||||
#define VK_TAB XK_Tab
|
||||
#define VK_ESCAPE XK_Escape
|
||||
#define VK_F4 XK_F4
|
||||
|
||||
#include <cwchar>
|
||||
#include <cstdarg>
|
||||
|
||||
template <typename Array>
|
||||
void wsprintfW(Array& buf, const wchar_t *format, ...) {
|
||||
va_list a;
|
||||
va_start(a, format);
|
||||
|
||||
vswprintf(buf, sizeof(buf)/sizeof(buf[0]), format, a);
|
||||
|
||||
va_end(a);
|
||||
}
|
||||
|
||||
template <typename Array>
|
||||
void wsprintf(Array& buf, const wchar_t *format, ...) {
|
||||
va_list a;
|
||||
va_start(a, format);
|
||||
|
||||
vswprintf(buf, sizeof(buf)/sizeof(buf[0]), format, a);
|
||||
|
||||
va_end(a);
|
||||
}
|
||||
|
||||
static inline int wcsicmp(const wchar_t* w1, const wchar_t* w2) {
|
||||
// I didn't find a way to put ignore case ...
|
||||
return wcscmp(w1, w2);
|
||||
}
|
||||
|
||||
#include <sys/time.h>
|
||||
static inline unsigned int timeGetTime() {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
uint64_t ms = (now.tv_usec/1000) + (now.tv_sec * 1000);
|
||||
return (ms & 0xFFFFFFFF); // MS code is u32 ...
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
|
||||
#ifdef NO_CRT
|
||||
|
@ -40,9 +101,10 @@ inline void * realloc(void *mem, size_t size);
|
|||
#ifdef _MSC_VER
|
||||
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
||||
#else
|
||||
#define EXPORT_C_(type) extern "C" type
|
||||
#define EXPORT_C_(type) extern "C" __attribute__((externally_visible,visibility("default"))) type CALLBACK
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Actually works with 0x0400, but need 0x500 to get XBUTTON defines,
|
||||
// 0x501 to get raw input structures, and 0x0600 to get WM_MOUSEHWHEEL.
|
||||
#define WINVER 0x0600
|
||||
|
@ -61,17 +123,28 @@ inline void * realloc(void *mem, size_t size);
|
|||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <mutex>
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <commctrl.h>
|
||||
// Only needed for DBT_DEVNODES_CHANGED
|
||||
#include <Dbt.h>
|
||||
#endif
|
||||
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
extern HINSTANCE hInst;
|
||||
#endif
|
||||
// Needed for config screen
|
||||
void GetNameAndVersionString(wchar_t *out);
|
||||
|
||||
|
|
|
@ -54,7 +54,9 @@ Device::Device(DeviceAPI api, DeviceType d, const wchar_t *displayName, const wc
|
|||
attached = 1;
|
||||
enabled = 0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
hWndProc = 0;
|
||||
#endif
|
||||
|
||||
virtualControls = 0;
|
||||
numVirtualControls = 0;
|
||||
|
|
|
@ -196,12 +196,14 @@ struct InitInfo {
|
|||
// 1 when binding.
|
||||
int binding;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
HWND hWndTop;
|
||||
|
||||
// For config screen, need to eat button's message handling.
|
||||
//HWND hWndButton;
|
||||
|
||||
WndProcEater* hWndProc;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -216,9 +218,11 @@ public:
|
|||
// Based on input modes.
|
||||
char enabled;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Not all devices need to subclass the windproc, but most do so might as well
|
||||
// put it here... --air
|
||||
WndProcEater* hWndProc;
|
||||
#endif
|
||||
|
||||
union {
|
||||
// Allows for one loop to compare all 3 in order.
|
||||
|
|
|
@ -40,11 +40,7 @@
|
|||
|
||||
// Keeps the various sources for Update polling (PADpoll, PADupdate, etc) from wreaking
|
||||
// havoc on each other...
|
||||
#ifdef _MSC_VER
|
||||
CRITICAL_SECTION updateLock;
|
||||
#else
|
||||
static std::mutex updateLock;
|
||||
#endif
|
||||
|
||||
// Used to toggle mouse listening.
|
||||
u8 miceEnabled;
|
||||
|
@ -325,7 +321,6 @@ void AddForce(ButtonSum *sum, u8 cmd, int delta = 255) {
|
|||
void ProcessButtonBinding(Binding *b, ButtonSum *sum, int value) {
|
||||
if (value < b->deadZone || !value) return;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if ( config.turboKeyHack == 1 ){ // send a tabulator keypress to emulator
|
||||
//printf("%x\n", b->command);
|
||||
if ( b->command == 0x11 ){ // L3 button
|
||||
|
@ -336,7 +331,6 @@ void ProcessButtonBinding(Binding *b, ButtonSum *sum, int value) {
|
|||
LastCheck = t;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int sensitivity = b->sensitivity;
|
||||
if (sensitivity < 0) {
|
||||
|
@ -403,11 +397,9 @@ void Update(unsigned int port, unsigned int slot) {
|
|||
// Lock prior to timecheck code to avoid pesky race conditions.
|
||||
std::lock_guard<std::mutex> lock(updateLock);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
static unsigned int LastCheck = 0;
|
||||
unsigned int t = timeGetTime();
|
||||
if (t - LastCheck < 15 || !openCount) return;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (windowThreadId != GetCurrentThreadId()) {
|
||||
|
@ -422,9 +414,9 @@ void Update(unsigned int port, unsigned int slot) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
LastCheck = t;
|
||||
#endif
|
||||
|
||||
int i;
|
||||
ButtonSum s[2][4];
|
||||
|
|
Loading…
Reference in New Issue