- added config keys for Guitar Grip;
This commit is contained in:
mtabachenko 2009-07-10 10:34:49 +00:00
parent c0e17f2a2b
commit 275cf18417
5 changed files with 268 additions and 5 deletions

View File

@ -57,7 +57,7 @@ static u32 guitarGrip_read32(u32 adr)
//INFO("GuitarGrip: read 32 at 0x%08X\n", adr);
return (0);
}
static void guitarGrip_info(char *info) { strcpy(info, "Guitar Grid for Guitar Hero games"); }
static void guitarGrip_info(char *info) { strcpy(info, "Guitar Grip for Guitar Hero games"); }
void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue)
{
@ -65,7 +65,7 @@ void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue)
}
ADDONINTERFACE addonGuitarGrip = {
"Guitar Grid",
"Guitar Grip",
guitarGrip_init,
guitarGrip_reset,
guitarGrip_close,

View File

@ -27,6 +27,7 @@
#include "debug.h"
#include "../addons.h"
#include "../NDSSystem.h"
#include "inputdx.h"
#include <shlobj.h>
WNDCLASSEX wc;
@ -39,6 +40,8 @@ char tmp_gbagame_filename[MAX_PATH] = { 0 };
ADDON_CFLASH_MODE tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath;
HWND OKbutton = NULL;
bool _OKbutton = false;
SGuitar tmp_Guitar;
bool needReset = true;
std::string CFlashPath, CFlashName;
@ -289,13 +292,60 @@ BOOL CALLBACK GbaSlotGBAgame(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
BOOL CALLBACK GbaSlotGuitarGrip(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
{
int which = 0;
switch(msg)
{
case WM_INITDIALOG:
{
_OKbutton = TRUE;
SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0);
SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0);
SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0);
SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0);
if (temp_type != addon_type)
needReset = true;
else
needReset = false;
return TRUE;
}
case WM_USER+46:
SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0);
SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0);
SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0);
SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0);
return TRUE;
case WM_USER+43:
//MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK);
which = GetDlgCtrlID((HWND)lparam);
switch(which)
{
case IDC_GGREEN:
tmp_Guitar.GREEN = wparam;
break;
case IDC_GRED:
tmp_Guitar.RED = wparam;
break;
case IDC_GYELLOW:
tmp_Guitar.YELLOW = wparam;
break;
case IDC_GBLUE:
tmp_Guitar.BLUE = wparam;
break;
}
SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0);
SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0);
SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0);
SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0);
PostMessage(dialog,WM_NEXTDLGCTL,0,0);
return true;
}
return FALSE;
}
@ -349,9 +399,9 @@ BOOL CALLBACK GbaSlotBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
case IDOK:
{
int Msg = IDYES;
if (romloaded)
if (romloaded && (needReset || (temp_type!=addon_type)) )
{
int Msg = MessageBox(dialog,
Msg = MessageBox(dialog,
"After change GBA slot pak game will reset!\nAre you sure to continue?", "DeSmuME",
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
}
@ -403,8 +453,10 @@ void GBAslotDialog(HWND hwnd)
strcpy(tmp_cflash_filename, CFlashName.c_str());
strcpy(tmp_cflash_path, CFlashPath.c_str());
strcpy(tmp_gbagame_filename, GBAgameName);
memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar));
tmp_CFlashMode = CFlash_Mode;
_OKbutton = false;
needReset == true;
u32 res=DialogBox(hAppInst, MAKEINTRESOURCE(IDD_GBASLOT), hwnd, (DLGPROC) GbaSlotBox_Proc);
if (res)
{
@ -432,6 +484,11 @@ void GBAslotDialog(HWND hwnd)
WritePrivateProfileString("GBAslot.GBAgame","filename",GBAgameName,IniName);
break;
case NDS_ADDON_GUITARGRIP:
memcpy(&Guitar, &tmp_Guitar, sizeof(tmp_Guitar));
WritePrivateProfileInt("GBAslot.GuitarGrip","green",Guitar.GREEN,IniName);
WritePrivateProfileInt("GBAslot.GuitarGrip","red",Guitar.RED,IniName);
WritePrivateProfileInt("GBAslot.GuitarGrip","yellow",Guitar.YELLOW,IniName);
WritePrivateProfileInt("GBAslot.GuitarGrip","blue",Guitar.BLUE,IniName);
break;
default:
return;
@ -440,7 +497,8 @@ void GBAslotDialog(HWND hwnd)
addon_type = temp_type;
addonsChangePak(addon_type);
if (romloaded)
if (romloaded && needReset)
NDS_Reset();
return;
}
}

View File

@ -198,9 +198,11 @@
static TCHAR szClassName[] = _T("InputCustom");
static TCHAR szHotkeysClassName[] = _T("InputCustomHot");
static TCHAR szGuitarClassName[] = _T("InputCustomGuitar");
static LRESULT CALLBACK InputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK HotInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK GuitarInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
SJoyState Joystick [16];
SJoyState JoystickF [16];
@ -239,6 +241,11 @@ SJoypad DefaultJoypad[16] = {
SJoypad Joypad[16];
SGuitar DefaultGuitar = { true, 'E', 'R', 'T', 'Y' };
SGuitar Guitar;
u8 guitarState = 0;
extern volatile BOOL paused;
#define MAXKEYPAD 15
@ -345,6 +352,15 @@ static void ReadHotkey(const char* name, WORD& output)
}
}
static void ReadGuitarControl(const char* name, WORD& output)
{
UINT temp;
temp = GetPrivateProfileInt("GBAslot.GuitarGrip",name,-1,IniName);
if(temp != -1) {
output = temp;
}
}
static void LoadHotkeyConfig()
{
SCustomKey *key = &CustomKeys.key(0);
@ -369,6 +385,19 @@ static void SaveHotkeyConfig()
}
}
static void LoadGuitarConfig()
{
memcpy(&Guitar,&DefaultGuitar,sizeof(Guitar));
Guitar.Enabled = true;
#define DO(X) ReadControl(#X,Guitar.X);
DO(GREEN);
DO(RED);
DO(YELLOW);
DO(BLUE);
#undef DO
}
static void LoadInputConfig()
{
memcpy(&Joypad,&DefaultJoypad,sizeof(Joypad));
@ -1140,6 +1169,21 @@ static void InitCustomControls()
RegisterClassEx(&wc);
wc.cbSize = sizeof(wc);
wc.lpszClassName = szGuitarClassName;
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = GuitarInputCustomWndProc;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = 0;
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(InputCust *);
wc.hIconSm = 0;
RegisterClassEx(&wc);
}
InputCust * GetInputCustom(HWND hwnd)
@ -1341,6 +1385,148 @@ static LRESULT CALLBACK InputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
return DefWindowProc(hwnd, msg, wParam, lParam);
}
static LRESULT CALLBACK GuitarInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// retrieve the custom structure POINTER for THIS window
InputCust *icp = GetInputCustom(hwnd);
HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT);
funky= hwnd;
static HWND selectedItem = NULL;
char temp[100];
COLORREF col;
switch(msg)
{
case WM_GETDLGCODE:
return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS;
break;
case WM_NCCREATE:
// Allocate a new CustCtrl structure for this window.
icp = (InputCust *) malloc( sizeof(InputCust) );
// Failed to allocate, stop window creation.
if(icp == NULL) return FALSE;
// Initialize the CustCtrl structure.
icp->hwnd = hwnd;
icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT);
icp->crBackGnd = GetSysColor(COLOR_WINDOW);
icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT);
// Assign the window text specified in the call to CreateWindow.
SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName);
// Attach custom structure to this window.
SetInputCustom(hwnd, icp);
InvalidateRect(icp->hwnd, NULL, FALSE);
UpdateWindow(icp->hwnd);
selectedItem = NULL;
SetTimer(hwnd,777,125,NULL);
// Continue with window creation.
return TRUE;
// Clean up when the window is destroyed.
case WM_NCDESTROY:
free(icp);
break;
case WM_PAINT:
return InputCustom_OnPaint(icp,wParam,lParam);
break;
case WM_ERASEBKGND:
return 1;
case WM_USER+45:
case WM_KEYDOWN:
TranslateKey(wParam,temp);
col = CheckButtonKey(wParam);
icp->crForeGnd = ((~col) & 0x00ffffff);
icp->crBackGnd = col;
SetWindowText(hwnd,temp);
InvalidateRect(icp->hwnd, NULL, FALSE);
UpdateWindow(icp->hwnd);
SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd);
break;
case WM_USER+44:
TranslateKey(wParam,temp);
if(IsWindowEnabled(hwnd))
{
col = CheckButtonKey(wParam);
}
else
{
col = RGB( 192,192,192);
}
icp->crForeGnd = ((~col) & 0x00ffffff);
icp->crBackGnd = col;
SetWindowText(hwnd,temp);
InvalidateRect(icp->hwnd, NULL, FALSE);
UpdateWindow(icp->hwnd);
break;
case WM_SETFOCUS:
{
selectedItem = hwnd;
col = RGB( 0,255,0);
icp->crForeGnd = ((~col) & 0x00ffffff);
icp->crBackGnd = col;
InvalidateRect(icp->hwnd, NULL, FALSE);
UpdateWindow(icp->hwnd);
// tid = wParam;
break;
}
case WM_KILLFOCUS:
{
selectedItem = NULL;
SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect
break;
}
case WM_TIMER:
if(hwnd == selectedItem)
{
FunkyJoyStickTimer();
}
SetTimer(hwnd,777,125,NULL);
break;
case WM_LBUTTONDOWN:
SetFocus(hwnd);
break;
case WM_ENABLE:
COLORREF col;
if(wParam)
{
col = RGB( 255,255,255);
icp->crForeGnd = ((~col) & 0x00ffffff);
icp->crBackGnd = col;
}
else
{
col = RGB( 192,192,192);
icp->crForeGnd = ((~col) & 0x00ffffff);
icp->crBackGnd = col;
}
InvalidateRect(icp->hwnd, NULL, FALSE);
UpdateWindow(icp->hwnd);
return true;
default:
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
static void TranslateKeyWithModifiers(int wParam, int modifiers, char * outStr)
{
@ -2171,6 +2357,7 @@ void input_init()
LoadInputConfig();
LoadHotkeyConfig();
LoadGuitarConfig();
di_init();
FeedbackON = input_feedback;
@ -2213,6 +2400,14 @@ void input_process()
NDS_setPad( R, L, D, U, T, S, B, A, Y, X, W, E, G, F);
if (Guitar.Enabled)
{
bool gG=!S9xGetState(Guitar.GREEN);
bool gR=!S9xGetState(Guitar.RED);
bool gY=!S9xGetState(Guitar.YELLOW);
bool gB=!S9xGetState(Guitar.BLUE);
guitarGrip_setKey(gG, gR, gY, gB);
}
}
static void set_hotkeyinfo(HWND hDlg)

View File

@ -112,6 +112,16 @@ void RunInputConfig();
void RunHotkeyConfig();
void input_process();
struct SGuitar {
BOOL Enabled;
WORD GREEN;
WORD RED;
WORD YELLOW;
WORD BLUE;
};
extern SGuitar Guitar;
#endif

Binary file not shown.