[XAM/NUI] - Implement More Functions
- Implement XamNuiIsDeviceReady, XamNuiIdentityGetSessionId, XamNuiHudGetInitializeFlags, XamNuiHudGetVersions, and XamNuiHudIsEnabled - Stub XamIsNuiAutomationEnabled/XamIsNatalPlaybackEnabled, XamUserNuiGetUserIndex, XamUserNuiEnableBiometric, XamNuiGetDepthCalibration, XamNuiSkeletonGetBestSkeletonIndex, XamNuiIsChatMicEnabled, XamNuiPlayerEngagementUpdate, XamNuiCameraTiltGetStatus, XamNuiCameraElevationGetAngle, XamNuiCameraGetTiltControllerType, XamNuiCameraSetFlags, XamShowNuiGuideUI, and XamNuiHudSetEngagedTrackingID - According to Xam XamIsNuiAutomationEnabled, and XamIsNatalPlaybackEnabled are the same function. - Left Notes for future reference
This commit is contained in:
parent
c4867250e4
commit
4377a038c4
|
@ -2,7 +2,7 @@
|
|||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2025 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -19,13 +19,35 @@
|
|||
#include "xenia/ui/windowed_app_context.h"
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
DEFINE_bool(NUI_Ready, false,
|
||||
"Enable Kinect\n"
|
||||
" Only set true when testing kinect games. Certain games may\n"
|
||||
" require avatar implementation.",
|
||||
"Testing");
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
// Structs:
|
||||
extern std::atomic<int> xam_dialogs_shown_;
|
||||
|
||||
// https://web.cs.ucdavis.edu/~okreylos/ResDev/Kinect/MainPage.html
|
||||
|
||||
struct X_NUI_DEVICE_STATUS {
|
||||
/* Notes:
|
||||
- for one side func of XamNuiGetDeviceStatus
|
||||
- if some data addressis less than zero then unk1 = it
|
||||
- else another func is called and its return can set unk1 = c0051200 or
|
||||
some value involving DetroitDeviceRequest
|
||||
- next PsCamDeviceRequest is called and if its return is less than zero
|
||||
then X_NUI_DEVICE_STATUS = return of PsCamDeviceRequest
|
||||
- else it equals an unknown local_1c
|
||||
- finally McaDeviceRequest is called and if its return is less than zero
|
||||
then unk2 = return of McaDeviceRequest
|
||||
- else it equals an unknown local_14
|
||||
- status can be set to X_NUI_DEVICE_STATUS[3] | 0x44 or | 0x40
|
||||
*/
|
||||
xe::be<uint32_t> unk0;
|
||||
xe::be<uint32_t> unk1;
|
||||
xe::be<uint32_t> unk2;
|
||||
|
@ -35,23 +57,266 @@ struct X_NUI_DEVICE_STATUS {
|
|||
};
|
||||
static_assert(sizeof(X_NUI_DEVICE_STATUS) == 24, "Size matters");
|
||||
|
||||
void XamNuiGetDeviceStatus_entry(pointer_t<X_NUI_DEVICE_STATUS> status_ptr) {
|
||||
// Get
|
||||
uint64_t NUI_Session_Id = 0;
|
||||
|
||||
dword_result_t XamNuiGetDeviceStatus_entry(
|
||||
pointer_t<X_NUI_DEVICE_STATUS> status_ptr) {
|
||||
/* Notes:
|
||||
- it does return a value that is not always used
|
||||
- returns values are X_ERROR_SUCCESS, 0xC0050006, and others
|
||||
- 1) On func start *status_ptr = 0, status_ptr->unk1 = 0, status_ptr->unk2
|
||||
= 0, and status_ptr->status = 0
|
||||
- 2) calls XamXStudioRequest(6,&var <- = 0);
|
||||
- if return is greater than -1 && var & 0x80000000 != 0 then set
|
||||
status_ptr->unk1 = 0xC000009D, status_ptr->unk2 = 0xC000009D, and
|
||||
status_ptr->status = status_ptr[3] = 0x20
|
||||
- lots of branching functions after
|
||||
*/
|
||||
|
||||
status_ptr.Zero();
|
||||
status_ptr->status = 0; // Not connected.
|
||||
status_ptr->status = cvars::NUI_Ready ? true : false;
|
||||
return cvars::NUI_Ready ? X_ERROR_SUCCESS : 0xC0050006;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiGetDeviceStatus, kNone, kStub);
|
||||
|
||||
qword_result_t XamNuiIdentityGetSessionId_entry() {
|
||||
if (NUI_Session_Id == 0) {
|
||||
std::memset(&NUI_Session_Id, 0xFD,
|
||||
8); // xboxkrnl::XeCryptRandom_entry(NUI_Session_Id, 8);
|
||||
}
|
||||
return NUI_Session_Id;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiIdentityGetSessionId, kNone, kImplemented);
|
||||
|
||||
dword_result_t XamUserNuiGetUserIndex_entry(unknown_t unk, lpdword_t index) {
|
||||
return X_E_NO_SUCH_USER;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamUserNuiGetUserIndex, kNone, kStub);
|
||||
|
||||
dword_result_t XamUserNuiGetUserIndexForSignin_entry(lpdword_t index) {
|
||||
return X_E_FAIL;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamUserNuiGetUserIndexForSignin, kNone, kStub);
|
||||
|
||||
dword_result_t XamUserNuiGetUserIndexForBind_entry(lpdword_t index) {
|
||||
return X_E_FAIL;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamUserNuiGetUserIndexForBind, kNone, kStub);
|
||||
|
||||
dword_result_t XamNuiGetDepthCalibration_entry(lpdword_t unk1) {
|
||||
/* Notes:
|
||||
- Possible returns X_STATUS_NO_SUCH_FILE, and 0x10000000
|
||||
*/
|
||||
return X_STATUS_NO_SUCH_FILE;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiGetDepthCalibration, kNone, kStub);
|
||||
|
||||
// Skeleton
|
||||
qword_result_t XamNuiSkeletonGetBestSkeletonIndex_entry(int_t unk) {
|
||||
return 0xffffffffffffffff;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiSkeletonGetBestSkeletonIndex, kNone, kStub);
|
||||
|
||||
// Camera
|
||||
dword_result_t XamNuiCameraTiltGetStatus_entry(lpdword_t unk) {
|
||||
/* Notes:
|
||||
- Used by XamNuiCameraElevationGetAngle, and XamNuiCameraSetFlags
|
||||
- if it returns anything greater than -1 then both above functions continue
|
||||
- Both funcs send in a param of *unk = 0x50
|
||||
- Ghidra decompile fails
|
||||
*/
|
||||
return X_E_FAIL;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiCameraTiltGetStatus, kNone, kStub);
|
||||
|
||||
dword_result_t XamNuiCameraElevationGetAngle_entry(lpqword_t unk1,
|
||||
lpdword_t unk2) {
|
||||
/* Notes:
|
||||
- Xam 12611 does not show what unk1 is used for (Ghidra)
|
||||
*/
|
||||
uint32_t status = 0x50;
|
||||
uint32_t response;
|
||||
response = XamNuiCameraTiltGetStatus_entry(&status);
|
||||
if (-1 < response) {
|
||||
// operation here
|
||||
// *unk2 = output
|
||||
}
|
||||
return response;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiCameraElevationGetAngle, kNone, kStub);
|
||||
|
||||
dword_result_t XamNuiCameraGetTiltControllerType_entry() {
|
||||
/* Notes:
|
||||
- undefined unk[8]
|
||||
- undefined8 local_28;
|
||||
- undefined8 local_20;
|
||||
- undefined8 local_18;
|
||||
- undefined4 local_10;
|
||||
- local_20 = 0;
|
||||
- local_18 = 0;
|
||||
- local_10 = 0;
|
||||
- local_28 = 0xf030000000000;
|
||||
- calls DetroitDeviceRequest(unk) -> result
|
||||
- returns (ulonglong)(LZCOUNT(result) << 0x20) >> 0x25
|
||||
*/
|
||||
return X_E_FAIL;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiCameraGetTiltControllerType, kNone, kStub);
|
||||
|
||||
dword_result_t XamNuiCameraSetFlags_entry(qword_t unk1, dword_t unk2) {
|
||||
/* Notes:
|
||||
- if XamNuiCameraGetTiltControllerType returns 1 then operation is done
|
||||
- else 0xffffffff8007048f
|
||||
*/
|
||||
uint32_t result = X_E_DEVICE_NOT_CONNECTED;
|
||||
int Controller_Type = XamNuiCameraGetTiltControllerType_entry();
|
||||
|
||||
if (Controller_Type == 1) {
|
||||
uint32_t status = 0x50;
|
||||
result = XamNuiCameraTiltGetStatus_entry(&status);
|
||||
if (-1 < result) {
|
||||
// op here
|
||||
// result =
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiCameraSetFlags, kNone, kStub);
|
||||
|
||||
// Is
|
||||
dword_result_t XamNuiIsDeviceReady_entry() { return cvars::NUI_Ready; }
|
||||
DECLARE_XAM_EXPORT1(XamNuiIsDeviceReady, kNone, kImplemented);
|
||||
|
||||
dword_result_t XamIsNuiAutomationEnabled_entry(unknown_t unk1, unknown_t unk2) {
|
||||
/* Notes:
|
||||
- XamIsNuiAutomationEnabled = XamIsNatalPlaybackEnabled
|
||||
- Always returns X_E_SUCCESS? Maybe check later versions
|
||||
- Recieves param but never interacts with them
|
||||
- No Operations
|
||||
*/
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
DECLARE_XAM_EXPORT2(XamIsNuiAutomationEnabled, kNone, kSketchy, kHighFrequency);
|
||||
|
||||
dword_result_t XamIsNatalPlaybackEnabled_entry(unknown_t unk1, unknown_t unk2) {
|
||||
/* Notes:
|
||||
- XamIsNuiAutomationEnabled = XamIsNatalPlaybackEnabled
|
||||
- Always returns X_E_SUCCESS? Maybe check later versions
|
||||
- Recieves param but never interacts with them
|
||||
- No Operations
|
||||
*/
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
DECLARE_XAM_EXPORT2(XamIsNatalPlaybackEnabled, kNone, kSketchy, kHighFrequency);
|
||||
|
||||
dword_result_t XamNuiIsChatMicEnabled_entry() {
|
||||
/* Notes:
|
||||
- calls a second function with a param of uint local_20 [4];
|
||||
- Second function calls ExGetXConfigSetting(7,9,local_30,0x1c,local_40);
|
||||
- Result is sent to *local_20[0] = ^
|
||||
- Once sent back to XamNuiIsChatMicEnabled it looks for byte that
|
||||
correlates to NUI mic setting
|
||||
- return uVar2 = (~(ulonglong)local_20[0] << 0x20) >> 0x23 & 1;
|
||||
- unless the second function returns something -1 or less then
|
||||
XamNuiIsChatMicEnabled 1
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiIsChatMicEnabled, kNone, kImplemented);
|
||||
|
||||
// HUD
|
||||
/* Notes:
|
||||
- XamNuiHudGetEngagedTrackingID, XamNuiHudIsEnabled,
|
||||
XamNuiHudSetEngagedTrackingID, XamNuiHudInterpretFrame, and
|
||||
XamNuiHudGetEngagedEnrollmentIndex all utilize the same data address
|
||||
*/
|
||||
|
||||
uint32_t HUD_Flags = 0; // 0x40000000
|
||||
uint64_t version_id_1 = 0; // double check this
|
||||
uint64_t version_id_2 = 0; // double check this
|
||||
uint32_t engaged_tracking_id = 0; // double check this
|
||||
|
||||
dword_result_t XamNuiHudIsEnabled_entry() {
|
||||
/* Notes:
|
||||
- checks if XamNuiIsDeviceReady false and engaged_tracking_id if it exist
|
||||
and is equal to null terminated string
|
||||
- only returns true if one check fails and allows for other NUI functions
|
||||
to progress
|
||||
*/
|
||||
bool result = XamNuiIsDeviceReady_entry();
|
||||
if (engaged_tracking_id != 0 &&
|
||||
(*reinterpret_cast<char*>(&engaged_tracking_id + 0x50) != '\0') &&
|
||||
(result == true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiHudIsEnabled, kNone, kStub);
|
||||
|
||||
dword_result_t XamNuiHudSetEngagedTrackingID_entry(dword_t id) {
|
||||
if ((id & 0xffffffff) == 0) {
|
||||
return static_cast<uint32_t>(id);
|
||||
}
|
||||
|
||||
if (engaged_tracking_id != 0) {
|
||||
*reinterpret_cast<int*>(&engaged_tracking_id + 0x118) = id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return X_E_FAIL;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiHudSetEngagedTrackingID, kNone, kStub);
|
||||
|
||||
qword_result_t XamNuiHudGetEngagedTrackingID_entry() {
|
||||
if (engaged_tracking_id != 0) {
|
||||
return *reinterpret_cast<uint32_t*>(&engaged_tracking_id + 0x118);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiHudGetEngagedTrackingID, kNone, kStub);
|
||||
|
||||
uint32_t XeXamNuiHudCheck(dword_t unk1) {
|
||||
uint32_t result = 0;
|
||||
uint32_t check = XamNuiHudIsEnabled_entry();
|
||||
if (check == false) {
|
||||
result = X_ERROR_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
check = XamNuiHudSetEngagedTrackingID_entry(unk1);
|
||||
if (check != 0) {
|
||||
return X_ERROR_FUNCTION_FAILED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t XamNuiHudGetInitializeFlags_entry() { return HUD_Flags; }
|
||||
DECLARE_XAM_EXPORT1(XamNuiHudGetInitializeFlags, kNone, kImplemented);
|
||||
|
||||
void XamNuiHudGetVersions_entry(lpqword_t unk1, lpqword_t unk2) {
|
||||
if (unk1) {
|
||||
*unk1 = version_id_1;
|
||||
}
|
||||
if (unk2) {
|
||||
*unk2 = version_id_2;
|
||||
}
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiHudGetVersions, kNone, kImplemented);
|
||||
|
||||
// UI
|
||||
dword_result_t XamShowNuiTroubleshooterUI_entry(unknown_t unk1, unknown_t unk2,
|
||||
dword_t flag) {
|
||||
/* Notes:
|
||||
- unk1 is 0xFF - possibly user index?
|
||||
- unk2 appear to always be zero.
|
||||
- First calls XamPackageManagerGetExperienceMode and checks if the return
|
||||
is less than zero
|
||||
- First calls XamPackageManagerGetExperienceMode with a param of 1 and
|
||||
checks if the return is less than zero
|
||||
- If less than zero then returns error message below
|
||||
- else it checks if flag = 0x800000 if it does then call
|
||||
XamNuiGetDeviceStatus. if not return error
|
||||
- XamNuiNatalCameraUpdateComplete calls
|
||||
XamShowNuiTroubleshooterUI(0xff,0,0) if param = -0x7ff8fffe
|
||||
*/
|
||||
|
||||
if (cvars::headless) {
|
||||
|
@ -75,7 +340,7 @@ dword_result_t XamShowNuiTroubleshooterUI_entry(unknown_t unk1, unknown_t unk2,
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamShowNuiTroubleshooterUI, kNone, kStub);
|
||||
|
||||
|
@ -88,6 +353,45 @@ dword_result_t XamShowNuiHardwareRequiredUI_entry(unknown_t unk1) {
|
|||
}
|
||||
DECLARE_XAM_EXPORT1(XamShowNuiHardwareRequiredUI, kNone, kImplemented);
|
||||
|
||||
dword_result_t XamShowNuiGuideUI_entry(unknown_t unk1, unknown_t unk2) {
|
||||
/* Notes:
|
||||
- calls an unnamed function that checks XamNuiHudIsEnabled and
|
||||
XamNuiHudSetEngagedTrackingID
|
||||
- if XamNuiHudIsEnabled returns false then fuctions fails return
|
||||
X_ERROR_ACCESS_DENIED
|
||||
- else calls XamNuiHudSetEngagedTrackingID and if returns less than 0 then
|
||||
returns X_ERROR_FUNCTION_FAILED
|
||||
- else return X_ERROR_SUCCESS
|
||||
- if return offunc is X_ERROR_SUCCESS then call up ui screen
|
||||
- else return value of func
|
||||
*/
|
||||
|
||||
// decompiler error stops me from knowing which param gets used here
|
||||
uint32_t result = XeXamNuiHudCheck(0);
|
||||
if ((result & 0xffffffff) == 0) {
|
||||
// operations here
|
||||
// XMsgSystemProcessCall(0xfe,0x21030, undefined local_30[8] ,0xc);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamShowNuiGuideUI, kNone, kStub);
|
||||
|
||||
// Other
|
||||
dword_result_t XamUserNuiEnableBiometric_entry(dword_t user_index,
|
||||
int_t enable) {
|
||||
return -0x7ff8ffa9;
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamUserNuiEnableBiometric, kNone, kStub);
|
||||
|
||||
void XamNuiPlayerEngagementUpdate_entry(qword_t unk1, unknown_t unk2,
|
||||
lpunknown_t unk3) {
|
||||
/* Notes:
|
||||
- Only calls a second function with the params unk3, 0, and 0x1c in that
|
||||
order
|
||||
*/
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamNuiPlayerEngagementUpdate, kNone, kStub);
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -108,6 +108,7 @@ typedef uint32_t X_RESULT;
|
|||
#define X_ERROR_DEVICE_NOT_CONNECTED X_RESULT_FROM_WIN32(0x0000048FL)
|
||||
#define X_ERROR_NOT_FOUND X_RESULT_FROM_WIN32(0x00000490L)
|
||||
#define X_ERROR_CANCELLED X_RESULT_FROM_WIN32(0x000004C7L)
|
||||
#define X_ERROR_ABORTED X_RESULT_FROM_WIN32(0x000004D3L)
|
||||
#define X_ERROR_NOT_LOGGED_ON X_RESULT_FROM_WIN32(0x000004DDL)
|
||||
#define X_ERROR_NO_SUCH_USER X_RESULT_FROM_WIN32(0x00000525L)
|
||||
#define X_ERROR_FUNCTION_FAILED X_RESULT_FROM_WIN32(0x0000065BL)
|
||||
|
@ -310,7 +311,7 @@ enum : XNotificationID {
|
|||
kXNotificationSystemNUIBindingChanged = 0x0006001D,
|
||||
kXNotificationSystemAudioLatencyChanged = 0x0008001E,
|
||||
kXNotificationSystemNUIChatBindingChanged = 0x0008001F,
|
||||
kXNotificationSystemInputActivityChanged = 0x00009020,
|
||||
kXNotificationSystemInputActivityChanged = 0x00090020,
|
||||
|
||||
// XNotification Live
|
||||
kXNotificationLiveConnectionChanged = 0x02000001,
|
||||
|
|
Loading…
Reference in New Issue