mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
[HID] Implement some extra service calls. [CFG] Add language checking.
This commit is contained in:
parent
2a4709dcfa
commit
d395fcd3cc
6 changed files with 86 additions and 6 deletions
|
@ -73,7 +73,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc
|
||||||
include/PICA/shader.hpp include/PICA/shader_unit.hpp include/PICA/float_types.hpp
|
include/PICA/shader.hpp include/PICA/shader_unit.hpp include/PICA/float_types.hpp
|
||||||
include/logger.hpp include/loader/ncch.hpp include/loader/ncsd.hpp include/io_file.hpp
|
include/logger.hpp include/loader/ncch.hpp include/loader/ncsd.hpp include/io_file.hpp
|
||||||
include/loader/lz77.hpp include/fs/archive_base.hpp include/fs/archive_ncch.hpp
|
include/loader/lz77.hpp include/fs/archive_base.hpp include/fs/archive_ncch.hpp
|
||||||
include/services/dsp.hpp include/services/cfg.hpp
|
include/services/dsp.hpp include/services/cfg.hpp include/services/region_codes.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||||
|
|
|
@ -10,6 +10,7 @@ class CFGService {
|
||||||
|
|
||||||
// Service functions
|
// Service functions
|
||||||
void getConfigInfoBlk2(u32 messagePointer);
|
void getConfigInfoBlk2(u32 messagePointer);
|
||||||
|
void secureInfoGetRegion(u32 messagePointer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFGService(Memory& mem) : mem(mem) {}
|
CFGService(Memory& mem) : mem(mem) {}
|
||||||
|
|
|
@ -9,9 +9,14 @@ class HIDService {
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
u8* sharedMem = nullptr; // Pointer to HID shared memory
|
u8* sharedMem = nullptr; // Pointer to HID shared memory
|
||||||
|
|
||||||
|
bool accelerometerEnabled;
|
||||||
|
bool gyroEnabled;
|
||||||
|
|
||||||
MAKE_LOG_FUNCTION(log, hidLogger)
|
MAKE_LOG_FUNCTION(log, hidLogger)
|
||||||
|
|
||||||
// Service commands
|
// Service commands
|
||||||
|
void enableAccelerometer(u32 messagePointer);
|
||||||
|
void enableGyroscopeLow(u32 messagePointer);
|
||||||
void getIPCHandles(u32 messagePointer);
|
void getIPCHandles(u32 messagePointer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
42
include/services/region_codes.hpp
Normal file
42
include/services/region_codes.hpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#pragma once
|
||||||
|
#include "helpers.hpp"
|
||||||
|
|
||||||
|
// Used for CFG::SecureInfoGetRegion
|
||||||
|
enum class Regions : u32 {
|
||||||
|
Japan = 0,
|
||||||
|
USA = 1,
|
||||||
|
Europe = 2,
|
||||||
|
Australia = 3,
|
||||||
|
China = 4,
|
||||||
|
Korea = 5,
|
||||||
|
Taiwan = 6
|
||||||
|
};
|
||||||
|
|
||||||
|
// Used for the language field in the NAND user data
|
||||||
|
enum class LanguageCodes : u32 {
|
||||||
|
JP = 0,
|
||||||
|
EN = 1,
|
||||||
|
FR = 2,
|
||||||
|
DE = 3,
|
||||||
|
IT = 4,
|
||||||
|
ES = 5,
|
||||||
|
ZH = 6,
|
||||||
|
KO = 7,
|
||||||
|
NL = 8,
|
||||||
|
PT = 9,
|
||||||
|
RU = 10,
|
||||||
|
TW = 11,
|
||||||
|
|
||||||
|
Japanese = JP,
|
||||||
|
English = EN,
|
||||||
|
French = FR,
|
||||||
|
German = DE,
|
||||||
|
Italian = IT,
|
||||||
|
Spanish = ES,
|
||||||
|
Chinese = ZH,
|
||||||
|
Korean = KO,
|
||||||
|
Dutch = NL,
|
||||||
|
Portuguese = PT,
|
||||||
|
Russian = RU,
|
||||||
|
Taiwanese = TW
|
||||||
|
};
|
|
@ -1,9 +1,11 @@
|
||||||
#include "services/cfg.hpp"
|
#include "services/cfg.hpp"
|
||||||
#include "services/dsp.hpp"
|
#include "services/dsp.hpp"
|
||||||
|
#include "services/region_codes.hpp"
|
||||||
|
|
||||||
namespace CFGCommands {
|
namespace CFGCommands {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
GetConfigInfoBlk2 = 0x00010082
|
GetConfigInfoBlk2 = 0x00010082,
|
||||||
|
SecureInfoGetRegion = 0x00020000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +21,7 @@ void CFGService::handleSyncRequest(u32 messagePointer) {
|
||||||
const u32 command = mem.read32(messagePointer);
|
const u32 command = mem.read32(messagePointer);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break;
|
case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break;
|
||||||
|
case CFGCommands::SecureInfoGetRegion: secureInfoGetRegion(messagePointer); break;
|
||||||
default: Helpers::panic("CFG service requested. Command: %08X\n", command);
|
default: Helpers::panic("CFG service requested. Command: %08X\n", command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +32,23 @@ void CFGService::getConfigInfoBlk2(u32 messagePointer) {
|
||||||
u32 output = mem.read32(messagePointer + 16); // Pointer to write the output data to
|
u32 output = mem.read32(messagePointer + 16); // Pointer to write the output data to
|
||||||
log("CFG::GetConfigInfoBlk2 (size = %X, block ID = %X, output pointer = %08X\n", size, blockID, output);
|
log("CFG::GetConfigInfoBlk2 (size = %X, block ID = %X, output pointer = %08X\n", size, blockID, output);
|
||||||
|
|
||||||
// Implement checking the sound output mode
|
// TODO: Make this not bad
|
||||||
if (size == 1 && blockID == 0x70001) {
|
if (size == 1 && blockID == 0x70001) { // Sound output mode
|
||||||
mem.write8(output, (u8) DSPService::SoundOutputMode::Stereo);
|
mem.write8(output, static_cast<u8>(DSPService::SoundOutputMode::Stereo));
|
||||||
|
} else if (size == 1 && blockID == 0xA0002){ // System language
|
||||||
|
mem.write8(output, static_cast<u8>(LanguageCodes::English));
|
||||||
|
} else if (size == 0x20 && blockID == 0x50005) {
|
||||||
|
printf("[Unimplemented] Read stereo display settings from NAND\n");
|
||||||
} else {
|
} else {
|
||||||
Helpers::panic("Unhandled GetConfigInfoBlk2 configuration");
|
Helpers::panic("Unhandled GetConfigInfoBlk2 configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFGService::secureInfoGetRegion(u32 messagePointer) {
|
||||||
|
log("CFG::SecureInfoGetRegion\n");
|
||||||
|
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
mem.write32(messagePointer + 8, static_cast<u32>(Regions::USA)); // TODO: Detect the game region and report it
|
||||||
}
|
}
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
namespace HIDCommands {
|
namespace HIDCommands {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
GetIPCHandles = 0x000A0000
|
GetIPCHandles = 0x000A0000,
|
||||||
|
EnableAccelerometer = 0x00110000,
|
||||||
|
EnableGyroscopeLow = 0x00130000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,16 +17,32 @@ namespace Result {
|
||||||
|
|
||||||
void HIDService::reset() {
|
void HIDService::reset() {
|
||||||
sharedMem = nullptr;
|
sharedMem = nullptr;
|
||||||
|
accelerometerEnabled = false;
|
||||||
|
gyroEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HIDService::handleSyncRequest(u32 messagePointer) {
|
void HIDService::handleSyncRequest(u32 messagePointer) {
|
||||||
const u32 command = mem.read32(messagePointer);
|
const u32 command = mem.read32(messagePointer);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
case HIDCommands::EnableAccelerometer: enableAccelerometer(messagePointer); break;
|
||||||
|
case HIDCommands::EnableGyroscopeLow: enableGyroscopeLow(messagePointer); break;
|
||||||
case HIDCommands::GetIPCHandles: getIPCHandles(messagePointer); break;
|
case HIDCommands::GetIPCHandles: getIPCHandles(messagePointer); break;
|
||||||
default: Helpers::panic("HID service requested. Command: %08X\n", command);
|
default: Helpers::panic("HID service requested. Command: %08X\n", command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HIDService::enableAccelerometer(u32 messagePointer) {
|
||||||
|
log("HID::EnableAccelerometer\n");
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
accelerometerEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HIDService::enableGyroscopeLow(u32 messagePointer) {
|
||||||
|
log("HID::EnableGyroscopeLow\n");
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
gyroEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
void HIDService::getIPCHandles(u32 messagePointer) {
|
void HIDService::getIPCHandles(u32 messagePointer) {
|
||||||
log("HID::GetIPCHandles\n");
|
log("HID::GetIPCHandles\n");
|
||||||
mem.write32(messagePointer + 4, Result::Success); // Result code
|
mem.write32(messagePointer + 4, Result::Success); // Result code
|
||||||
|
|
Loading…
Add table
Reference in a new issue