2009-02-09 21:15:56 +00:00
|
|
|
/* ZeroPAD - author: zerofrog(@gmail.com)
|
2009-05-03 12:19:58 +00:00
|
|
|
* Copyright (C) 2006-2007
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
#include "resource.h"
|
|
|
|
#include "../zeropad.h"
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
HINSTANCE hInst = NULL;
|
2009-02-09 21:15:56 +00:00
|
|
|
static pthread_spinlock_t s_mutexStatus;
|
|
|
|
static u32 s_keyPress[2], s_keyRelease[2];
|
|
|
|
extern u16 status[2];
|
|
|
|
|
|
|
|
extern string s_strIniPath;
|
|
|
|
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
2009-05-03 12:19:58 +00:00
|
|
|
WNDPROC GSwndProc = NULL;
|
|
|
|
HWND GShwnd = NULL;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
extern keyEvent event;
|
|
|
|
|
|
|
|
|
|
|
|
void SaveConfig()
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
char *szTemp;
|
2009-02-09 21:15:56 +00:00
|
|
|
char szIniFile[256], szValue[256], szProf[256];
|
2009-05-03 12:19:58 +00:00
|
|
|
int i, j;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
|
|
|
szTemp = strrchr(szIniFile, '\\');
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
if (!szTemp) return;
|
2009-02-09 21:15:56 +00:00
|
|
|
strcpy(szTemp, "\\inis\\zeropad.ini");
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
for (j = 0; j < 2 * PADSUBKEYS; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < PADKEYS; i++)
|
|
|
|
{
|
|
|
|
sprintf(szProf, "%d_%d", j, i);
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(szValue, "%d", conf.keys[j][i]);
|
2009-05-03 12:19:58 +00:00
|
|
|
WritePrivateProfileString("Interface", szProf, szValue, szIniFile);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
sprintf(szValue, "%u", conf.log);
|
|
|
|
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoadConfig()
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
FILE *fp;
|
2009-02-09 21:15:56 +00:00
|
|
|
char *szTemp;
|
|
|
|
char szIniFile[256], szValue[256], szProf[256];
|
|
|
|
int i, j;
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
memset(&conf, 0, sizeof(conf));
|
2009-02-09 21:15:56 +00:00
|
|
|
#ifdef _WIN32
|
2009-05-03 12:19:58 +00:00
|
|
|
conf.keys[0][0] = 'W'; // L2
|
|
|
|
conf.keys[0][1] = 'O'; // R2
|
|
|
|
conf.keys[0][2] = 'A'; // L1
|
|
|
|
conf.keys[0][3] = ';'; // R1
|
|
|
|
conf.keys[0][4] = 'I'; // TRIANGLE
|
|
|
|
conf.keys[0][5] = 'L'; // CIRCLE
|
|
|
|
conf.keys[0][6] = 'K'; // CROSS
|
|
|
|
conf.keys[0][7] = 'J'; // SQUARE
|
|
|
|
conf.keys[0][8] = 'V'; // SELECT
|
|
|
|
conf.keys[0][11] = 'N'; // START
|
|
|
|
conf.keys[0][12] = 'E'; // UP
|
|
|
|
conf.keys[0][13] = 'F'; // RIGHT
|
|
|
|
conf.keys[0][14] = 'D'; // DOWN
|
|
|
|
conf.keys[0][15] = 'S'; // LEFT
|
2009-02-09 21:15:56 +00:00
|
|
|
#endif
|
|
|
|
conf.log = 0;
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
2009-02-09 21:15:56 +00:00
|
|
|
szTemp = strrchr(szIniFile, '\\');
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
if (!szTemp) return ;
|
2009-02-09 21:15:56 +00:00
|
|
|
strcpy(szTemp, "\\inis\\zeropad.ini");
|
2009-05-03 12:19:58 +00:00
|
|
|
fp = fopen("inis\\zeropad.ini", "rt");//check if usbnull.ini really exists
|
|
|
|
if (!fp)
|
|
|
|
{
|
|
|
|
CreateDirectory("inis", NULL);
|
|
|
|
SaveConfig();//save and return
|
2009-02-09 21:15:56 +00:00
|
|
|
return ;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
for (j = 0; j < 2 * PADSUBKEYS; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < PADKEYS; i++)
|
|
|
|
{
|
|
|
|
sprintf(szProf, "%d_%d", j, i);
|
|
|
|
GetPrivateProfileString("Interface", szProf, NULL, szValue, 20, szIniFile);
|
|
|
|
conf.keys[j][i] = strtoul(szValue, NULL, 10);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
|
|
|
conf.log = strtoul(szValue, NULL, 10);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
void SysMessage(char *fmt, ...)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
va_list list;
|
|
|
|
char tmp[512];
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(tmp, fmt, list);
|
2009-02-09 21:15:56 +00:00
|
|
|
va_end(list);
|
|
|
|
MessageBox(0, tmp, "PADwinKeyb Msg", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 _PADopen(void *pDsp)
|
|
|
|
{
|
|
|
|
memset(&event, 0, sizeof(event));
|
|
|
|
LoadConfig();
|
2009-05-03 12:19:58 +00:00
|
|
|
pthread_spin_init(&s_mutexStatus, PTHREAD_PROCESS_PRIVATE);
|
|
|
|
s_keyPress[0] = s_keyPress[1] = 0;
|
|
|
|
s_keyRelease[0] = s_keyRelease[1] = 0;
|
|
|
|
|
|
|
|
if (GShwnd != NULL && GSwndProc != NULL)
|
|
|
|
{
|
|
|
|
// revert
|
|
|
|
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
GShwnd = (HWND) * (long*)pDsp;
|
|
|
|
GSwndProc = (WNDPROC)GetWindowLongPtr(GShwnd, GWLP_WNDPROC);
|
|
|
|
GSwndProc = ((WNDPROC)SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(PADwndProc)));
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
return 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _PADclose()
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
if (GShwnd != NULL && GSwndProc != NULL)
|
|
|
|
{
|
|
|
|
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)(GSwndProc));
|
|
|
|
GSwndProc = NULL;
|
|
|
|
GShwnd = NULL;
|
|
|
|
}
|
|
|
|
pthread_spin_destroy(&s_mutexStatus);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _PADupdate(int pad)
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
pthread_spin_lock(&s_mutexStatus);
|
|
|
|
status[pad] |= s_keyRelease[pad];
|
|
|
|
status[pad] &= ~s_keyPress[pad];
|
|
|
|
s_keyRelease[pad] = 0;
|
|
|
|
s_keyPress[pad] = 0;
|
|
|
|
pthread_spin_unlock(&s_mutexStatus);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CALLBACK PADupdate(int pad)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
int i, pad, keyPress[2] = {0}, keyRelease[2] = {0};
|
|
|
|
static bool lbutton = false, rbutton = false;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
switch (msg)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
case WM_KEYDOWN:
|
|
|
|
if (lParam & 0x40000000)
|
|
|
|
return TRUE;
|
|
|
|
|
2009-05-03 19:30:38 +00:00
|
|
|
i = FindKey(wParam, pad);
|
|
|
|
if (i != -1) {
|
|
|
|
keyPress[pad] |= (1 << i);
|
|
|
|
keyRelease[pad] &= ~(1 << i);
|
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
event.evt = KEYPRESS;
|
2009-05-03 11:09:15 +00:00
|
|
|
event.key = wParam;
|
2009-02-09 21:15:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_KEYUP:
|
2009-05-03 19:30:38 +00:00
|
|
|
i = FindKey(wParam, pad);
|
|
|
|
if (i != -1) {
|
|
|
|
keyPress[pad] &= ~(1 << i);
|
|
|
|
keyRelease[pad] |= (1 << i);
|
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
event.evt = KEYRELEASE;
|
|
|
|
event.key = wParam;
|
2009-02-09 21:15:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
lbutton = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
g_lanalog[0].x = 0x80;
|
|
|
|
g_lanalog[0].y = 0x80;
|
2009-05-03 12:19:58 +00:00
|
|
|
g_lanalog[1].x = 0x80;
|
2009-02-09 21:15:56 +00:00
|
|
|
g_lanalog[1].y = 0x80;
|
|
|
|
lbutton = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
rbutton = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
g_ranalog[0].x = 0x80;
|
|
|
|
g_ranalog[0].y = 0x80;
|
2009-05-03 12:19:58 +00:00
|
|
|
g_ranalog[1].x = 0x80;
|
2009-02-09 21:15:56 +00:00
|
|
|
g_ranalog[1].y = 0x80;
|
|
|
|
rbutton = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
2009-05-03 12:19:58 +00:00
|
|
|
if (lbutton)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
g_lanalog[0].x = LOWORD(lParam) & 254;
|
|
|
|
g_lanalog[0].y = HIWORD(lParam) & 254;
|
2009-05-03 12:19:58 +00:00
|
|
|
g_lanalog[1].x = LOWORD(lParam) & 254;
|
2009-02-09 21:15:56 +00:00
|
|
|
g_lanalog[1].y = HIWORD(lParam) & 254;
|
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
if (rbutton)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
g_ranalog[0].x = LOWORD(lParam) & 254;
|
|
|
|
g_ranalog[0].y = HIWORD(lParam) & 254;
|
2009-05-03 12:19:58 +00:00
|
|
|
g_ranalog[1].x = LOWORD(lParam) & 254;
|
2009-02-09 21:15:56 +00:00
|
|
|
g_ranalog[1].y = HIWORD(lParam) & 254;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
case WM_QUIT:
|
|
|
|
event.evt = KEYPRESS;
|
|
|
|
event.key = VK_ESCAPE;
|
2009-05-03 12:19:58 +00:00
|
|
|
return GSwndProc(hWnd, msg, wParam, lParam);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
default:
|
2009-02-09 21:15:56 +00:00
|
|
|
return GSwndProc(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
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);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
string GetKeyLabel(const int pad, const int index)
|
|
|
|
{
|
|
|
|
const int key = conf.keys[pad][index];
|
2009-05-03 12:19:58 +00:00
|
|
|
char buff[16] = "NONE)";
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
if (key < 0x100)
|
|
|
|
{
|
|
|
|
if (key == 0)
|
2009-05-03 12:19:58 +00:00
|
|
|
strcpy(buff, "NONE");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (key >= 0x60 && key <= 0x69)
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(buff, "NumPad %c", '0' + key - 0x60);
|
2009-05-03 12:19:58 +00:00
|
|
|
else
|
|
|
|
sprintf(buff, "%c", key);
|
|
|
|
}
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
else if (key >= 0x1000 && key < 0x2000)
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
sprintf(buff, "J%d_%d", (key & 0xfff) / 0x100, (key & 0xff) + 1);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
else if (key >= 0x2000 && key < 0x3000)
|
|
|
|
{
|
|
|
|
static const char name[][4] = { "MIN", "MAX" };
|
|
|
|
const int axis = (key & 0xff);
|
2009-05-03 12:19:58 +00:00
|
|
|
|
|
|
|
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';
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
else if (key >= 0x3000 && key < 0x4000)
|
|
|
|
{
|
|
|
|
static const char name[][7] = { "FOWARD", "RIGHT", "BACK", "LEFT" };
|
|
|
|
const int pov = (key & 0xff);
|
2009-05-03 12:19:58 +00:00
|
|
|
sprintf(buff, "J%d_POV%d_%s", (key & 0xfff) / 0x100, pov / 4, name[pov % 4]);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
return buff;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
HWND hWC;
|
2009-05-03 12:19:58 +00:00
|
|
|
TCITEM tcI;
|
|
|
|
int i, key, numkeys;
|
|
|
|
u8* pkeyboard;
|
|
|
|
static int disabled = 0;
|
|
|
|
static int padn = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
LoadConfig();
|
2009-05-03 12:19:58 +00:00
|
|
|
padn = 0;
|
|
|
|
if (conf.log) CheckDlgButton(hW, IDC_LOG, TRUE);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
for (i = 0; i < PADKEYS; i++)
|
|
|
|
{
|
|
|
|
hWC = GetDlgItem(hW, IDC_L2 + i * 2);
|
2009-02-09 21:15:56 +00:00
|
|
|
Button_SetText(hWC, GetKeyLabel(padn, i).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
hWC = GetDlgItem(hW, IDC_TABC);
|
|
|
|
|
|
|
|
tcI.mask = TCIF_TEXT;
|
|
|
|
tcI.pszText = "PAD 1";
|
|
|
|
|
|
|
|
TabCtrl_InsertItem(hWC, 0, &tcI);
|
|
|
|
|
|
|
|
tcI.mask = TCIF_TEXT;
|
|
|
|
tcI.pszText = "PAD 2";
|
|
|
|
|
|
|
|
TabCtrl_InsertItem(hWC, 1, &tcI);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_TIMER:
|
2009-05-03 12:19:58 +00:00
|
|
|
if (disabled)
|
|
|
|
{
|
|
|
|
key = 0;
|
|
|
|
//pkeyboard = SDL_GetKeyState(&numkeys);
|
|
|
|
for (int i = 0; i < numkeys; ++i)
|
|
|
|
{
|
|
|
|
if (pkeyboard[i])
|
|
|
|
{
|
|
|
|
key = i;
|
|
|
|
break;
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
|
|
|
|
if (key == 0)
|
|
|
|
{
|
|
|
|
// check joystick
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key != 0)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
KillTimer(hW, 0x80);
|
|
|
|
hWC = GetDlgItem(hW, disabled);
|
2009-05-03 12:19:58 +00:00
|
|
|
conf.keys[padn][disabled-IDC_L2] = key;
|
|
|
|
Button_SetText(hWC, GetKeyLabel(padn, disabled - IDC_L2).c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
EnableWindow(hWC, TRUE);
|
2009-05-03 12:19:58 +00:00
|
|
|
disabled = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
2009-05-03 12:19:58 +00:00
|
|
|
for (i = IDC_L2; i <= IDC_LEFT; i += 2)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
if (LOWORD(wParam) == i)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
if (disabled)//change selection
|
|
|
|
EnableWindow(GetDlgItem(hW, disabled), TRUE);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
EnableWindow(GetDlgItem(hW, disabled = wParam), FALSE);
|
|
|
|
|
|
|
|
SetTimer(hW, 0x80, 250, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
case IDCANCEL:
|
|
|
|
KillTimer(hW, 0x80);
|
|
|
|
EndDialog(hW, TRUE);
|
|
|
|
return TRUE;
|
2009-05-03 12:19:58 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
case IDOK:
|
|
|
|
KillTimer(hW, 0x80);
|
2009-05-03 12:19:58 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
if (IsDlgButtonChecked(hW, IDC_LOG))
|
2009-05-03 12:19:58 +00:00
|
|
|
conf.log = 1;
|
|
|
|
else
|
|
|
|
conf.log = 0;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
SaveConfig();
|
|
|
|
EndDialog(hW, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
break;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
2009-05-03 12:19:58 +00:00
|
|
|
switch (wParam)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
case IDC_TABC:
|
|
|
|
hWC = GetDlgItem(hW, IDC_TABC);
|
|
|
|
padn = TabCtrl_GetCurSel(hWC);
|
2009-05-03 12:19:58 +00:00
|
|
|
|
|
|
|
for (i = 0; i < PADKEYS; i++)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
hWC = GetDlgItem(hW, IDC_EL3 + i);
|
2009-05-03 12:19:58 +00:00
|
|
|
Button_SetText(hWC, GetKeyLabel(padn, i).c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
2009-05-03 12:19:58 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
case IDOK:
|
|
|
|
EndDialog(hW, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
void CALLBACK PADconfigure()
|
|
|
|
{
|
|
|
|
DialogBox(hInst,
|
|
|
|
MAKEINTRESOURCE(IDD_DIALOG1),
|
|
|
|
GetActiveWindow(),
|
|
|
|
(DLGPROC)ConfigureDlgProc);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
void CALLBACK PADabout()
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
SysMessage("Author: zerofrog\nThanks to SSSPSXPad, TwinPAD, and PADwin plugins");
|
|
|
|
}
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
s32 CALLBACK PADtest()
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
2009-05-03 12:19:58 +00:00
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpReserved)
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
hInst = (HINSTANCE)hModule;
|
|
|
|
return TRUE; // very quick :)
|
|
|
|
}
|