Moving input structs out of xbox.h.

Progress on #297.
This commit is contained in:
Ben Vanik 2015-06-27 11:37:12 -07:00
parent 8c69a4df09
commit 7e0246c381
7 changed files with 94 additions and 65 deletions

View File

@ -389,6 +389,7 @@
<ClInclude Include="src\xenia\gpu\ucode_disassembler.h" />
<ClInclude Include="src\xenia\gpu\xenos.h" />
<ClInclude Include="src\xenia\hid\hid_flags.h" />
<ClInclude Include="src\xenia\hid\input.h" />
<ClInclude Include="src\xenia\hid\input_driver.h" />
<ClInclude Include="src\xenia\hid\input_system.h" />
<ClInclude Include="src\xenia\hid\nop\nop_hid.h" />

View File

@ -1485,6 +1485,9 @@
<ClInclude Include="src\xenia\apu\nop\nop_apu_flags.h">
<Filter>src\xenia\apu\nop</Filter>
</ClInclude>
<ClInclude Include="src\xenia\hid\input.h">
<Filter>src\xenia\hid</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="src\xenia\cpu\backend\x64\x64_sequence.inl">

86
src/xenia/hid/input.h Normal file
View File

@ -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<uint16_t> buttons;
be<uint8_t> left_trigger;
be<uint8_t> right_trigger;
be<int16_t> thumb_lx;
be<int16_t> thumb_ly;
be<int16_t> thumb_rx;
be<int16_t> thumb_ry;
};
static_assert_size(X_INPUT_GAMEPAD, 12);
struct X_INPUT_STATE {
be<uint32_t> packet_number;
X_INPUT_GAMEPAD gamepad;
};
static_assert_size(X_INPUT_STATE, sizeof(X_INPUT_GAMEPAD) + 4);
struct X_INPUT_VIBRATION {
be<uint16_t> left_motor_speed;
be<uint16_t> right_motor_speed;
};
static_assert_size(X_INPUT_VIBRATION, 4);
struct X_INPUT_CAPABILITIES {
be<uint8_t> type;
be<uint8_t> sub_type;
be<uint16_t> 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<uint16_t> virtual_key;
be<uint16_t> unicode;
be<uint16_t> flags;
be<uint8_t> user_index;
be<uint8_t> hid_code;
};
static_assert_size(X_INPUT_KEYSTROKE, 8);
} // namespace hid
} // namespace xe
#endif // XENIA_HID_INPUT_H_

View File

@ -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 {

View File

@ -14,6 +14,7 @@
#include <vector>
#include "xenia/cpu/processor.h"
#include "xenia/hid/input.h"
#include "xenia/memory.h"
#include "xenia/xbox.h"

View File

@ -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) {

View File

@ -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<uint16_t> buttons;
be<uint8_t> left_trigger;
be<uint8_t> right_trigger;
be<int16_t> thumb_lx;
be<int16_t> thumb_ly;
be<int16_t> thumb_rx;
be<int16_t> thumb_ry;
};
static_assert_size(X_INPUT_GAMEPAD, 12);
struct X_INPUT_STATE {
be<uint32_t> packet_number;
X_INPUT_GAMEPAD gamepad;
};
static_assert_size(X_INPUT_STATE, sizeof(X_INPUT_GAMEPAD) + 4);
struct X_INPUT_VIBRATION {
be<uint16_t> left_motor_speed;
be<uint16_t> right_motor_speed;
};
static_assert_size(X_INPUT_VIBRATION, 4);
struct X_INPUT_CAPABILITIES {
be<uint8_t> type;
be<uint8_t> sub_type;
be<uint16_t> 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<uint16_t> virtual_key;
be<uint16_t> unicode;
be<uint16_t> flags;
be<uint8_t> user_index;
be<uint8_t> hid_code;
};
static_assert_size(X_INPUT_KEYSTROKE, 8);
struct X_LIST_ENTRY {
be<uint32_t> flink_ptr; // next entry / head
be<uint32_t> blink_ptr; // previous entry / head