2009-02-11 20:47:41 +00:00
|
|
|
// Includes Windows.h, has inlined versions of memory allocation and
|
|
|
|
// string comparison functions needed to avoid using CRT. This reduces
|
|
|
|
// dll size by over 100k while avoiding any dependencies on updated CRT dlls.
|
2009-02-11 09:24:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
2009-09-18 06:58:48 +00:00
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
|
|
|
2009-02-11 09:24:56 +00:00
|
|
|
#ifdef NO_CRT
|
|
|
|
#define _CRT_ALLOCATION_DEFINED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UNICODE
|
|
|
|
|
2009-02-24 02:08:37 +00:00
|
|
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
2009-02-11 09:24:56 +00:00
|
|
|
#define _CRT_SECURE_NO_DEPRECATE
|
2009-02-24 02:08:37 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-01 23:53:20 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
|
|
|
#else
|
|
|
|
#define EXPORT_C_(type) extern "C" type
|
|
|
|
#endif
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
// 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
|
2009-02-11 09:24:56 +00:00
|
|
|
#define _WIN32_WINNT WINVER
|
|
|
|
#define __MSCW32__
|
|
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
2009-09-18 06:58:48 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <commctrl.h>
|
|
|
|
// Only needed for DBT_DEVNODES_CHANGED
|
|
|
|
#include <Dbt.h>
|
|
|
|
|
2009-03-01 23:53:20 +00:00
|
|
|
#include "PS2Etypes.h"
|
|
|
|
#include "PS2Edefs.h"
|
2009-02-11 09:24:56 +00:00
|
|
|
|
2009-09-20 04:14:40 +00:00
|
|
|
#include "resource.h"
|
|
|
|
#include "InputManager.h"
|
|
|
|
#include "Config.h"
|
|
|
|
|
2009-02-11 09:24:56 +00:00
|
|
|
extern HINSTANCE hInst;
|
2009-02-27 23:29:48 +00:00
|
|
|
// Needed for config screen
|
|
|
|
void GetNameAndVersionString(wchar_t *out);
|
2009-02-11 09:24:56 +00:00
|
|
|
|
2009-03-01 23:53:20 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned char controllerType;
|
|
|
|
unsigned short buttonStatus;
|
|
|
|
unsigned char rightJoyX, rightJoyY, leftJoyX, leftJoyY;
|
|
|
|
unsigned char moveX, moveY;
|
|
|
|
unsigned char reserved[91];
|
|
|
|
} PadDataS;
|
|
|
|
|
|
|
|
EXPORT_C_(void) PADupdate(int pad);
|
|
|
|
EXPORT_C_(u32) PS2EgetLibType(void);
|
|
|
|
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type);
|
|
|
|
EXPORT_C_(char*) PSEgetLibName();
|
|
|
|
EXPORT_C_(char*) PS2EgetLibName(void);
|
|
|
|
EXPORT_C_(void) PADshutdown();
|
|
|
|
EXPORT_C_(s32) PADinit(u32 flags);
|
|
|
|
EXPORT_C_(s32) PADopen(void *pDsp);
|
|
|
|
EXPORT_C_(void) PADclose();
|
|
|
|
EXPORT_C_(u8) PADstartPoll(int pad);
|
|
|
|
EXPORT_C_(u8) PADpoll(u8 value);
|
|
|
|
EXPORT_C_(u32) PADquery();
|
|
|
|
EXPORT_C_(void) PADabout();
|
|
|
|
EXPORT_C_(s32) PADtest();
|
|
|
|
EXPORT_C_(keyEvent*) PADkeyEvent();
|
|
|
|
EXPORT_C_(u32) PADreadPort1 (PadDataS* pads);
|
|
|
|
EXPORT_C_(u32) PADreadPort2 (PadDataS* pads);
|
|
|
|
EXPORT_C_(u32) PSEgetLibType();
|
|
|
|
EXPORT_C_(u32) PSEgetLibVersion();
|
|
|
|
EXPORT_C_(void) PADconfigure();
|
2009-03-15 00:00:02 +00:00
|
|
|
EXPORT_C_(s32) PADfreeze(int mode, freezeData *data);
|
2009-03-29 06:14:59 +00:00
|
|
|
EXPORT_C_(s32) PADsetSlot(u8 port, u8 slot);
|
|
|
|
EXPORT_C_(s32) PADqueryMtap(u8 port);
|
2009-03-01 23:53:20 +00:00
|
|
|
|
2009-02-11 09:24:56 +00:00
|
|
|
#ifdef NO_CRT
|
2009-09-18 06:58:48 +00:00
|
|
|
|
|
|
|
#define malloc MyMalloc
|
|
|
|
#define calloc MyCalloc
|
|
|
|
#define free MyFree
|
|
|
|
#define realloc MyRealloc
|
|
|
|
#define wcsdup MyWcsdup
|
|
|
|
#define wcsicmp MyWcsicmp
|
|
|
|
|
2009-02-11 09:24:56 +00:00
|
|
|
inline void * malloc(size_t size) {
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void * calloc(size_t num, size_t size) {
|
|
|
|
size *= num;
|
|
|
|
void *out = malloc(size);
|
|
|
|
if (out) memset(out, 0, size);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void free(__inout_opt void * mem) {
|
|
|
|
if (mem) HeapFree(GetProcessHeap(), 0, mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void * realloc(void *mem, size_t size) {
|
|
|
|
if (!mem) {
|
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!size) {
|
|
|
|
free(mem);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, mem, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline wchar_t * __cdecl wcsdup(const wchar_t *in) {
|
|
|
|
size_t size = sizeof(wchar_t) * (1+wcslen(in));
|
|
|
|
wchar_t *out = (wchar_t*) malloc(size);
|
|
|
|
if (out)
|
|
|
|
memcpy(out, in, size);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
inline void * __cdecl operator new(size_t lSize) {
|
2009-02-11 09:24:56 +00:00
|
|
|
return HeapAlloc(GetProcessHeap(), 0, lSize);
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
inline void __cdecl operator delete(void *pBlock) {
|
2009-02-11 09:24:56 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pBlock);
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
inline int __cdecl wcsicmp(const wchar_t *s1, const wchar_t *s2) {
|
2009-02-11 09:24:56 +00:00
|
|
|
int res = CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, s1, -1, s2, -1);
|
|
|
|
if (res) return res-2;
|
|
|
|
return res;
|
|
|
|
}
|
2009-02-11 20:47:41 +00:00
|
|
|
|
|
|
|
#endif
|