| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2013 by Blade_Arma <[email protected]> * |
| 3 |
* * |
| 4 |
* This program is free software; you can redistribute it and/or modify * |
| 5 |
* it under the terms of the GNU General Public License as published by * |
| 6 |
* the Free Software Foundation; either version 2 of the License, or * |
| 7 |
* (at your option) any later version. * |
| 8 |
* * |
| 9 |
* This program is distributed in the hope that it will be useful, * |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 12 |
* GNU General Public License for more details. * |
| 13 |
* * |
| 14 |
* You should have received a copy of the GNU General Public License * |
| 15 |
* along with this program; if not, write to the * |
| 16 |
* Free Software Foundation, Inc., * |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * |
| 18 |
***************************************************************************/ |
| 19 |
|
| 20 |
#include "stdafx.h" |
| 21 |
#include "typedefs.h" |
| 22 |
#include "cfg-winapi.h" |
| 23 |
#include "sio1.h" |
| 24 |
|
| 25 |
/***************************************************************************/ |
| 26 |
|
| 27 |
void settingsRead() { |
| 28 |
HKEY myKey; |
| 29 |
DWORD temp; |
| 30 |
DWORD type; |
| 31 |
DWORD size; |
| 32 |
|
| 33 |
settings.player = PLAYER_DISABLED; |
| 34 |
strcpy(settings.ip, "127.0.0.1"); |
| 35 |
settings.port = 33307; |
| 36 |
|
| 37 |
if(RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SIO1\\bladesio1",0,KEY_ALL_ACCESS,&myKey) == ERROR_SUCCESS) { |
| 38 |
size = 4; |
| 39 |
if(RegQueryValueEx(myKey, "player", 0, &type, (LPBYTE)&temp, &size) == ERROR_SUCCESS) |
| 40 |
settings.player = (int)temp; |
| 41 |
size = sizeof(settings.ip); |
| 42 |
RegQueryValueEx(myKey, "ip", 0, &type, (LPBYTE)settings.ip, &size); |
| 43 |
size = 4; |
| 44 |
if(RegQueryValueEx(myKey, "port", 0, &type, (LPBYTE)&temp, &size) == ERROR_SUCCESS) |
| 45 |
settings.port = (int)temp; |
| 46 |
|
| 47 |
RegCloseKey(myKey); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
void settingsWrite() { |
| 52 |
HKEY myKey; |
| 53 |
DWORD myDisp; |
| 54 |
DWORD temp; |
| 55 |
|
| 56 |
RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Vision Thing\\PSEmu Pro\\SIO1\\bladesio1", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp); |
| 57 |
temp = settings.player; |
| 58 |
RegSetValueEx(myKey, "player", 0, REG_DWORD, (LPBYTE)&temp, sizeof(temp)); |
| 59 |
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SIO1\\bladesio1", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp); |
| 60 |
RegSetValueEx(myKey, "ip", 0, REG_SZ, (BYTE*)settings.ip, strlen(settings.ip)); |
| 61 |
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Vision Thing\\PSEmu Pro\\SIO1\\bladesio1", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp); |
| 62 |
temp = settings.port; |
| 63 |
RegSetValueEx(myKey, "port", 0, REG_DWORD,(LPBYTE) &temp,sizeof(temp)); |
| 64 |
|
| 65 |
RegCloseKey(myKey); |
| 66 |
} |
| 67 |
|
| 68 |
/***************************************************************************/ |
| 69 |
|
| 70 |
BOOL OnInitSio1Dialog(HWND hW) { |
| 71 |
char str[32]; |
| 72 |
|
| 73 |
settingsRead(); |
| 74 |
|
| 75 |
CheckRadioButton(hW, IDC_DISABLED, IDC_CLIENT, IDC_DISABLED + settings.player); |
| 76 |
SetDlgItemText(hW, IDC_IP, settings.ip); |
| 77 |
sprintf(str, "%i", settings.port); |
| 78 |
SetDlgItemText(hW, IDC_PORT, str); |
| 79 |
|
| 80 |
return TRUE; |
| 81 |
} |
| 82 |
|
| 83 |
void OnSio1OK(HWND hW) { |
| 84 |
char str[32]; |
| 85 |
|
| 86 |
if(IsDlgButtonChecked(hW,IDC_DISABLED)) |
| 87 |
settings.player = 0; |
| 88 |
if(IsDlgButtonChecked(hW,IDC_SERVER)) |
| 89 |
settings.player = 1; |
| 90 |
if(IsDlgButtonChecked(hW,IDC_CLIENT)) |
| 91 |
settings.player = 2; |
| 92 |
GetDlgItemText(hW,IDC_IP, settings.ip, sizeof(settings.ip)); |
| 93 |
GetDlgItemText(hW,IDC_PORT, str, sizeof(str)); |
| 94 |
settings.port = atoi(str); |
| 95 |
|
| 96 |
settingsWrite(); |
| 97 |
|
| 98 |
EndDialog(hW,TRUE); |
| 99 |
} |
| 100 |
|
| 101 |
void OnSio1Cancel(HWND hW) { |
| 102 |
EndDialog(hW,FALSE); |
| 103 |
} |
| 104 |
|
| 105 |
BOOL CALLBACK Sio1DlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
| 106 |
switch(uMsg) { |
| 107 |
case WM_INITDIALOG: |
| 108 |
return OnInitSio1Dialog(hW); |
| 109 |
case WM_COMMAND: { |
| 110 |
switch(LOWORD(wParam)) { |
| 111 |
case IDCANCEL: |
| 112 |
OnSio1Cancel(hW); |
| 113 |
return TRUE; |
| 114 |
case IDOK: |
| 115 |
OnSio1OK(hW); |
| 116 |
return TRUE; |
| 117 |
} |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
return FALSE; |
| 122 |
} |
| 123 |
|
| 124 |
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
| 125 |
switch(uMsg) { |
| 126 |
case WM_COMMAND: { |
| 127 |
switch(LOWORD(wParam)) { |
| 128 |
case IDOK: |
| 129 |
EndDialog(hW,TRUE); |
| 130 |
return TRUE; |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
return FALSE; |
| 136 |
} |
| 137 |
|
| 138 |
/***************************************************************************/ |