diff --git a/libxenia.vcxproj b/libxenia.vcxproj index 2dd787e50..c9a638789 100644 --- a/libxenia.vcxproj +++ b/libxenia.vcxproj @@ -389,6 +389,7 @@ + diff --git a/libxenia.vcxproj.filters b/libxenia.vcxproj.filters index 542889405..aa315161f 100644 --- a/libxenia.vcxproj.filters +++ b/libxenia.vcxproj.filters @@ -1485,6 +1485,9 @@ src\xenia\apu\nop + + src\xenia\hid + diff --git a/src/xenia/hid/input.h b/src/xenia/hid/input.h new file mode 100644 index 000000000..3170a76e5 --- /dev/null +++ b/src/xenia/hid/input.h @@ -0,0 +1,86 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2015 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#ifndef XENIA_HID_INPUT_H_ +#define XENIA_HID_INPUT_H_ + +#include "xenia/base/assert.h" +#include "xenia/base/byte_order.h" + +namespace xe { +namespace hid { + +enum X_INPUT_FLAG { + X_INPUT_FLAG_GAMEPAD = 0x00000001, +}; + +enum X_INPUT_GAMEPAD_BUTTON { + X_INPUT_GAMEPAD_DPAD_UP = 0x0001, + X_INPUT_GAMEPAD_DPAD_DOWN = 0x0002, + X_INPUT_GAMEPAD_DPAD_LEFT = 0x0004, + X_INPUT_GAMEPAD_DPAD_RIGHT = 0x0008, + X_INPUT_GAMEPAD_START = 0x0010, + X_INPUT_GAMEPAD_BACK = 0x0020, + X_INPUT_GAMEPAD_LEFT_THUMB = 0x0040, + X_INPUT_GAMEPAD_RIGHT_THUMB = 0x0080, + X_INPUT_GAMEPAD_LEFT_SHOULDER = 0x0100, + X_INPUT_GAMEPAD_RIGHT_SHOULDER = 0x0200, + X_INPUT_GAMEPAD_A = 0x1000, + X_INPUT_GAMEPAD_B = 0x2000, + X_INPUT_GAMEPAD_X = 0x4000, + X_INPUT_GAMEPAD_Y = 0x8000, +}; + +struct X_INPUT_GAMEPAD { + be buttons; + be left_trigger; + be right_trigger; + be thumb_lx; + be thumb_ly; + be thumb_rx; + be thumb_ry; +}; +static_assert_size(X_INPUT_GAMEPAD, 12); + +struct X_INPUT_STATE { + be packet_number; + X_INPUT_GAMEPAD gamepad; +}; +static_assert_size(X_INPUT_STATE, sizeof(X_INPUT_GAMEPAD) + 4); + +struct X_INPUT_VIBRATION { + be left_motor_speed; + be right_motor_speed; +}; +static_assert_size(X_INPUT_VIBRATION, 4); + +struct X_INPUT_CAPABILITIES { + be type; + be sub_type; + be flags; + X_INPUT_GAMEPAD gamepad; + X_INPUT_VIBRATION vibration; +}; +static_assert_size(X_INPUT_CAPABILITIES, + sizeof(X_INPUT_GAMEPAD) + sizeof(X_INPUT_VIBRATION) + 4); + +// http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinput_keystroke(v=vs.85).aspx +struct X_INPUT_KEYSTROKE { + be virtual_key; + be unicode; + be flags; + be user_index; + be hid_code; +}; +static_assert_size(X_INPUT_KEYSTROKE, 8); + +} // namespace hid +} // namespace xe + +#endif // XENIA_HID_INPUT_H_ diff --git a/src/xenia/hid/input_driver.h b/src/xenia/hid/input_driver.h index 913a40a18..b768c5965 100644 --- a/src/xenia/hid/input_driver.h +++ b/src/xenia/hid/input_driver.h @@ -10,6 +10,7 @@ #ifndef XENIA_HID_INPUT_DRIVER_H_ #define XENIA_HID_INPUT_DRIVER_H_ +#include "xenia/hid/input.h" #include "xenia/xbox.h" namespace xe { diff --git a/src/xenia/hid/input_system.h b/src/xenia/hid/input_system.h index 9a1bb6cf9..6bb8ef72e 100644 --- a/src/xenia/hid/input_system.h +++ b/src/xenia/hid/input_system.h @@ -14,6 +14,7 @@ #include #include "xenia/cpu/processor.h" +#include "xenia/hid/input.h" #include "xenia/memory.h" #include "xenia/xbox.h" diff --git a/src/xenia/kernel/xam_input.cc b/src/xenia/kernel/xam_input.cc index 09042728a..421b6e7ec 100644 --- a/src/xenia/kernel/xam_input.cc +++ b/src/xenia/kernel/xam_input.cc @@ -9,6 +9,7 @@ #include "xenia/base/logging.h" #include "xenia/emulator.h" +#include "xenia/hid/input.h" #include "xenia/hid/input_system.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" @@ -18,7 +19,7 @@ namespace xe { namespace kernel { -using xe::hid::InputSystem; +using namespace xe::hid; SHIM_CALL XamResetInactivity_shim(PPCContext* ppc_context, KernelState* kernel_state) { diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index dfc0bf01a..6c5f17e1f 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -309,70 +309,6 @@ struct X_VIDEO_MODE { }; static_assert_size(X_VIDEO_MODE, 48); -enum X_INPUT_FLAG { - X_INPUT_FLAG_GAMEPAD = 0x00000001, -}; - -enum X_INPUT_GAMEPAD_BUTTON { - X_INPUT_GAMEPAD_DPAD_UP = 0x0001, - X_INPUT_GAMEPAD_DPAD_DOWN = 0x0002, - X_INPUT_GAMEPAD_DPAD_LEFT = 0x0004, - X_INPUT_GAMEPAD_DPAD_RIGHT = 0x0008, - X_INPUT_GAMEPAD_START = 0x0010, - X_INPUT_GAMEPAD_BACK = 0x0020, - X_INPUT_GAMEPAD_LEFT_THUMB = 0x0040, - X_INPUT_GAMEPAD_RIGHT_THUMB = 0x0080, - X_INPUT_GAMEPAD_LEFT_SHOULDER = 0x0100, - X_INPUT_GAMEPAD_RIGHT_SHOULDER = 0x0200, - X_INPUT_GAMEPAD_A = 0x1000, - X_INPUT_GAMEPAD_B = 0x2000, - X_INPUT_GAMEPAD_X = 0x4000, - X_INPUT_GAMEPAD_Y = 0x8000, -}; - -struct X_INPUT_GAMEPAD { - be buttons; - be left_trigger; - be right_trigger; - be thumb_lx; - be thumb_ly; - be thumb_rx; - be thumb_ry; -}; -static_assert_size(X_INPUT_GAMEPAD, 12); - -struct X_INPUT_STATE { - be packet_number; - X_INPUT_GAMEPAD gamepad; -}; -static_assert_size(X_INPUT_STATE, sizeof(X_INPUT_GAMEPAD) + 4); - -struct X_INPUT_VIBRATION { - be left_motor_speed; - be right_motor_speed; -}; -static_assert_size(X_INPUT_VIBRATION, 4); - -struct X_INPUT_CAPABILITIES { - be type; - be sub_type; - be flags; - X_INPUT_GAMEPAD gamepad; - X_INPUT_VIBRATION vibration; -}; -static_assert_size(X_INPUT_CAPABILITIES, - sizeof(X_INPUT_GAMEPAD) + sizeof(X_INPUT_VIBRATION) + 4); - -// http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinput_keystroke(v=vs.85).aspx -struct X_INPUT_KEYSTROKE { - be virtual_key; - be unicode; - be flags; - be user_index; - be hid_code; -}; -static_assert_size(X_INPUT_KEYSTROKE, 8); - struct X_LIST_ENTRY { be flink_ptr; // next entry / head be blink_ptr; // previous entry / head