forked from PlexaryDamato/nrage-input
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFileAccess.h
227 lines (185 loc) · 7.46 KB
/
FileAccess.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*
N-Rage`s Dinput8 Plugin
(C) 2002, 2006 Norbert Wladyka
Author`s Email: [email protected]
Website: http://go.to/nrage
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
*/
#ifndef _FILEACCESS_H_
#define _FILEACCESS_H_
#include "NRagePluginV2.h"
#include <string>
using std::string;
bool GetDirectory( LPTSTR pszDirectory, WORD wDirID );
bool CheckFileExists( LPCTSTR FileName );
void GetAbsoluteFileName( LPTSTR szAbsolute, LPCTSTR szFileName, const WORD wDirID );
BOOL SendFilestoList( HWND hDlgItem, WORD wType );
bool StoreConfigToINI();
bool LoadConfigFromINI();
LANGID GetLanguageFromINI();
bool LoadProfileFile( LPCTSTR pszFileName, int iController, LPTSTR pszGameDevice, LPBYTE bGameDeviceNr );
bool LoadShortcutsFile( LPCTSTR pszFileName );
void FormatProfileBlock( FILE * fFile, const int iController );
void FormatShortcutsBlock( FILE * fFile, bool bIsINI );
bool BrowseFolders( HWND hwndParent, LPTSTR pszHeader, LPTSTR pszDirectory );
bool BrowseFile( HWND hDlg, LPTSTR pszFileName, DWORD dwType, bool fSave );
bool ReadMemPakFile( LPTSTR pszMemPakFile, BYTE *aMemPak, bool fCreate );
bool WriteMemPakFile( LPTSTR pszMemPakFile, BYTE *aMemPak, bool fCreate );
bool LoadProfileFromResource( int indexController, bool bIsInterface );
bool LoadShortcutsFromResource( bool bIsInterface );
inline void GUIDtoStringA( char * szGUIDbuf, const GUID guid );
inline bool StringtoGUIDA( LPGUID guid, const char * szGUIDbuf );
unsigned long djbHash(const char *str);
#ifdef _UNICODE
#define TCHAR_TO_CHAR(x,y,z) wcstombs(x,y,z)
#define CHAR_TO_TCHAR(x,y,z) mbstowcs(x,y,z)
#else
#define TCHAR_TO_CHAR(x,y,z) strncpy(x,y,z)
#define CHAR_TO_TCHAR(x,y,z) strncpy(x,y,z)
#endif
#define STRING_DEF_MEMPAKFILE _T("MemPaks")
#define STRING_DEF_GBROMFILE _T("GBxRoms")
#define STRING_DEF_GBROMSAVE _T("GBxSaves")
#define STRING_INI_HEADER "# Generated by NRage input plugin V2 version " VERSIONNUMBER "\n"
// We use these names for loading from INI files and NRage config files
#define STRING_INI_GENERAL "General"
#define STRING_INI_CONTROLLER "Controller"
#define STRING_INI_FOLDERS "Folders"
#define STRING_INI_BROWSER "lastBrowserDir"
#define STRING_INI_CONTROLS "Controls"
#define STRING_INI_SHORTCUTS "Shortcuts"
#define STRING_INI_MODIFIERS "Modifiers"
#define STRING_INI_LANGUAGE "Language"
#define STRING_INI_SHOWMESSAGES "ShowMessages"
#define STRING_INI_BRPROFILE "Profile"
#define STRING_INI_BRNOTE "Note"
#define STRING_INI_BRMEMPAK "Mempak"
#define STRING_INI_BRGBROM "GBxRom"
#define STRING_INI_BRGBSAVE "GBxSave"
// #define STRING_INI_BRSHORTCUTS STRING_INI_SHORTCUTS
#define STRING_INI_PLUGGED "Plugged"
#define STRING_INI_XINPUT "xInput"
#define STRING_INI_RAWDATA "RawData"
#define STRING_INI_PAKTYPE "PakType"
#define STRING_INI_REALN64RANGE "RealN64Range"
#define STRING_INI_RAPIDFIREENABLED "RapidFireEnabled"
#define STRING_INI_RAPIDFIRERATE "RapidFireRate"
#define STRING_INI_STICKRANGE "StickRange"
#define STRING_INI_MOUSEMOVEX "MouseMoveX"
#define STRING_INI_MOUSEMOVEY "MouseMoveY"
#define STRING_INI_AXISSET "AxisSet"
#define STRING_INI_KEYABSOLUTEX "KeyAbsoluteX"
#define STRING_INI_KEYABSOLUTEY "KeyAbsoluteY"
#define STRING_INI_PADDEADZONE "PadDeadZone"
#define STRING_INI_MOUSESENSX "MouseSensitivityX"
#define STRING_INI_MOUSESENSY "MouseSensitivityY"
#define STRING_INI_RUMBLETYPE "RumbleType"
#define STRING_INI_RUMBLESTRENGTH "RumbleStrength"
#define STRING_INI_VISUALRUMBLE "VisualRumble"
#define STRING_INI_FFDEVICEGUID "FFDeviceGUID"
#define STRING_INI_MEMPAKFILE "MemPakFile"
#define STRING_INI_GBROMFILE "GBRomFile"
#define STRING_INI_GBROMSAVE "GBRomSave"
#define STRING_INI_DINPUTGUID "DInputGUID"
#define STRING_INI_BUTTON "Button"
#define STRING_INI_MODIFIER "Modifier"
// The following are not found in INI files; only profile and shortcuts files
#define STRING_PROFILEVERSION22 "Controller Profile 2.2"
#define STRING_PROFILEVERSION STRING_PROFILEVERSION22
#define STRING_INI_FFDEVICENAME "FFDeviceName"
#define STRING_INI_FFDEVICENR "FFDeviceNr"
#define STRING_INI_DINPUTNAME "DInputName"
#define STRING_INI_DINPUTNR "DInputNr"
// the following are hashes for the string values above
// version strings, including the @ in front
#define CHK_PROFILEVERSION20 2278962538
#define CHK_PROFILEVERSION21 2278962539
#define CHK_PROFILEVERSION22 2278962540
// categories
#define CHK_GENERAL 63249731
#define CHK_FOLDERS 3455681620
#define CHK_LASTBROWSERDIR 2659654652
#define CHK_CONTROLLER_1 3910856026
#define CHK_CONTROLLER_2 3910856027
#define CHK_CONTROLLER_3 3910856028
#define CHK_CONTROLLER_4 3910856029
#define CHK_CONTROLS 3459743001
#define CHK_SHORTCUTS 2945387732
#define CHK_MODIFIERS 95935975
// assignments (to the left of the '=' sign)
#define CHK_LANGUAGE 3857633481
#define CHK_SHOWMESSAGES 638097246
#define CHK_MEMPAK 3230166560
#define CHK_GBXROM 2992194388
#define CHK_GBXSAVE 4253155349
#define CHK_PROFILE 3606499382
#define CHK_NOTE 2089365563
#define CHK_PLUGGED 3378836077
#define CHK_XINPUT 3665436173
#define CHK_RAWDATA 1238573385
#define CHK_PAKTYPE 2936974691
#define CHK_REALN64RANGE 1279831790
#define CHK_RAPIDFIREENABLED 1491009894
#define CHK_RAPIDFIRERATE 1576165031
#define CHK_STICKRANGE 4145501776
#define CHK_MOUSEMOVEX 1825694205
#define CHK_MOUSEMOVEY 1825694206
#define CHK_AXISSET 1642523718
#define CHK_KEYABSOLUTEX 958566277
#define CHK_KEYABSOLUTEY 958566278
#define CHK_PADDEADZONE 2913910084
#define CHK_MOUSESENSITIVITYX 1513071697
#define CHK_MOUSESENSITIVITYY 1513071698
#define CHK_RUMBLETYPE 3440038446
#define CHK_RUMBLESTRENGTH 3038086267
#define CHK_VISUALRUMBLE 1795686016
#define CHK_FFDEVICEGUID 2645316746
#define CHK_MEMPAKFILE 2373591360
#define CHK_GBROMFILE 2409678172
#define CHK_GBROMSAVE 2410136971
#define CHK_DINPUTGUID 1452894242
#define CHK_BUTTON 2818908353
#define CHK_MODIFIER 4037573396
// The following are not found in INI files; only profile and shortcuts files
#define CHK_FFDEVICENAME 2645546658
#define CHK_FFDEVICENR 2037510273
#define CHK_DINPUTNAME 1453124154
#define CHK_DINPUTNR 3965009433
// If any of the following values conflict with djbHash return values (such as a blank string), there will be problems!
// nothing
#define PL_NOHIT 0
// [Category]
#define PL_CATEGORY 1
// @STRING_PROFILEVERSION
#define PL_VERSIONSTRING 10
// resets the static vars in ProcessKey
#define PL_RESET 200
#define DIRECTORY_MEMPAK 0
#define DIRECTORY_GBROMS 1
#define DIRECTORY_GBSAVES 2
#define DIRECTORY_DLL 254
#define DIRECTORY_APPLICATION 255
#define DIRECTORY_INVALID 256
#define FILIST_MEM 1
#define FILIST_TRANSFER 2
#define BF_LOAD false
#define BF_SAVE true
#define BF_MEMPAK 0
#define BF_GBROM 1
#define BF_GBSAVE 2
#define BF_PROFILE 3
#define BF_NOTE 4
#define BF_SHORTCUTS 5
// 32 hex characters, 4 hyphens, 2 end braces
#define GUID_STRINGLENGTH 32+4+2
#endif // #ifndef _FILEACCESS_H_