2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2012-06-18 10:13:51 +00:00
|
|
|
|
|
|
|
#include <nall/platform.hpp>
|
|
|
|
#include <nall/string.hpp>
|
|
|
|
|
|
|
|
#include <shlwapi.h>
|
2013-04-14 08:52:47 +00:00
|
|
|
#undef interface
|
2012-06-18 10:13:51 +00:00
|
|
|
#ifndef KEY_WOW64_64KEY
|
|
|
|
#define KEY_WOW64_64KEY 0x0100
|
|
|
|
#endif
|
|
|
|
#ifndef KEY_WOW64_32KEY
|
|
|
|
#define KEY_WOW64_32KEY 0x0200
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NWR_FLAGS
|
|
|
|
#define NWR_FLAGS KEY_WOW64_64KEY
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NWR_SIZE
|
|
|
|
#define NWR_SIZE 4096
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct registry {
|
2015-12-14 09:41:06 +00:00
|
|
|
static auto exists(const string& name) -> bool {
|
2017-07-15 12:00:20 +00:00
|
|
|
auto part = name.split("\\");
|
2016-05-04 10:07:13 +00:00
|
|
|
HKEY handle, rootKey = root(part.takeLeft());
|
|
|
|
string node = part.takeRight();
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
string path = part.merge("\\");
|
2012-06-18 10:13:51 +00:00
|
|
|
if(RegOpenKeyExW(rootKey, utf16_t(path), 0, NWR_FLAGS | KEY_READ, &handle) == ERROR_SUCCESS) {
|
|
|
|
wchar_t data[NWR_SIZE] = L"";
|
|
|
|
DWORD size = NWR_SIZE * sizeof(wchar_t);
|
2013-03-15 13:11:33 +00:00
|
|
|
LONG result = RegQueryValueExW(handle, utf16_t(node), nullptr, nullptr, (LPBYTE)&data, (LPDWORD)&size);
|
2012-06-18 10:13:51 +00:00
|
|
|
RegCloseKey(handle);
|
|
|
|
if(result == ERROR_SUCCESS) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
static auto read(const string& name) -> string {
|
2017-07-15 12:00:20 +00:00
|
|
|
auto part = name.split("\\");
|
2016-05-04 10:07:13 +00:00
|
|
|
HKEY handle, rootKey = root(part.takeLeft());
|
|
|
|
string node = part.takeRight();
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
string path = part.merge("\\");
|
2012-06-18 10:13:51 +00:00
|
|
|
if(RegOpenKeyExW(rootKey, utf16_t(path), 0, NWR_FLAGS | KEY_READ, &handle) == ERROR_SUCCESS) {
|
|
|
|
wchar_t data[NWR_SIZE] = L"";
|
|
|
|
DWORD size = NWR_SIZE * sizeof(wchar_t);
|
2013-03-15 13:11:33 +00:00
|
|
|
LONG result = RegQueryValueExW(handle, utf16_t(node), nullptr, nullptr, (LPBYTE)&data, (LPDWORD)&size);
|
2012-06-18 10:13:51 +00:00
|
|
|
RegCloseKey(handle);
|
|
|
|
if(result == ERROR_SUCCESS) return (const char*)utf8_t(data);
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
static auto write(const string& name, const string& data = "") -> void {
|
2017-07-15 12:00:20 +00:00
|
|
|
auto part = name.split("\\");
|
2016-05-04 10:07:13 +00:00
|
|
|
HKEY handle, rootKey = root(part.takeLeft());
|
|
|
|
string node = part.takeRight(), path;
|
2012-06-18 10:13:51 +00:00
|
|
|
DWORD disposition;
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < part.size(); n++) {
|
2012-06-18 10:13:51 +00:00
|
|
|
path.append(part[n]);
|
2013-03-15 13:11:33 +00:00
|
|
|
if(RegCreateKeyExW(rootKey, utf16_t(path), 0, nullptr, 0, NWR_FLAGS | KEY_ALL_ACCESS, nullptr, &handle, &disposition) == ERROR_SUCCESS) {
|
2012-06-18 10:13:51 +00:00
|
|
|
if(n == part.size() - 1) {
|
|
|
|
RegSetValueExW(handle, utf16_t(node), 0, REG_SZ, (BYTE*)(wchar_t*)utf16_t(data), (data.length() + 1) * sizeof(wchar_t));
|
|
|
|
}
|
|
|
|
RegCloseKey(handle);
|
|
|
|
}
|
|
|
|
path.append("\\");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
static auto remove(const string& name) -> bool {
|
2017-07-15 12:00:20 +00:00
|
|
|
auto part = name.split("\\");
|
2016-05-04 10:07:13 +00:00
|
|
|
HKEY rootKey = root(part.takeLeft());
|
|
|
|
string node = part.takeRight();
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
string path = part.merge("\\");
|
2016-05-16 09:51:12 +00:00
|
|
|
if(!node) return SHDeleteKeyW(rootKey, utf16_t(path)) == ERROR_SUCCESS;
|
2012-06-18 10:13:51 +00:00
|
|
|
return SHDeleteValueW(rootKey, utf16_t(path), utf16_t(node)) == ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
Update to 20180729 release.
byuu wrote:
Sigh ...
asio.hpp needs #include <nall/windows/registry.hpp>
[Since the last WIP, byuu also posted the following message. -Ed.]
ruby drivers have all been updated (but not tested outside of BSD), and
I redesigned the settings window. The driver functionality all exists on
a new "Drivers" panel, the emulator/hack settings go to a
"Configuration" panel, and the video/audio panels lose driver settings.
As does the settings menu and its synchronize options.
I want to start pushing toward a v107 release. Critically, I will need
DirectSound and ALSA to support dynamic rate control. I'd also like to
eliminate the other system manifest.bml files. I need to update the
cheat code database format, and bundle at least a few quark shaders --
although I still need to default to Direct3D on Windows.
Turbo keys would be nice, if it's not too much effort. Aside from
netplay, it's the last significant feature I'm missing.
I think for v107, higan is going to be a bit rough around the edges
compared to bsnes. And I don't think it's practical to finish the bsnes
localization support.
I'm thinking we probably want another WIP to iron out any critical
issues, but this time there should be a feature freeze with the next
WIP.
2018-07-29 13:24:38 +00:00
|
|
|
static auto contents(const string& name) -> vector<string> {
|
|
|
|
vector<string> result;
|
2017-07-15 12:00:20 +00:00
|
|
|
auto part = name.split("\\");
|
2016-05-04 10:07:13 +00:00
|
|
|
HKEY handle, rootKey = root(part.takeLeft());
|
|
|
|
part.removeRight();
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
string path = part.merge("\\");
|
2012-06-18 10:13:51 +00:00
|
|
|
if(RegOpenKeyExW(rootKey, utf16_t(path), 0, NWR_FLAGS | KEY_READ, &handle) == ERROR_SUCCESS) {
|
|
|
|
DWORD folders, nodes;
|
2013-03-15 13:11:33 +00:00
|
|
|
RegQueryInfoKey(handle, nullptr, nullptr, nullptr, &folders, nullptr, nullptr, &nodes, nullptr, nullptr, nullptr, nullptr);
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < folders; n++) {
|
2012-06-18 10:13:51 +00:00
|
|
|
wchar_t name[NWR_SIZE] = L"";
|
|
|
|
DWORD size = NWR_SIZE * sizeof(wchar_t);
|
2013-03-15 13:11:33 +00:00
|
|
|
RegEnumKeyEx(handle, n, (wchar_t*)&name, &size, nullptr, nullptr, nullptr, nullptr);
|
2017-07-15 12:00:20 +00:00
|
|
|
result.append(string{(const char*)utf8_t(name), "\\"});
|
2012-06-18 10:13:51 +00:00
|
|
|
}
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < nodes; n++) {
|
2012-06-18 10:13:51 +00:00
|
|
|
wchar_t name[NWR_SIZE] = L"";
|
|
|
|
DWORD size = NWR_SIZE * sizeof(wchar_t);
|
2013-03-15 13:11:33 +00:00
|
|
|
RegEnumValueW(handle, n, (wchar_t*)&name, &size, nullptr, nullptr, nullptr, nullptr);
|
2012-06-18 10:13:51 +00:00
|
|
|
result.append((const char*)utf8_t(name));
|
|
|
|
}
|
|
|
|
RegCloseKey(handle);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-12-14 09:41:06 +00:00
|
|
|
static auto root(const string& name) -> HKEY {
|
2012-06-18 10:13:51 +00:00
|
|
|
if(name == "HKCR") return HKEY_CLASSES_ROOT;
|
|
|
|
if(name == "HKCC") return HKEY_CURRENT_CONFIG;
|
|
|
|
if(name == "HKCU") return HKEY_CURRENT_USER;
|
|
|
|
if(name == "HKLM") return HKEY_LOCAL_MACHINE;
|
|
|
|
if(name == "HKU" ) return HKEY_USERS;
|
2013-03-15 13:11:33 +00:00
|
|
|
return nullptr;
|
2012-06-18 10:13:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|