Converting HID API to use be<> auto swapping type.

This commit is contained in:
Ben Vanik
2014-08-19 22:50:21 -07:00
parent 48a0e5c601
commit fb98683ed3
24 changed files with 325 additions and 518 deletions

View File

@@ -58,6 +58,8 @@ using PPCContext = alloy::frontend::ppc::PPCContext;
#define SHIM_SET_RETURN_32(v) SHIM_SET_GPR_64(3, (uint64_t)(int32_t)v)
#define SHIM_SET_RETURN_64(v) SHIM_SET_GPR_64(3, v)
#define SHIM_STRUCT(type, address) \
reinterpret_cast<type*>(SHIM_MEM_ADDR(address))
} // namespace kernel
} // namespace xe

View File

@@ -58,11 +58,8 @@ SHIM_CALL XamInputGetCapabilities_shim(PPCContext* ppc_state,
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_CAPABILITIES caps;
auto caps = SHIM_STRUCT(X_INPUT_CAPABILITIES, caps_ptr);
X_RESULT result = input_system->GetCapabilities(user_index, flags, caps);
if (XSUCCEEDED(result)) {
caps.Write(SHIM_MEM_BASE, caps_ptr);
}
SHIM_SET_RETURN_32(result);
}
@@ -78,13 +75,8 @@ SHIM_CALL XamInputGetState_shim(PPCContext* ppc_state, KernelState* state) {
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_STATE input_state;
auto input_state = SHIM_STRUCT(X_INPUT_STATE, state_ptr);
X_RESULT result = input_system->GetState(user_index, input_state);
if (XSUCCEEDED(result)) {
if (state_ptr) {
input_state.Write(SHIM_MEM_BASE, state_ptr);
}
}
SHIM_SET_RETURN_32(result);
}
@@ -103,7 +95,7 @@ SHIM_CALL XamInputSetState_shim(PPCContext* ppc_state, KernelState* state) {
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_VIBRATION vibration(SHIM_MEM_BASE, vibration_ptr);
auto vibration = SHIM_STRUCT(X_INPUT_VIBRATION, vibration_ptr);
X_RESULT result = input_system->SetState(user_index, vibration);
SHIM_SET_RETURN_32(result);
}
@@ -128,11 +120,8 @@ SHIM_CALL XamInputGetKeystroke_shim(PPCContext* ppc_state, KernelState* state) {
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_KEYSTROKE keystroke;
auto keystroke = SHIM_STRUCT(X_INPUT_KEYSTROKE, keystroke_ptr);
X_RESULT result = input_system->GetKeystroke(user_index, flags, keystroke);
if (XSUCCEEDED(result)) {
keystroke.Write(SHIM_MEM_BASE, keystroke_ptr);
}
SHIM_SET_RETURN_32(result);
}
@@ -155,11 +144,10 @@ SHIM_CALL XamInputGetKeystrokeEx_shim(PPCContext* ppc_state,
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_KEYSTROKE keystroke;
auto keystroke = SHIM_STRUCT(X_INPUT_KEYSTROKE, keystroke_ptr);
X_RESULT result = input_system->GetKeystroke(user_index, flags, keystroke);
if (XSUCCEEDED(result)) {
SHIM_SET_MEM_32(user_index_ptr, keystroke.user_index);
keystroke.Write(SHIM_MEM_BASE, keystroke_ptr);
SHIM_SET_MEM_32(user_index_ptr, keystroke->user_index);
}
SHIM_SET_RETURN_32(result);
}