From 4e276695bfcd23a8ba627580b70f68c89e19315a Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 4 Aug 2014 22:02:19 -0700 Subject: [PATCH] XamUserGetDeviceContext --- src/xenia/kernel/xam_input.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/xenia/kernel/xam_input.cc b/src/xenia/kernel/xam_input.cc index 5e6266cbd..b4f272447 100644 --- a/src/xenia/kernel/xam_input.cc +++ b/src/xenia/kernel/xam_input.cc @@ -202,6 +202,30 @@ SHIM_CALL XamInputGetKeystrokeEx_shim( } +SHIM_CALL XamUserGetDeviceContext_shim( + PPCContext* ppc_state, KernelState* state) { + uint32_t user_index = SHIM_GET_ARG_32(0); + uint32_t unk = SHIM_GET_ARG_32(1); + uint32_t out_ptr = SHIM_GET_ARG_32(2); + + XELOGD( + "XamUserGetDeviceContext(%d, %d, %.8X)", + user_index, + unk, + out_ptr); + + // Games check the result - usually with some masking. + // If this function fails they assume zero, so let's fail AND + // set zero just to be safe. + SHIM_SET_MEM_32(out_ptr, 0); + if (!user_index || (user_index & 0xFF) == 0xFF) { + SHIM_SET_RETURN_32(0); + } else { + SHIM_SET_RETURN_32(-1); + } +} + + } // namespace kernel } // namespace xe @@ -215,4 +239,5 @@ void xe::kernel::xam::RegisterInputExports( SHIM_SET_MAPPING("xam.xex", XamInputSetState, state); SHIM_SET_MAPPING("xam.xex", XamInputGetKeystroke, state); SHIM_SET_MAPPING("xam.xex", XamInputGetKeystrokeEx, state); + SHIM_SET_MAPPING("xam.xex", XamUserGetDeviceContext, state); }