From c967d4f46e365c661e50c087b5f683ecada412b0 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Mon, 11 May 2015 22:39:29 +0200 Subject: [PATCH] Added N64 Mouse support in NRage --- Source/nragev20/FileAccess.cpp | 5 ++ Source/nragev20/FileAccess.h | 2 + Source/nragev20/Interface.cpp | 5 ++ Source/nragev20/NRagePluginV2.cpp | 7 ++- Source/nragev20/NRagePluginV2.h | 1 + Source/nragev20/NRagePluginV2.rc | 87 ++++++++++++++++--------------- Source/nragev20/resource.h | 9 +++- 7 files changed, 72 insertions(+), 44 deletions(-) diff --git a/Source/nragev20/FileAccess.cpp b/Source/nragev20/FileAccess.cpp index a08104dac..122637baa 100644 --- a/Source/nragev20/FileAccess.cpp +++ b/Source/nragev20/FileAccess.cpp @@ -253,6 +253,10 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic if (pController) pController->fXInput = atoi(pszLine); break; + case CHK_N64MOUSE: + if (pController) + pController->fN64Mouse = atoi(pszLine); + break; case CHK_PAKTYPE: if (pController) pController->PakType = atoi(pszLine); @@ -1485,6 +1489,7 @@ void DumpControllerSettings(FILE * fFile, int i, bool bIsINI) fprintf(fFile, STRING_INI_PLUGGED "=%u\n", g_ivConfig->Controllers[i].fPlugged); fprintf(fFile, STRING_INI_XINPUT "=%u\n", g_ivConfig->Controllers[i].fXInput); + fprintf(fFile, STRING_INI_N64MOUSE "=%u\n", g_ivConfig->Controllers[i].fN64Mouse); fprintf(fFile, STRING_INI_RAWDATA "=%u\n", g_ivConfig->Controllers[i].fRawData); fprintf(fFile, STRING_INI_PAKTYPE "=%u\n", g_ivConfig->Controllers[i].PakType); fprintf(fFile, STRING_INI_REALN64RANGE "=%u\n", g_ivConfig->Controllers[i].fRealN64Range); diff --git a/Source/nragev20/FileAccess.h b/Source/nragev20/FileAccess.h index 2a4ec74fd..fbd3e8217 100644 --- a/Source/nragev20/FileAccess.h +++ b/Source/nragev20/FileAccess.h @@ -86,6 +86,7 @@ unsigned long djbHash(const char *str); #define STRING_INI_PLUGGED "Plugged" #define STRING_INI_XINPUT "xInput" +#define STRING_INI_N64MOUSE "N64Mouse" #define STRING_INI_RAWDATA "RawData" #define STRING_INI_PAKTYPE "PakType" #define STRING_INI_REALN64RANGE "RealN64Range" @@ -154,6 +155,7 @@ unsigned long djbHash(const char *str); #define CHK_PLUGGED 3378836077 #define CHK_XINPUT 3665436173 +#define CHK_N64MOUSE 863329606 #define CHK_RAWDATA 1238573385 #define CHK_PAKTYPE 2936974691 #define CHK_REALN64RANGE 1279831790 diff --git a/Source/nragev20/Interface.cpp b/Source/nragev20/Interface.cpp index 7f8941861..88073aabf 100644 --- a/Source/nragev20/Interface.cpp +++ b/Source/nragev20/Interface.cpp @@ -548,6 +548,10 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return TRUE; // END IDC_XINPUT_ENABLER + case IDC_N64MOUSE: + pcController->fN64Mouse = (IsDlgButtonChecked(hDlg, LOWORD(wParam)) == BST_CHECKED); + return TRUE; + default: return FALSE; } @@ -556,6 +560,7 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // for this dialog CheckDlgButton( hDlg, IDC_PLUGGED, pcController->fPlugged ? BST_CHECKED : BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_XINPUT_ENABLER, pcController->fXInput ? BST_CHECKED : BST_UNCHECKED ); + CheckDlgButton( hDlg, IDC_N64MOUSE, pcController->fN64Mouse ? BST_CHECKED : BST_UNCHECKED); if( hTabControl ) DestroyWindow( hTabControl ); diff --git a/Source/nragev20/NRagePluginV2.cpp b/Source/nragev20/NRagePluginV2.cpp index 970013e0d..f008f8d25 100644 --- a/Source/nragev20/NRagePluginV2.cpp +++ b/Source/nragev20/NRagePluginV2.cpp @@ -602,9 +602,14 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) #ifdef ENABLE_RAWPAK_DEBUG WriteDatasA( "GetStatus-PreProcessing", Control, Command, 0); #endif - Command[3] = RD_GAMEPAD | RD_ABSOLUTE; + Command[3] = RD_GAMEPAD; Command[4] = RD_NOEEPROM; + if (g_pcControllers[Control].fN64Mouse) // Is Controller a mouse? + Command[3] |= RD_RELATIVE; + else + Command[3] |= RD_ABSOLUTE; + if( g_pcControllers[Control].fPakInitialized && g_pcControllers[Control].pPakData ) { if( *(BYTE*)g_pcControllers[Control].pPakData == PAK_ADAPTOID ) diff --git a/Source/nragev20/NRagePluginV2.h b/Source/nragev20/NRagePluginV2.h index 06057dd9f..a8eedefd4 100644 --- a/Source/nragev20/NRagePluginV2.h +++ b/Source/nragev20/NRagePluginV2.h @@ -126,6 +126,7 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER { unsigned fPlugged; // is the controller "plugged" (i.e. does the emulator see a controller on this port?) unsigned fXInput; // is the controller an xInput device? + unsigned fN64Mouse; // is the controller a N64 Mouse (Relative)? unsigned fRawData; // are we using RAW mode for this controller? unsigned fIsAdaptoid; // is it an adaptoid? diff --git a/Source/nragev20/NRagePluginV2.rc b/Source/nragev20/NRagePluginV2.rc index 07d4cafa4..a428d30c8 100644 --- a/Source/nragev20/NRagePluginV2.rc +++ b/Source/nragev20/NRagePluginV2.rc @@ -1,7 +1,6 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" -#include "Version.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -31,7 +30,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_MAINCFGDIALOG, DIALOG BEGIN @@ -179,12 +178,13 @@ EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN CONTROL "Plugged",IDC_PLUGGED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,45,13 - PUSHBUTTON "Clear Controller",IDC_CLEARCONTROLLER,63,7,67,13 - PUSHBUTTON "Default Config",IDC_SETDEFAULT,63,21,67,13 + PUSHBUTTON "Clear Controller",IDC_CLEARCONTROLLER,104,7,67,13 + PUSHBUTTON "Default Config",IDC_SETDEFAULT,104,21,67,13 PUSHBUTTON "Load Profile",IDC_LOADPROFILE,191,7,67,13 PUSHBUTTON "Save Profile",IDC_SAVEPROFILE,272,7,67,13 CONTROL "PLACEHOLDER",IDC_CONTROLLERTAB,"SysTabControl32",WS_GROUP | WS_TABSTOP,0,38,375,196 CONTROL "XInput",IDC_XINPUT_ENABLER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,22,37,10 + CONTROL "N64 Mouse",IDC_N64MOUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,22,51,10 END IDD_SHORTCUT DIALOGEX 0, 0, 376, 235 @@ -524,25 +524,29 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION VER_FILE_VERSION - PRODUCTVERSION VER_PRODUCT_VERSION - FILEFLAGSMASK 0x3fL - FILEFLAGS VER_FILEFLAGS - FILEOS VER_FILEOS - FILETYPE VER_FILETYPE - FILESUBTYPE 0x0L + FILEVERSION 2,4,0,4 + PRODUCTVERSION 2,4,0,4 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "000004b0" BEGIN - VALUE "FileDescription", VER_FILE_DESCRIPTION_STR "\0" - VALUE "FileVersion", VER_FILE_VERSION_STR "\0" - VALUE "InternalName", VER_INTERNAL_NAME_STR "\0" - VALUE "LegalCopyright", VER_COPYRIGHT_STR "\0" - VALUE "OriginalFilename", VER_ORIGINAL_FILENAME_STR "\0" - VALUE "ProductName", VER_PRODUCTNAME_STR - VALUE "ProductVersion", VER_PRODUCT_VERSION_STR "\0" + VALUE "FileDescription", "N-Rage for Project64" + VALUE "FileVersion", "2.4.0.4" + VALUE "InternalName", "N-Rage" + VALUE "LegalCopyright", "Copyright (C) 2015" + VALUE "OriginalFilename", "N-Rage.dll" + VALUE "ProductName", "N-Rage" + VALUE "ProductVersion", "2.4.0.4" END END BLOCK "VarFileInfo" @@ -551,6 +555,7 @@ BEGIN END END + ///////////////////////////////////////////////////////////////////////////// // // PROFILE @@ -578,13 +583,13 @@ END 2 TEXTINCLUDE BEGIN - "#include ""WinResrc.h""\r\n" - "\r\n" - "#ifdef IDC_STATIC\r\n" - "#undef IDC_STATIC\r\n" - "#endif\r\n" - "#define IDC_STATIC (-1)\r\n" - "\0" + "#include ""WinResrc.h""\r\n" + "\r\n" + "#ifdef IDC_STATIC\r\n" + "#undef IDC_STATIC\r\n" + "#endif\r\n" + "#define IDC_STATIC (-1)\r\n" + "\0" END 3 TEXTINCLUDE @@ -601,14 +606,14 @@ END // String Table // -STRINGTABLE +STRINGTABLE BEGIN IDS_ERR_DINOTFOUND "dinput8.dll could not be found.\nPlease reinstall the latest version of DirectX." IDS_ERR_DICREATE "Could not create DirectInput object." IDS_DLG_MPCHOOSE "Choose a MemPak or type a new name to create one." END -STRINGTABLE +STRINGTABLE BEGIN IDS_ERR_MPREAD "Couldn't read MemPak." IDS_ERR_GBROM "Can't open GB ROM file!" @@ -628,7 +633,7 @@ BEGIN IDS_ERR_PROFREAD "Couldn't read profile." END -STRINGTABLE +STRINGTABLE BEGIN IDS_C_POLLING "...Awaiting Input %i..." IDS_C_RANGE "Range: %i%%" @@ -648,7 +653,7 @@ BEGIN IDS_M_MACRO "Macro" END -STRINGTABLE +STRINGTABLE BEGIN IDS_M_CONFIG "Configuration" IDS_M_ASSIGNED "Assigned to" @@ -668,7 +673,7 @@ BEGIN IDS_P_ADAPTOID_NORAW "The AdaptoidPak needs RawMode to be activated." END -STRINGTABLE +STRINGTABLE BEGIN IDS_P_NONE_RAWNORAW "No Pak inserted." IDS_P_MEM_NOCHANGE "Can't change dir while running." @@ -688,7 +693,7 @@ BEGIN IDS_DLG_SHORTCUTRESTORE "The shortcut configuration will be restored.\nAre you sure?" END -STRINGTABLE +STRINGTABLE BEGIN IDS_DLG_SHORTCUTRESTORE_TITLE "Restore default" IDS_C_GAMEPAD "Gamepad: " @@ -708,7 +713,7 @@ BEGIN IDS_DLG_ABOUT "Help us translate N-Rage Input V2 into your language!" END -STRINGTABLE +STRINGTABLE BEGIN IDS_DLG_ABOUT_TITLE "About N-Rage Input V2" IDS_ERR_NOINIT "Plugin didn't get initialized!" @@ -716,11 +721,11 @@ BEGIN IDS_POP_MOUSELOCKED "Mouse Locked" IDS_POP_CHANGEPAK "Player %i:\nPak changed to %s" IDS_ERR_MAPVIEW "Couldn't MapViewOfFile" - IDS_DLG_CPF "Controller Profile (*.cpf)\0*.cpf" - IDS_DLG_MPKN64 "MemPak (*.mpk)\0*.mpk\0Dexdrive Save (*.n64)\0*.n64" - IDS_DLG_A64 "MemPak Note (*.a64)\0*.a64" - IDS_DLG_GBGBC "GameBoy ROM (*.gb;*.gbc)\0*.gb;*.gbc" - IDS_DLG_SVSAV "GameBoy Save (*.sv;*.sav)\0*.sv;*.sav" + IDS_DLG_CPF "Controller Profile (*.cpf)" + IDS_DLG_MPKN64 "MemPak (*.mpk)" + IDS_DLG_A64 "MemPak Note (*.a64)" + IDS_DLG_GBGBC "GameBoy ROM (*.gb;*.gbc)" + IDS_DLG_SVSAV "GameBoy Save (*.sv;*.sav)" IDS_ERR_HANDLER "%s\n\n Error description: " IDS_ERR_MEM_NOSPEC "No MemPak specified; please configure plugin." IDS_DLG_MEM_READONLY "Mempak %s opened with read-only access.\nAfter exiting the game, the MemPak will NOT be saved." @@ -729,7 +734,7 @@ BEGIN "Bad AddressCRC detected!\nThis usually indicates a bad ROM.\n\nIgnore it and continue?" END -STRINGTABLE +STRINGTABLE BEGIN IDS_P_MEM_NOREGION "None" IDS_P_MEM_BETA "Beta" @@ -749,7 +754,7 @@ BEGIN IDS_ERR_MEMPAK_NONOTES "No free notes on MemPak (only 16 notes available per pak)." END -STRINGTABLE +STRINGTABLE BEGIN IDS_ERR_NOTEEOF "Error reading note file: unexpected end of file or read error." IDS_ERR_NOTEREAD "Couldn't read note file." @@ -758,7 +763,7 @@ BEGIN IDS_DLG_WARN_TITLE "N-Rage Input V2 Warning" IDS_PLUGIN_TITLE "N-Rage Input V2" IDS_ERR_MPCREATE "Couldn't create MemPak." - IDS_DLG_SC "Shortcuts File (*.sc)\0*.sc" + IDS_DLG_SC "Shortcuts File (*.sc)" IDS_P_MEM_ERROR "ErrorCode %lu: " IDS_P_R_NODEVICE "None" IDS_P_TRANS_NOCHANGE "Can't change paks while running" @@ -783,7 +788,7 @@ LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_CHILE // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_XCONTROLS, DIALOG BEGIN diff --git a/Source/nragev20/resource.h b/Source/nragev20/resource.h index ad81693c1..913d9b172 100644 --- a/Source/nragev20/resource.h +++ b/Source/nragev20/resource.h @@ -2,9 +2,13 @@ // Microsoft Visual C++ generated include file. // Used by NRagePluginV2.rc // -#define IDC_STATIC -1 +#define VERSION_REVISION 0 +#define VER_VER_DEBUG 0 +#define VERSION_MAJOR 2 #define IDC_STOREINDB 3 #define IDC_ERASEFROMDB 4 +#define VERSION_MINOR 4 +#define VERSION_BUILD 4 #define IDC_SAVEPROFILE 5 #define IDC_UPDATEDB 6 #define IDC_SAVEBINARY 6 @@ -361,6 +365,7 @@ #define IDC_XC_DPAD 1193 #define IDC_XC_LTS 1194 #define IDC_XC_RTS 1195 +#define IDC_N64MOUSE 1196 // Next default values for new objects // @@ -368,7 +373,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 147 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1196 +#define _APS_NEXT_CONTROL_VALUE 1197 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif