[Kernel] HDD and save detection changes

This commit is contained in:
Cancerous 2019-12-28 22:25:58 -05:00 committed by illusion
parent e0631c80a7
commit a0b0b7a751
4 changed files with 31 additions and 14 deletions

View File

@ -608,18 +608,25 @@ void KernelState::RegisterNotifyListener(XNotifyListener* listener) {
// https://cs.rin.ru/forum/viewtopic.php?f=38&t=60668&hilit=resident+evil+5&start=375
if (!has_notified_startup_ && listener->mask() & 0x00000001) {
has_notified_startup_ = true;
// begin
listener->EnqueueNotification(0x00000001, 1);
// XN_SYS_UI (on, off)
listener->EnqueueNotification(0x00000009, 1);
listener->EnqueueNotification(0x00000009, 0);
// XN_SYS_SIGNINCHANGED x2
listener->EnqueueNotification(0x0000000A, 1);
listener->EnqueueNotification(0x0000000A, 1);
// HDD ?
listener->EnqueueNotification(0x0000000B, 0);
listener->EnqueueNotification(0x0000000B, 1);
// XN_SYS_INPUTDEVICESCHANGED x2
listener->EnqueueNotification(0x00000012, 0);
listener->EnqueueNotification(0x00000012, 0);
// XN_SYS_INPUTDEVICECONFIGCHANGED x2
listener->EnqueueNotification(0x00000013, 0);
listener->EnqueueNotification(0x00000013, 0);
// end
listener->EnqueueNotification(0x00000026, 1);
}
}

View File

@ -54,9 +54,9 @@ struct DeviceInfo {
// will not be recognized properly.
#define ONE_GB (1024ull * 1024ull * 1024ull)
static const DeviceInfo dummy_device_info_ = {
0xF00D0000, 1,
4ull * ONE_GB, // 4GB
3ull * ONE_GB, // 3GB, so it looks a little used.
0x00000001, 1,
120ull * ONE_GB, // 4GB
42ull * ONE_GB, // 3GB, so it looks a little used.
L"Dummy HDD",
};
#undef ONE_GB
@ -81,7 +81,7 @@ DECLARE_XAM_EXPORT2(XamContentGetLicenseMask, kContent, kStub, kHighFrequency);
dword_result_t XamContentGetDeviceName(dword_t device_id,
lpwstring_t name_buffer,
dword_t name_capacity) {
if ((device_id & 0xFFFF0000) != dummy_device_info_.device_id) {
if ((device_id & 0x0000000F) != dummy_device_info_.device_id) {
return X_ERROR_DEVICE_NOT_CONNECTED;
}
@ -98,12 +98,12 @@ DECLARE_XAM_EXPORT1(XamContentGetDeviceName, kContent, kImplemented);
dword_result_t XamContentGetDeviceState(dword_t device_id,
lpunknown_t overlapped_ptr) {
if ((device_id & 0xFFFF0000) != dummy_device_info_.device_id) {
if ((device_id & 0x0000000F) != dummy_device_info_.device_id) {
if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediateEx(
overlapped_ptr, X_ERROR_FUNCTION_FAILED, X_ERROR_DEVICE_NOT_CONNECTED,
0);
return X_ERROR_IO_PENDING;
return X_ERROR_SUCCESS;
} else {
return X_ERROR_DEVICE_NOT_CONNECTED;
}
@ -130,7 +130,7 @@ static_assert_size(X_CONTENT_DEVICE_DATA, 0x50);
dword_result_t XamContentGetDeviceData(
dword_t device_id, pointer_t<X_CONTENT_DEVICE_DATA> device_data) {
if ((device_id & 0xFFFF0000) != dummy_device_info_.device_id) {
if ((device_id & 0x0000000F) != dummy_device_info_.device_id) {
// TODO(benvanik): memset 0 the data?
return X_ERROR_DEVICE_NOT_CONNECTED;
}
@ -169,7 +169,7 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
lpdword_t buffer_size_ptr,
lpdword_t handle_out) {
assert_not_null(handle_out);
if ((device_id && (device_id & 0xFFFF0000) != dummy_device_info_.device_id) ||
if ((device_id && (device_id & 0x0000000F) != dummy_device_info_.device_id) ||
!handle_out) {
if (buffer_size_ptr) {
*buffer_size_ptr = 0;

View File

@ -382,8 +382,13 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type,
XOverlappedSetResult((void*)overlapped.host_address(), X_ERROR_IO_PENDING);
}
// broadcast begin
kernel_state()->BroadcastNotification(0x1, 1);
// Broadcast XN_SYS_UI = true
kernel_state()->BroadcastNotification(0x9, true);
// broadcast HDD changed
kernel_state()->BroadcastNotification(0xB, 0);
kernel_state()->BroadcastNotification(0xB, 1);
auto ui_fn = [content_type, device_id_ptr, overlapped]() {
XELOGW("XamShowDeviceSelectorUI Content_type:(%X) device_id_ptr: %.8X overlapped:(%X)",
@ -392,18 +397,18 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type,
// NOTE: 0xF00D0000 magic from xam_content.cc
switch (content_type) {
case 1: // save game
*device_id_ptr = 0xF00D0000 | 0x0001;
*device_id_ptr = 0x00000001 | 0x0001;
break;
case 2: // marketplace
*device_id_ptr = 0xF00D0000 | 0x0002;
*device_id_ptr = 0x00000001 | 0x0002;
break;
case 3: // title/publisher update?
*device_id_ptr = 0xF00D0000 | 0x0003;
*device_id_ptr = 0x00000001 | 0x0003;
break;
default:
XELOGW("XamShowDeviceSelectorUI Unhandled Content_type:(%X)", content_type);
assert_unhandled_case(content_type);
*device_id_ptr = 0xF00D0000 | 0x0001;
*device_id_ptr = 0x00000001 | 0x0001;
break;
}
@ -432,9 +437,13 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type,
while (ui_thread->last_error() != X_ERROR_SUCCESS) {
xe::threading::Sleep(std::chrono::milliseconds(110));
}
// broadcast end
kernel_state()->BroadcastNotification(0x26, 1);
return X_ERROR_IO_PENDING;
} else {
ui_fn();
// broadcast end
kernel_state()->BroadcastNotification(0x26, 1);
return X_ERROR_SUCCESS;
}
}

View File

@ -47,9 +47,10 @@ dword_result_t XamProfileCreateEnumerator(dword_t device_id,
X_PROFILEENUMRESULT* profile = (X_PROFILEENUMRESULT*)e->AppendItem();
memset(profile, 0, sizeof(X_PROFILEENUMRESULT));
profile->xuid_offline = user_profile->xuid();
profile->device_id = 0xF00D0000;
profile->device_id = 0x00000001;
auto tag = xe::to_wstring(user_profile->name());
XELOGI("XamProfileCreateEnumerator profile:(%S)", tag.c_str());
xe::copy_and_swap<wchar_t>(profile->account.gamertag, tag.c_str(),
tag.length());
profile->account.xuid_online = user_profile->xuid();