win32: pass #1 of adding snes9x input configuration - input binding system and dialog implemented, meshed with our directinput joystick system for rumble support. I have no rumble pad; can someone test it?

This commit is contained in:
zeromus 2009-02-10 06:47:06 +00:00
parent b24f4fe17e
commit 07ca5cc0a3
7 changed files with 2728 additions and 677 deletions

View File

@ -572,6 +572,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\main.h"
>
</File>
<File
RelativePath=".\mapView.cpp"
>

File diff suppressed because it is too large Load Diff

View File

@ -1,78 +1,325 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
Copyright (C) 2006-2008 DeSmuME team
This file is part of DeSmuME
DeSmuME 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.
DeSmuME 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 DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _INPUT_DX_
#define _INPUT_DX_
#define DIRECTINPUT_VERSION 0x0800
#include "../common.h"
#include "../types.h"
#include "directx/dinput.h"
#define MAXKEYPAD 15
typedef void (*INPUTPROC)(BOOL, LPSTR);
class DI_CLASS
{
friend BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
friend BOOL CALLBACK EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext);
public:
char JoystickName[255];
BOOL Feedback;
LPDIRECTINPUTDEVICE8 EnumDevices(LPDIRECTINPUT8 pDI);
protected:
BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
BOOL CALLBACK EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext);
};
class INPUTCLASS : private DI_CLASS
{
private:
HWND hParentWnd;
BOOL paused;
char cDIBuf[512];
LPDIRECTINPUT8 pDI;
LPDIRECTINPUTDEVICE8 pKeyboard;
LPDIRECTINPUTDEVICE8 pJoystick;
DIDEVCAPS DIJoycap;
LPDIRECTINPUTEFFECT pEffect;
INPUTPROC inputProc;
public:
INPUTCLASS();
~INPUTCLASS();
BOOL Init(HWND hParentWnd, INPUTPROC inputProc);
BOOL JoystickEnabled();
void JoystickFeedback(BOOL on);
void process();
};
// ========== emu input
extern void InputConfig(HWND hwnd);
extern void NDS_inputInit();
extern void NDS_inputPost(BOOL paused, LPSTR buf);
extern u16 keyPad[MAXKEYPAD];
#endif
///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are
// licensed under the terms supplied at the end of this file (for the terms are very long!)
// Differences from that baseline version are:
//
// Copyright (C) 2009 DeSmuME team
//
// DeSmuME 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.
//
// DeSmuME 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 DeSmuME; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//*/
#ifndef INPUTDX_INCLUDED
#define INPUTDX_INCLUDED
void InitInputCustomControl(void);
HWND CreateInputCustom(HWND hwndParent);
void InitKeyCustomControl(void);
HWND CreateKeyCustom(HWND hwndParent);
typedef struct
{
COLORREF crForeGnd; // Foreground text colour
COLORREF crBackGnd; // Background text colour
HFONT hFont; // The font
HWND hwnd; // The control's window handle
} InputCust;
COLORREF CheckButtonKey( WORD Key);
COLORREF CheckHotKey( WORD Key, int modifiers);
InputCust * GetInputCustom(HWND hwnd);
#define CUSTKEY_ALT_MASK 0x01
#define CUSTKEY_CTRL_MASK 0x02
#define CUSTKEY_SHIFT_MASK 0x04
struct SCustomKey {
WORD key;
WORD modifiers;
};
struct SCustomKeys {
SCustomKey SpeedUp;
SCustomKey SpeedDown;
SCustomKey Pause;
SCustomKey FrameAdvance;
SCustomKey SkipUp;
SCustomKey SkipDown;
SCustomKey ScopeTurbo;
SCustomKey ScopePause;
SCustomKey FrameCount;
SCustomKey ReadOnly;
SCustomKey Save [10];
SCustomKey Load [10];
SCustomKey FastForward;
SCustomKey ShowPressed;
SCustomKey SaveScreenShot;
SCustomKey SlotPlus;
SCustomKey SlotMinus;
SCustomKey SlotSave;
SCustomKey SlotLoad;
SCustomKey BGL1;
SCustomKey BGL2;
SCustomKey BGL3;
SCustomKey BGL4;
SCustomKey BGL5;
SCustomKey ClippingWindows;
// SCustomKey BGLHack;
SCustomKey Transparency;
SCustomKey HDMA;
SCustomKey GLCube;
// SCustomKey InterpMode7;
SCustomKey JoypadSwap;
SCustomKey SwitchControllers;
SCustomKey TurboA, TurboB, TurboY, TurboX, TurboL, TurboR, TurboStart, TurboSelect, TurboLeft, TurboUp, TurboRight, TurboDown;
SCustomKey SelectSave [10];
SCustomKey ResetGame;
SCustomKey ToggleCheats;
SCustomKey ToggleSound [8];
SCustomKey ToggleMacro [8];
SCustomKey EditMacro;
};
struct SJoypad {
BOOL Enabled;
WORD Left;
WORD Right;
WORD Up;
WORD Down;
WORD Left_Up;
WORD Left_Down;
WORD Right_Up;
WORD Right_Down;
WORD Start;
WORD Select;
WORD Lid;
WORD Debug;
WORD A;
WORD B;
WORD X;
WORD Y;
WORD L;
WORD R;
};
#define LEFT_MASK 0x0001
#define RIGHT_MASK 0x0002
#define UP_MASK 0x0004
#define DOWN_MASK 0x0008
#define START_MASK 0x0010
#define SELECT_MASK 0x0020
#define LID_MASK 0x0040
#define DEBUG_MASK 0x0080
#define A_MASK 0x0100
#define B_MASK 0x0200
#define X_MASK 0x0400
#define Y_MASK 0x0800
#define L_MASK 0x1000
#define R_MASK 0x2000
struct SJoyState{
bool Attached;
//JOYCAPS Caps;
int Threshold;
bool Left;
bool Right;
bool Up;
bool Down;
bool PovLeft;
bool PovRight;
bool PovUp;
bool PovDown;
bool PovDnLeft;
bool PovDnRight;
bool PovUpLeft;
bool PovUpRight;
bool RUp;
bool RDown;
bool UUp;
bool UDown;
bool VUp;
bool VDown;
bool ZUp;
bool ZDown;
bool Button[32];
};
extern SJoypad Joypad[16];
extern SJoypad ToggleJoypadStorage[8];
extern SCustomKeys CustomKeys;
extern SJoypad TurboToggleJoypadStorage[8];
#endif
/**********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2007 zones
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
**********************************************************************************/

View File

@ -116,7 +116,7 @@ LPDIRECTDRAWCLIPPER lpDDClipPrimary=NULL;
LPDIRECTDRAWCLIPPER lpDDClipBack=NULL;
//===================== Input vars
INPUTCLASS *input = NULL;
//INPUTCLASS *input = NULL;
#ifndef EXPERIMENTAL_GBASLOT
/* The compact flash disk image file */
@ -814,7 +814,10 @@ DWORD WINAPI run()
// if (!skipnextframe)
// {
input->process();
//input->process();
//TODO INPUT
void input_process();
input_process();
if (FpsDisplay) osd->addFixed(0, 5, "%02d Fps", fps);
osd->update();
@ -1141,6 +1144,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
}
InitializeCriticalSection(&win_sync);
InitInputCustomControl();
InitKeyCustomControl();
#ifdef GDB_STUB
gdbstub_handle_t arm9_gdb_stub;
@ -1282,13 +1287,16 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
LOG("Init NDS\n");
input = new INPUTCLASS();
if (!input->Init(MainWindow->getHWnd(), &NDS_inputPost))
{
MessageBox(NULL, "Error DXInput init\n", "DeSmuME", MB_OK);
exit(-1);
}
NDS_inputInit();
//input = new INPUTCLASS();
//if (!input->Init(MainWindow->getHWnd(), &NDS_inputPost))
//{
// MessageBox(NULL, "Error DXInput init\n", "DeSmuME", MB_OK);
// exit(-1);
//}
//NDS_inputInit();
void input_init();
input_init();
ViewDisasm_ARM7 = new TOOLSCLASS(hThisInstance, IDD_DESASSEMBLEUR_VIEWER7, (DLGPROC) ViewDisasm_ARM7Proc);
ViewDisasm_ARM9 = new TOOLSCLASS(hThisInstance, IDD_DESASSEMBLEUR_VIEWER9, (DLGPROC) ViewDisasm_ARM9Proc);
@ -1456,7 +1464,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
#ifdef DEBUG
//LogStop();
#endif
if (input!=NULL) delete input;
//if (input!=NULL) delete input;
if (ViewLights!=NULL) delete ViewLights;
if (ViewMatrices!=NULL) delete ViewMatrices;
if (ViewOAM!=NULL) delete ViewOAM;
@ -2418,7 +2426,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
tpaused=true;
NDS_Pause();
}
InputConfig(hwnd);
//InputConfig(hwnd);
void RunInputConfig();
RunInputConfig();
if (tpaused)
NDS_UnPause();
}

View File

@ -0,0 +1,7 @@
#ifndef _MAIN_H_
#define _MAIN_H_
#include "CWindow.h"
extern WINCLASS *MainWindow;
#endif

View File

@ -16,7 +16,6 @@
#define IDC_AUTO_UPDATE 108
#define IDM_MEMORY 109
#define IDM_DISASSEMBLER 110
#define IDC_AUTO_UPDATE2 111
#define IDD_3DSETTINGS 111
#define IDM_GAME_INFO 111
#define IDD_GBASLOT 113
@ -208,7 +207,6 @@
#define IDC_AUTOUPDATE_ASM 1018
#define IDC_BGMAP_PRIO 1018
#define IDC_BGMAP_PAL 1019
#define IDC_VISIBLE 1019
#define IDC_BGMAP_SIZE 1020
#define IDC_IPCFIFO9 1020
#define IDC_BGMAP_SCROLL 1021
@ -382,7 +380,6 @@
#define IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL 1332
#define IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT 1333
#define IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT 1334
#define IDM_ABOUT 40003
#define ACCEL_P 40004
#define ACCEL_SPACEBAR 40005
#define ACCEL_N 40007
@ -403,7 +400,6 @@
#define ACCEL_9 40030
#define ACCEL_CTRL_O 40032
#define ID_FILE_RECENTROM 40034
#define IDC_SAVETYPE7 40037
#define IDM_DEFSIZE 40038
#define IDM_3DCONFIG 40040
#define IDM_GBASLOT 40042
@ -411,3 +407,46 @@
#define IDC_BGMAP_ROTSCALEPARAMS 40051
#define IDM_CHEATS_SEARCH 40051
#define IDC_BGMAP_ROTSCALE 40052
#define IDC_LABEL_UP 50000
#define IDC_LABEL_RIGHT 50001
#define IDC_LABEL_LEFT 50002
#define IDC_LABEL_DOWN 50003
#define IDC_LABEL_A 50004
#define IDC_LABEL_X 50005
#define IDC_LABEL_B 50006
#define IDC_LABEL_Y 50007
#define IDC_LABEL_L 50008
#define IDC_LABEL_START 50009
#define IDC_LABEL_R 50010
#define IDC_LABEL_SELECT 50011
#define IDC_LABEL_UPLEFT 50012
#define IDC_LABEL_DOWNRIGHT 50013
#define IDC_LABEL_UPRIGHT 50014
#define IDC_LABEL_DOWNLEFT 50015
#define IDC_ALLOWLEFTRIGHT 50016
#define IDC_LABEL_X3 50017
#define IDC_LABEL_X2 50018
#define IDC_DEBUG 50019
#define IDC_UP 50020
#define IDC_LEFT 50021
#define IDC_DOWN 50022
#define IDC_RIGHT 50023
#define IDC_B 50024
#define IDC_A 50025
#define IDC_Y 50026
#define IDC_X 50027
#define IDC_START 50028
#define IDC_SELECT 50029
#define IDC_L 50030
#define IDC_R 50031
#define IDC_UPLEFT 50032
#define IDC_UPRIGHT 50033
#define IDC_DWNRIGHT 50034
#define IDC_DWNLEFT 50035
#define IDC_LABEL_BLUE 50036
#define IDC_LID 50037
#define IDD_INPUTCONFIG 50038
#define IDC_SAVETYPE7 40037
#define IDC_AUTO_UPDATE2 111
#define IDC_VISIBLE 1019
#define IDM_ABOUT 40003

View File

@ -2271,6 +2271,53 @@ BEGIN
LTEXT "secs", IDC_STATIC, 428, 167, 16, 8, SS_LEFT
END
IDD_INPUTCONFIG DIALOGEX 0, 0, 339, 148
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Control Config"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "WOG!",IDC_UP,"InputCustom",WS_TABSTOP,52,15,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_LEFT,"InputCustom",WS_TABSTOP,52,29,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_DOWN,"InputCustom",WS_TABSTOP,52,42,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_RIGHT,"InputCustom",WS_TABSTOP,52,55,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_B,"InputCustom",WS_TABSTOP,52,68,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_A,"InputCustom",WS_TABSTOP,52,81,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_Y,"InputCustom",WS_TABSTOP,52,94,71,12,WS_EX_CLIENTEDGE
CONTROL "",IDC_X,"InputCustom",WS_TABSTOP,52,107,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_START,"InputCustom",WS_TABSTOP,163,15,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_SELECT,"InputCustom",WS_TABSTOP,163,29,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_L,"InputCustom",WS_TABSTOP,163,42,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_R,"InputCustom",WS_TABSTOP,163,55,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_UPLEFT,"InputCustom",WS_DISABLED | WS_TABSTOP,163,68,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_UPRIGHT,"InputCustom",WS_DISABLED | WS_TABSTOP,163,81,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_DWNRIGHT,"InputCustom",WS_DISABLED | WS_TABSTOP,163,94,71,12,WS_EX_CLIENTEDGE
CONTROL " ",IDC_DWNLEFT,"InputCustom",WS_DISABLED | WS_TABSTOP,163,107,71,12,WS_EX_CLIENTEDGE
PUSHBUTTON "Cancel",IDCANCEL,293,119,39,14
PUSHBUTTON "OK",IDOK,245,119,41,14
LTEXT "Blue means the button is already mapped.\nPink means it conflicts with a custom hotkey.\nRed means it's reserved by Windows.\nButtons can be disabled using Escape.\nGrayed buttons arent supported yet (sorry!)",IDC_LABEL_BLUE,246,10,80,88
RTEXT "UP",IDC_LABEL_UP,10,18,38,8
RTEXT "RIGHT",IDC_LABEL_RIGHT,8,58,41,8
RTEXT "LEFT",IDC_LABEL_LEFT,11,31,37,8
RTEXT "DOWN",IDC_LABEL_DOWN,10,45,39,8
RTEXT "A",IDC_LABEL_A,10,83,38,8
RTEXT "X",IDC_LABEL_X,8,109,39,8
RTEXT "B",IDC_LABEL_B,11,71,37,8
RTEXT "Y",IDC_LABEL_Y,8,97,40,8
RTEXT "L",IDC_LABEL_L,136,44,24,8
RTEXT "START",IDC_LABEL_START,136,18,24,8
RTEXT "R",IDC_LABEL_R,136,57,24,8
RTEXT "SELECT",IDC_LABEL_SELECT,132,31,28,8
RTEXT "UP LEFT",IDC_LABEL_UPLEFT,130,71,30,8
RTEXT "DN RIGHT",IDC_LABEL_DOWNRIGHT,124,97,36,8
RTEXT "UP RIGHT",IDC_LABEL_UPRIGHT,124,84,36,8
RTEXT "DN LEFT",IDC_LABEL_DOWNLEFT,129,109,31,8
CONTROL "Allow Left+Rt/Up+Dn",IDC_ALLOWLEFTRIGHT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,245,102,87,11
GROUPBOX "Buttons",IDC_STATIC,7,7,234,129,0,WS_EX_TRANSPARENT
CONTROL "",IDC_LID,"InputCustom",WS_TABSTOP,52,120,71,12,WS_EX_CLIENTEDGE
RTEXT "LID",IDC_LABEL_X2,8,121,39,8
RTEXT "DEBUG",IDC_LABEL_X3,127,123,29,8
CONTROL " ",IDC_DEBUG,"InputCustom",WS_DISABLED | WS_TABSTOP,163,120,71,12,WS_EX_CLIENTEDGE
END
//