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

@@ -11,21 +11,16 @@
#define XENIA_HID_NOP_NOP_HID_PRIVATE_H_
#include <xenia/core.h>
#include <xenia/hid/nop/nop_hid.h>
namespace xe {
namespace hid {
namespace nop {
//
} // namespace nop
} // namespace hid
} // namespace xe
#endif // XENIA_HID_NOP_NOP_HID_PRIVATE_H_

View File

@@ -11,34 +11,32 @@
#include <xenia/hid/nop/nop_input_driver.h>
namespace xe {
namespace hid {
namespace nop {
using namespace xe;
using namespace xe::hid;
using namespace xe::hid::nop;
void InitializeIfNeeded();
void CleanupOnShutdown();
namespace {
void InitializeIfNeeded();
void CleanupOnShutdown();
void InitializeIfNeeded() {
static bool has_initialized = false;
if (has_initialized) {
return;
}
has_initialized = true;
//
atexit(CleanupOnShutdown);
void InitializeIfNeeded() {
static bool has_initialized = false;
if (has_initialized) {
return;
}
has_initialized = true;
void CleanupOnShutdown() {
}
//
atexit(CleanupOnShutdown);
}
void CleanupOnShutdown() {}
InputDriver* xe::hid::nop::Create(InputSystem* input_system) {
InitializeIfNeeded();
return new NopInputDriver(input_system);
}
} // namespace nop
} // namespace hid
} // namespace xe

View File

@@ -12,22 +12,17 @@
#include <xenia/core.h>
XEDECLARECLASS2(xe, hid, InputDriver);
XEDECLARECLASS2(xe, hid, InputSystem);
namespace xe {
namespace hid {
namespace nop {
InputDriver* Create(InputSystem* input_system);
} // namespace nop
} // namespace hid
} // namespace xe
#endif // XENIA_HID_NOP_NOP_HID_H_

View File

@@ -11,42 +11,40 @@
#include <xenia/hid/hid-private.h>
namespace xe {
namespace hid {
namespace nop {
using namespace xe;
using namespace xe::hid;
using namespace xe::hid::nop;
NopInputDriver::NopInputDriver(InputSystem* input_system)
: InputDriver(input_system) {}
NopInputDriver::~NopInputDriver() {}
NopInputDriver::NopInputDriver(InputSystem* input_system) :
InputDriver(input_system) {
}
NopInputDriver::~NopInputDriver() {
}
X_STATUS NopInputDriver::Setup() {
return X_STATUS_SUCCESS;
}
X_STATUS NopInputDriver::Setup() { return X_STATUS_SUCCESS; }
// TODO(benvanik): spoof a device so that games don't stop waiting for
// a controller to be plugged in.
X_RESULT NopInputDriver::GetCapabilities(
uint32_t user_index, uint32_t flags, X_INPUT_CAPABILITIES& out_caps) {
X_RESULT NopInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags,
X_INPUT_CAPABILITIES* out_caps) {
return X_ERROR_DEVICE_NOT_CONNECTED;
}
X_RESULT NopInputDriver::GetState(
uint32_t user_index, X_INPUT_STATE& out_state) {
X_RESULT NopInputDriver::GetState(uint32_t user_index,
X_INPUT_STATE* out_state) {
return X_ERROR_DEVICE_NOT_CONNECTED;
}
X_RESULT NopInputDriver::SetState(
uint32_t user_index, X_INPUT_VIBRATION& vibration) {
X_RESULT NopInputDriver::SetState(uint32_t user_index,
X_INPUT_VIBRATION* vibration) {
return X_ERROR_DEVICE_NOT_CONNECTED;
}
X_RESULT NopInputDriver::GetKeystroke(
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke) {
X_RESULT NopInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
X_INPUT_KEYSTROKE* out_keystroke) {
return X_ERROR_DEVICE_NOT_CONNECTED;
}
} // namespace nop
} // namespace hid
} // namespace xe

View File

@@ -11,39 +11,30 @@
#define XENIA_HID_NOP_NOP_INPUT_DRIVER_H_
#include <xenia/core.h>
#include <xenia/hid/input_driver.h>
#include <xenia/hid/nop/nop_hid-private.h>
namespace xe {
namespace hid {
namespace nop {
class NopInputDriver : public InputDriver {
public:
public:
NopInputDriver(InputSystem* input_system);
virtual ~NopInputDriver();
~NopInputDriver() override;
virtual X_STATUS Setup();
X_STATUS Setup() override;
virtual X_RESULT GetCapabilities(
uint32_t user_index, uint32_t flags, X_INPUT_CAPABILITIES& out_caps);
virtual X_RESULT GetState(
uint32_t user_index, X_INPUT_STATE& out_state);
virtual X_RESULT SetState(
uint32_t user_index, X_INPUT_VIBRATION& vibration);
virtual X_RESULT GetKeystroke(
uint32_t user_index, uint32_t flags, X_INPUT_KEYSTROKE& out_keystroke);
protected:
X_RESULT GetCapabilities(uint32_t user_index, uint32_t flags,
X_INPUT_CAPABILITIES* out_caps) override;
X_RESULT GetState(uint32_t user_index, X_INPUT_STATE* out_state) override;
X_RESULT SetState(uint32_t user_index, X_INPUT_VIBRATION* vibration) override;
X_RESULT GetKeystroke(uint32_t user_index, uint32_t flags,
X_INPUT_KEYSTROKE* out_keystroke) override;
};
} // namespace nop
} // namespace hid
} // namespace xe
#endif // XENIA_HID_NOP_NOP_INPUT_DRIVER_H_