mirror of https://github.com/PCSX2/pcsx2.git
ZeroPad: Revert the changes to the Windows files in ZeroPad, and ifdef off the changes in the common areas, as the Windows version of ZeroPad is clearly only working by voodoo and bailing wire on Windows. (Note: unable to reproduce ZeroPad working properly in any revision [including playground days] on any version of Windows available. Likely because I don't have any poultry handy to sacrifice.)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1130 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
66a8c03ded
commit
b02d6a19dd
|
@ -29,150 +29,142 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
HINSTANCE hInst = NULL;
|
HINSTANCE hInst=NULL;
|
||||||
static pthread_spinlock_t s_mutexStatus;
|
static pthread_spinlock_t s_mutexStatus;
|
||||||
static u32 s_keyPress[2], s_keyRelease[2];
|
static u32 s_keyPress[2], s_keyRelease[2];
|
||||||
extern u16 status[2];
|
extern u16 status[2];
|
||||||
|
|
||||||
extern string s_strIniPath;
|
extern string s_strIniPath;
|
||||||
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
WNDPROC GSwndProc = NULL;
|
WNDPROC GSwndProc=NULL;
|
||||||
HWND GShwnd = NULL;
|
HWND GShwnd=NULL;
|
||||||
|
|
||||||
extern keyEvent event;
|
extern keyEvent event;
|
||||||
|
|
||||||
|
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
char *szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256], szProf[256];
|
char szIniFile[256], szValue[256], szProf[256];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
szTemp = strrchr(szIniFile, '\\');
|
szTemp = strrchr(szIniFile, '\\');
|
||||||
|
|
||||||
if (!szTemp) return;
|
if(!szTemp) return;
|
||||||
strcpy(szTemp, "\\inis\\zeropad.ini");
|
strcpy(szTemp, "\\inis\\zeropad.ini");
|
||||||
|
|
||||||
for (j = 0; j < 2 * PADSUBKEYS; j++)
|
for (j=0; j<2; j++) {
|
||||||
{
|
for (i=0; i<PADKEYS; i++) {
|
||||||
for (i = 0; i < PADKEYS; i++)
|
sprintf(szProf, "%d_%d", j, i);
|
||||||
{
|
sprintf(szValue, "%d", conf.keys[j][i]);
|
||||||
sprintf(szProf, "%d_%d", j, i);
|
WritePrivateProfileString("Interface", szProf,szValue,szIniFile);
|
||||||
sprintf(szValue, "%d", conf.keys[j][i]);
|
}
|
||||||
WritePrivateProfileString("Interface", szProf, szValue, szIniFile);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(szValue, "%u", conf.log);
|
sprintf(szValue,"%u",conf.log);
|
||||||
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
|
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256], szProf[256];
|
char szIniFile[256], szValue[256], szProf[256];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
conf.keys[0][0] = 'W'; // L2
|
conf.keys[0][0] = 'W'; // L2
|
||||||
conf.keys[0][1] = 'O'; // R2
|
conf.keys[0][1] = 'O'; // R2
|
||||||
conf.keys[0][2] = 'A'; // L1
|
conf.keys[0][2] = 'A'; // L1
|
||||||
conf.keys[0][3] = ';'; // R1
|
conf.keys[0][3] = ';'; // R1
|
||||||
conf.keys[0][4] = 'I'; // TRIANGLE
|
conf.keys[0][4] = 'I'; // TRIANGLE
|
||||||
conf.keys[0][5] = 'L'; // CIRCLE
|
conf.keys[0][5] = 'L'; // CIRCLE
|
||||||
conf.keys[0][6] = 'K'; // CROSS
|
conf.keys[0][6] = 'K'; // CROSS
|
||||||
conf.keys[0][7] = 'J'; // SQUARE
|
conf.keys[0][7] = 'J'; // SQUARE
|
||||||
conf.keys[0][8] = 'V'; // SELECT
|
conf.keys[0][8] = 'V'; // SELECT
|
||||||
conf.keys[0][11] = 'N'; // START
|
conf.keys[0][11] = 'N'; // START
|
||||||
conf.keys[0][12] = 'E'; // UP
|
conf.keys[0][12] = 'E'; // UP
|
||||||
conf.keys[0][13] = 'F'; // RIGHT
|
conf.keys[0][13] = 'F'; // RIGHT
|
||||||
conf.keys[0][14] = 'D'; // DOWN
|
conf.keys[0][14] = 'D'; // DOWN
|
||||||
conf.keys[0][15] = 'S'; // LEFT
|
conf.keys[0][15] = 'S'; // LEFT
|
||||||
#endif
|
#endif
|
||||||
conf.log = 0;
|
conf.log = 0;
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
szTemp = strrchr(szIniFile, '\\');
|
szTemp = strrchr(szIniFile, '\\');
|
||||||
|
|
||||||
if (!szTemp) return ;
|
if(!szTemp) return ;
|
||||||
strcpy(szTemp, "\\inis\\zeropad.ini");
|
strcpy(szTemp, "\\inis\\zeropad.ini");
|
||||||
fp = fopen("inis\\zeropad.ini", "rt");//check if usbnull.ini really exists
|
fp=fopen("inis\\zeropad.ini","rt");//check if usbnull.ini really exists
|
||||||
if (!fp)
|
if (!fp) {
|
||||||
{
|
CreateDirectory("inis",NULL);
|
||||||
CreateDirectory("inis", NULL);
|
SaveConfig();//save and return
|
||||||
SaveConfig();//save and return
|
return ;
|
||||||
return ;
|
}
|
||||||
}
|
fclose(fp);
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
for (j = 0; j < 2 * PADSUBKEYS; j++)
|
for (j=0; j<2; j++) {
|
||||||
{
|
for (i=0; i<PADKEYS; i++) {
|
||||||
for (i = 0; i < PADKEYS; i++)
|
sprintf(szProf, "%d_%d", j, i);
|
||||||
{
|
GetPrivateProfileString("Interface", szProf, NULL, szValue, 20, szIniFile);
|
||||||
sprintf(szProf, "%d_%d", j, i);
|
conf.keys[j][i] = strtoul(szValue, NULL, 10);
|
||||||
GetPrivateProfileString("Interface", szProf, NULL, szValue, 20, szIniFile);
|
}
|
||||||
conf.keys[j][i] = strtoul(szValue, NULL, 10);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
||||||
conf.log = strtoul(szValue, NULL, 10);
|
conf.log = strtoul(szValue, NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysMessage(char *fmt, ...)
|
void SysMessage(char *fmt, ...) {
|
||||||
{
|
va_list list;
|
||||||
va_list list;
|
char tmp[512];
|
||||||
char tmp[512];
|
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list,fmt);
|
||||||
vsprintf(tmp, fmt, list);
|
vsprintf(tmp,fmt,list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
MessageBox(0, tmp, "PADwinKeyb Msg", 0);
|
MessageBox(0, tmp, "PADwinKeyb Msg", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _PADopen(void *pDsp)
|
s32 _PADopen(void *pDsp)
|
||||||
{
|
{
|
||||||
memset(&event, 0, sizeof(event));
|
memset(&event, 0, sizeof(event));
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
pthread_spin_init(&s_mutexStatus, PTHREAD_PROCESS_PRIVATE);
|
pthread_spin_init(&s_mutexStatus, PTHREAD_PROCESS_PRIVATE);
|
||||||
s_keyPress[0] = s_keyPress[1] = 0;
|
s_keyPress[0] = s_keyPress[1] = 0;
|
||||||
s_keyRelease[0] = s_keyRelease[1] = 0;
|
s_keyRelease[0] = s_keyRelease[1] = 0;
|
||||||
|
|
||||||
|
if( GShwnd != NULL && GSwndProc != NULL ) {
|
||||||
|
// revert
|
||||||
|
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
|
||||||
|
}
|
||||||
|
|
||||||
if (GShwnd != NULL && GSwndProc != NULL)
|
GShwnd = (HWND)*(long*)pDsp;
|
||||||
{
|
GSwndProc = (WNDPROC)GetWindowLongPtr(GShwnd, GWLP_WNDPROC);
|
||||||
// revert
|
GSwndProc = ((WNDPROC)SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(PADwndProc)));
|
||||||
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
|
|
||||||
}
|
|
||||||
|
|
||||||
GShwnd = (HWND) * (long*)pDsp;
|
return 0;
|
||||||
GSwndProc = (WNDPROC)GetWindowLongPtr(GShwnd, GWLP_WNDPROC);
|
|
||||||
GSwndProc = ((WNDPROC)SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(PADwndProc)));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _PADclose()
|
void _PADclose()
|
||||||
{
|
{
|
||||||
if (GShwnd != NULL && GSwndProc != NULL)
|
if( GShwnd != NULL && GSwndProc != NULL ) {
|
||||||
{
|
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
|
||||||
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
|
GSwndProc = NULL;
|
||||||
GSwndProc = NULL;
|
GShwnd = NULL;
|
||||||
GShwnd = NULL;
|
}
|
||||||
}
|
pthread_spin_destroy(&s_mutexStatus);
|
||||||
pthread_spin_destroy(&s_mutexStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _PADupdate(int pad)
|
void _PADupdate(int pad)
|
||||||
{
|
{
|
||||||
pthread_spin_lock(&s_mutexStatus);
|
pthread_spin_lock(&s_mutexStatus);
|
||||||
status[pad] |= s_keyRelease[pad];
|
status[pad] |= s_keyRelease[pad];
|
||||||
status[pad] &= ~s_keyPress[pad];
|
status[pad] &= ~s_keyPress[pad];
|
||||||
s_keyRelease[pad] = 0;
|
s_keyRelease[pad] = 0;
|
||||||
s_keyPress[pad] = 0;
|
s_keyPress[pad] = 0;
|
||||||
pthread_spin_unlock(&s_mutexStatus);
|
pthread_spin_unlock(&s_mutexStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK PADupdate(int pad)
|
void CALLBACK PADupdate(int pad)
|
||||||
|
@ -181,301 +173,287 @@ void CALLBACK PADupdate(int pad)
|
||||||
|
|
||||||
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int i, pad, keyPress[2] = {0}, keyRelease[2] = {0};
|
int i,pad,keyPress[2]={0},keyRelease[2]={0};
|
||||||
static bool lbutton = false, rbutton = false;
|
static bool lbutton=false,rbutton=false;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg) {
|
||||||
{
|
case WM_KEYDOWN:
|
||||||
case WM_KEYDOWN:
|
if (lParam & 0x40000000)
|
||||||
if (lParam & 0x40000000)
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
i = FindKey(wParam, pad);
|
for(pad = 0; pad < 2; ++pad ) {
|
||||||
if (i != -1) {
|
for (i=0; i<PADKEYS; i++) {
|
||||||
keyPress[pad] |= (1 << i);
|
if (wParam == conf.keys[pad][i]) {
|
||||||
keyRelease[pad] &= ~(1 << i);
|
keyPress[pad] |=(1<<i);
|
||||||
}
|
keyRelease[pad] &=~(1<<i);
|
||||||
event.evt = KEYPRESS;
|
break;
|
||||||
event.key = wParam;
|
}
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case WM_KEYUP:
|
event.evt = KEYPRESS;
|
||||||
i = FindKey(wParam, pad);
|
event.key = wParam;
|
||||||
if (i != -1) {
|
break;
|
||||||
keyPress[pad] &= ~(1 << i);
|
|
||||||
keyRelease[pad] |= (1 << i);
|
|
||||||
}
|
|
||||||
event.evt = KEYRELEASE;
|
|
||||||
event.key = wParam;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_KEYUP:
|
||||||
lbutton = true;
|
for(pad = 0; pad < 2; ++pad ) {
|
||||||
break;
|
for (i=0; i<PADKEYS; i++) {
|
||||||
|
if (wParam == conf.keys[pad][i]) {
|
||||||
|
keyPress[pad] &=~(1<<i);
|
||||||
|
keyRelease[pad] |= (1<<i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
g_lanalog[0].x = 0x80;
|
|
||||||
g_lanalog[0].y = 0x80;
|
|
||||||
g_lanalog[1].x = 0x80;
|
|
||||||
g_lanalog[1].y = 0x80;
|
|
||||||
lbutton = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
event.evt = KEYRELEASE;
|
||||||
rbutton = true;
|
event.key = wParam;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_RBUTTONUP:
|
case WM_LBUTTONDOWN:
|
||||||
g_ranalog[0].x = 0x80;
|
lbutton = true;
|
||||||
g_ranalog[0].y = 0x80;
|
break;
|
||||||
g_ranalog[1].x = 0x80;
|
|
||||||
g_ranalog[1].y = 0x80;
|
|
||||||
rbutton = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_LBUTTONUP:
|
||||||
if (lbutton)
|
g_lanalog[0].x = 0x80;
|
||||||
{
|
g_lanalog[0].y = 0x80;
|
||||||
g_lanalog[0].x = LOWORD(lParam) & 254;
|
g_lanalog[1].x = 0x80;
|
||||||
g_lanalog[0].y = HIWORD(lParam) & 254;
|
g_lanalog[1].y = 0x80;
|
||||||
g_lanalog[1].x = LOWORD(lParam) & 254;
|
lbutton = false;
|
||||||
g_lanalog[1].y = HIWORD(lParam) & 254;
|
break;
|
||||||
}
|
|
||||||
if (rbutton)
|
|
||||||
{
|
|
||||||
g_ranalog[0].x = LOWORD(lParam) & 254;
|
|
||||||
g_ranalog[0].y = HIWORD(lParam) & 254;
|
|
||||||
g_ranalog[1].x = LOWORD(lParam) & 254;
|
|
||||||
g_ranalog[1].y = HIWORD(lParam) & 254;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_QUIT:
|
rbutton = true;
|
||||||
event.evt = KEYPRESS;
|
break;
|
||||||
event.key = VK_ESCAPE;
|
|
||||||
return GSwndProc(hWnd, msg, wParam, lParam);
|
|
||||||
|
|
||||||
default:
|
case WM_RBUTTONUP:
|
||||||
return GSwndProc(hWnd, msg, wParam, lParam);
|
g_ranalog[0].x = 0x80;
|
||||||
}
|
g_ranalog[0].y = 0x80;
|
||||||
|
g_ranalog[1].x = 0x80;
|
||||||
|
g_ranalog[1].y = 0x80;
|
||||||
|
rbutton = false;
|
||||||
|
break;
|
||||||
|
|
||||||
pthread_spin_lock(&s_mutexStatus);
|
case WM_MOUSEMOVE:
|
||||||
for (pad = 0; pad < 2; ++pad)
|
if(lbutton)
|
||||||
{
|
{
|
||||||
s_keyPress[pad] |= keyPress[pad];
|
g_lanalog[0].x = LOWORD(lParam) & 254;
|
||||||
s_keyPress[pad] &= ~keyRelease[pad];
|
g_lanalog[0].y = HIWORD(lParam) & 254;
|
||||||
s_keyRelease[pad] |= keyRelease[pad];
|
g_lanalog[1].x = LOWORD(lParam) & 254;
|
||||||
s_keyRelease[pad] &= ~keyPress[pad];
|
g_lanalog[1].y = HIWORD(lParam) & 254;
|
||||||
}
|
}
|
||||||
pthread_spin_unlock(&s_mutexStatus);
|
if(rbutton)
|
||||||
|
{
|
||||||
|
g_ranalog[0].x = LOWORD(lParam) & 254;
|
||||||
|
g_ranalog[0].y = HIWORD(lParam) & 254;
|
||||||
|
g_ranalog[1].x = LOWORD(lParam) & 254;
|
||||||
|
g_ranalog[1].y = HIWORD(lParam) & 254;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
return TRUE;
|
case WM_DESTROY:
|
||||||
|
case WM_QUIT:
|
||||||
|
event.evt = KEYPRESS;
|
||||||
|
event.key = VK_ESCAPE;
|
||||||
|
return GSwndProc(hWnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return GSwndProc(hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_spin_lock(&s_mutexStatus);
|
||||||
|
for(pad = 0; pad < 2; ++pad ) {
|
||||||
|
s_keyPress[pad] |= keyPress[pad];
|
||||||
|
s_keyPress[pad] &= ~keyRelease[pad];
|
||||||
|
s_keyRelease[pad] |= keyRelease[pad];
|
||||||
|
s_keyRelease[pad] &= ~keyPress[pad];
|
||||||
|
}
|
||||||
|
pthread_spin_unlock(&s_mutexStatus);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetKeyLabel(const int pad, const int index)
|
string GetKeyLabel(const int pad, const int index)
|
||||||
{
|
{
|
||||||
const int key = conf.keys[pad][index];
|
const int key = conf.keys[pad][index];
|
||||||
char buff[16] = "NONE)";
|
char buff[16]="NONE)";
|
||||||
|
if (key < 0x100)
|
||||||
if (key < 0x100)
|
{
|
||||||
{
|
if (key == 0)
|
||||||
if (key == 0)
|
strcpy (buff, "NONE");
|
||||||
strcpy(buff, "NONE");
|
else {
|
||||||
else
|
if(key>=0x60 && key<=0x69) {
|
||||||
{
|
sprintf(buff, "NumPad %c", '0' + key - 0x60);
|
||||||
if (key >= 0x60 && key <= 0x69)
|
}
|
||||||
sprintf(buff, "NumPad %c", '0' + key - 0x60);
|
else sprintf(buff, "%c", key);
|
||||||
else
|
}
|
||||||
sprintf(buff, "%c", key);
|
}
|
||||||
}
|
else if (key >= 0x1000 && key < 0x2000)
|
||||||
}
|
{
|
||||||
else if (key >= 0x1000 && key < 0x2000)
|
sprintf (buff, "J%d_%d", (key & 0xfff) / 0x100, (key & 0xff) + 1);
|
||||||
{
|
}
|
||||||
sprintf(buff, "J%d_%d", (key & 0xfff) / 0x100, (key & 0xff) + 1);
|
else if (key >= 0x2000 && key < 0x3000)
|
||||||
}
|
{
|
||||||
else if (key >= 0x2000 && key < 0x3000)
|
static const char name[][4] = { "MIN", "MAX" };
|
||||||
{
|
const int axis = (key & 0xff);
|
||||||
static const char name[][4] = { "MIN", "MAX" };
|
sprintf (buff, "J%d_AXIS%d_%s", (key & 0xfff) / 0x100, axis / 2, name[axis % 2]);
|
||||||
const int axis = (key & 0xff);
|
if (index >= 17 && index <= 20)
|
||||||
|
buff[strlen (buff) -4] = '\0';
|
||||||
sprintf(buff, "J%d_AXIS%d_%s", (key & 0xfff) / 0x100, axis / 2, name[axis % 2]);
|
}
|
||||||
if (index >= 17 && index <= 20) buff[strlen(buff) -4] = '\0';
|
else if (key >= 0x3000 && key < 0x4000)
|
||||||
}
|
{
|
||||||
else if (key >= 0x3000 && key < 0x4000)
|
static const char name[][7] = { "FOWARD", "RIGHT", "BACK", "LEFT" };
|
||||||
{
|
const int pov = (key & 0xff);
|
||||||
static const char name[][7] = { "FOWARD", "RIGHT", "BACK", "LEFT" };
|
sprintf (buff, "J%d_POV%d_%s", (key & 0xfff) / 0x100, pov /4, name[pov % 4]);
|
||||||
const int pov = (key & 0xff);
|
}
|
||||||
sprintf(buff, "J%d_POV%d_%s", (key & 0xfff) / 0x100, pov / 4, name[pov % 4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
{
|
HWND hWC;
|
||||||
HWND hWC;
|
TCITEM tcI;
|
||||||
TCITEM tcI;
|
int i,key, numkeys;
|
||||||
int i, key, numkeys;
|
u8* pkeyboard;
|
||||||
u8* pkeyboard;
|
static int disabled=0;
|
||||||
static int disabled = 0;
|
static int padn=0;
|
||||||
static int padn = 0;
|
|
||||||
|
|
||||||
switch (uMsg)
|
switch(uMsg) {
|
||||||
{
|
case WM_INITDIALOG:
|
||||||
case WM_INITDIALOG:
|
LoadConfig();
|
||||||
LoadConfig();
|
padn = 0;
|
||||||
padn = 0;
|
if (conf.log) CheckDlgButton(hW, IDC_LOG, TRUE);
|
||||||
if (conf.log) CheckDlgButton(hW, IDC_LOG, TRUE);
|
|
||||||
|
|
||||||
for (i = 0; i < PADKEYS; i++)
|
for (i=0; i<PADKEYS; i++) {
|
||||||
{
|
hWC = GetDlgItem(hW, IDC_L2 + i*2);
|
||||||
hWC = GetDlgItem(hW, IDC_L2 + i * 2);
|
Button_SetText(hWC, GetKeyLabel(padn, i).c_str());
|
||||||
Button_SetText(hWC, GetKeyLabel(padn, i).c_str());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
hWC = GetDlgItem(hW, IDC_TABC);
|
hWC = GetDlgItem(hW, IDC_TABC);
|
||||||
|
|
||||||
tcI.mask = TCIF_TEXT;
|
tcI.mask = TCIF_TEXT;
|
||||||
tcI.pszText = "PAD 1";
|
tcI.pszText = "PAD 1";
|
||||||
|
|
||||||
TabCtrl_InsertItem(hWC, 0, &tcI);
|
TabCtrl_InsertItem(hWC, 0, &tcI);
|
||||||
|
|
||||||
tcI.mask = TCIF_TEXT;
|
tcI.mask = TCIF_TEXT;
|
||||||
tcI.pszText = "PAD 2";
|
tcI.pszText = "PAD 2";
|
||||||
|
|
||||||
TabCtrl_InsertItem(hWC, 1, &tcI);
|
TabCtrl_InsertItem(hWC, 1, &tcI);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
if (disabled)
|
if (disabled){
|
||||||
{
|
key = 0;
|
||||||
key = 0;
|
//pkeyboard = SDL_GetKeyState(&numkeys);
|
||||||
//pkeyboard = SDL_GetKeyState(&numkeys);
|
for (int i = 0; i < numkeys; ++i) {
|
||||||
for (int i = 0; i < numkeys; ++i)
|
if( pkeyboard[i] ) {
|
||||||
{
|
key = i;
|
||||||
if (pkeyboard[i])
|
break;
|
||||||
{
|
}
|
||||||
key = i;
|
}
|
||||||
break;
|
|
||||||
}
|
if( key == 0 ) {
|
||||||
}
|
// check joystick
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key != 0){
|
||||||
|
KillTimer(hW, 0x80);
|
||||||
|
hWC = GetDlgItem(hW, disabled);
|
||||||
|
conf.keys[padn][disabled-IDC_L2] = key;
|
||||||
|
Button_SetText(hWC, GetKeyLabel(padn, disabled-IDC_L2).c_str());
|
||||||
|
EnableWindow(hWC, TRUE);
|
||||||
|
disabled=0;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (key == 0)
|
case WM_COMMAND:
|
||||||
{
|
for(i = IDC_L2; i <= IDC_LEFT; i+=2)
|
||||||
// check joystick
|
{
|
||||||
}
|
if(LOWORD(wParam) == i)
|
||||||
|
{
|
||||||
|
if (disabled)//change selection
|
||||||
|
EnableWindow(GetDlgItem(hW, disabled), TRUE);
|
||||||
|
|
||||||
if (key != 0)
|
EnableWindow(GetDlgItem(hW, disabled=wParam), FALSE);
|
||||||
{
|
|
||||||
KillTimer(hW, 0x80);
|
SetTimer(hW, 0x80, 250, NULL);
|
||||||
hWC = GetDlgItem(hW, disabled);
|
|
||||||
conf.keys[padn][disabled-IDC_L2] = key;
|
return TRUE;
|
||||||
Button_SetText(hWC, GetKeyLabel(padn, disabled - IDC_L2).c_str());
|
}
|
||||||
EnableWindow(hWC, TRUE);
|
}
|
||||||
disabled = 0;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
switch(LOWORD(wParam)) {
|
||||||
for (i = IDC_L2; i <= IDC_LEFT; i += 2)
|
case IDCANCEL:
|
||||||
{
|
KillTimer(hW, 0x80);
|
||||||
if (LOWORD(wParam) == i)
|
EndDialog(hW, TRUE);
|
||||||
{
|
return TRUE;
|
||||||
if (disabled)//change selection
|
case IDOK:
|
||||||
EnableWindow(GetDlgItem(hW, disabled), TRUE);
|
KillTimer(hW, 0x80);
|
||||||
|
if (IsDlgButtonChecked(hW, IDC_LOG))
|
||||||
|
conf.log = 1;
|
||||||
|
else conf.log = 0;
|
||||||
|
SaveConfig();
|
||||||
|
EndDialog(hW, FALSE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
EnableWindow(GetDlgItem(hW, disabled = wParam), FALSE);
|
case WM_NOTIFY:
|
||||||
|
switch (wParam) {
|
||||||
|
case IDC_TABC:
|
||||||
|
hWC = GetDlgItem(hW, IDC_TABC);
|
||||||
|
padn = TabCtrl_GetCurSel(hWC);
|
||||||
|
|
||||||
|
for (i=0; i<PADKEYS; i++) {
|
||||||
|
hWC = GetDlgItem(hW, IDC_EL3 + i);
|
||||||
|
Button_SetText(hWC, GetKeyLabel(padn, i).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
SetTimer(hW, 0x80, 250, NULL);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
switch (LOWORD(wParam))
|
return FALSE;
|
||||||
{
|
|
||||||
case IDCANCEL:
|
|
||||||
KillTimer(hW, 0x80);
|
|
||||||
EndDialog(hW, TRUE);
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case IDOK:
|
|
||||||
KillTimer(hW, 0x80);
|
|
||||||
|
|
||||||
if (IsDlgButtonChecked(hW, IDC_LOG))
|
|
||||||
conf.log = 1;
|
|
||||||
else
|
|
||||||
conf.log = 0;
|
|
||||||
|
|
||||||
SaveConfig();
|
|
||||||
EndDialog(hW, FALSE);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_NOTIFY:
|
|
||||||
switch (wParam)
|
|
||||||
{
|
|
||||||
case IDC_TABC:
|
|
||||||
hWC = GetDlgItem(hW, IDC_TABC);
|
|
||||||
padn = TabCtrl_GetCurSel(hWC);
|
|
||||||
|
|
||||||
for (i = 0; i < PADKEYS; i++)
|
|
||||||
{
|
|
||||||
hWC = GetDlgItem(hW, IDC_EL3 + i);
|
|
||||||
Button_SetText(hWC, GetKeyLabel(padn, i).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
{
|
switch(uMsg) {
|
||||||
switch (uMsg)
|
case WM_INITDIALOG:
|
||||||
{
|
return TRUE;
|
||||||
case WM_INITDIALOG:
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch(LOWORD(wParam)) {
|
||||||
{
|
case IDOK:
|
||||||
case IDOK:
|
EndDialog(hW, FALSE);
|
||||||
EndDialog(hW, FALSE);
|
return TRUE;
|
||||||
return TRUE;
|
}
|
||||||
}
|
}
|
||||||
}
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK PADconfigure()
|
void CALLBACK PADconfigure() {
|
||||||
{
|
DialogBox(hInst,
|
||||||
DialogBox(hInst,
|
MAKEINTRESOURCE(IDD_DIALOG1),
|
||||||
MAKEINTRESOURCE(IDD_DIALOG1),
|
GetActiveWindow(),
|
||||||
GetActiveWindow(),
|
(DLGPROC)ConfigureDlgProc);
|
||||||
(DLGPROC)ConfigureDlgProc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK PADabout()
|
void CALLBACK PADabout() {
|
||||||
{
|
SysMessage("Author: zerofrog\nThanks to SSSPSXPad, TwinPAD, and PADwin plugins");
|
||||||
SysMessage("Author: zerofrog\nThanks to SSSPSXPad, TwinPAD, and PADwin plugins");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CALLBACK PADtest()
|
s32 CALLBACK PADtest() {
|
||||||
{
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||||
DWORD dwReason,
|
DWORD dwReason,
|
||||||
LPVOID lpReserved)
|
LPVOID lpReserved) {
|
||||||
{
|
hInst = (HINSTANCE)hModule;
|
||||||
hInst = (HINSTANCE)hModule;
|
return TRUE; // very quick :)
|
||||||
return TRUE; // very quick :)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,14 @@ void _KeyPress(int pad, u32 key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
for (i=0; i<PADKEYS; i++) {
|
||||||
|
if (key == conf.keys[pad][i]) {
|
||||||
|
status[pad]&=~(1<<i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
for (int p = 0; p < PADSUBKEYS; p++)
|
for (int p = 0; p < PADSUBKEYS; p++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < PADKEYS; i++)
|
for (i = 0; i < PADKEYS; i++)
|
||||||
|
@ -147,6 +155,7 @@ void _KeyPress(int pad, u32 key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
event.evt = KEYPRESS;
|
event.evt = KEYPRESS;
|
||||||
event.key = key;
|
event.key = key;
|
||||||
|
@ -156,6 +165,14 @@ void _KeyRelease(int pad, u32 key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
for (i=0; i<PADKEYS; i++) {
|
||||||
|
if (key == conf.keys[pad][i]) {
|
||||||
|
status[pad]|= (1<<i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
for (int p = 0; p < PADSUBKEYS; p++)
|
for (int p = 0; p < PADSUBKEYS; p++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < PADKEYS; i++)
|
for (i = 0; i < PADKEYS; i++)
|
||||||
|
@ -167,7 +184,7 @@ void _KeyRelease(int pad, u32 key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
event.evt = KEYRELEASE;
|
event.evt = KEYRELEASE;
|
||||||
event.key = key;
|
event.key = key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,12 @@ extern char libraryName[256];
|
||||||
#define PADOPTION_REVERTRX 0x8
|
#define PADOPTION_REVERTRX 0x8
|
||||||
#define PADOPTION_REVERTRY 0x10
|
#define PADOPTION_REVERTRY 0x10
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define PADSUBKEYS 1
|
||||||
|
#else
|
||||||
#define PADSUBKEYS 2
|
#define PADSUBKEYS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int PadEnum[2][2];
|
extern int PadEnum[2][2];
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
Loading…
Reference in New Issue