Review Changes 8

This commit is contained in:
Daniel Stuart Baxter 2015-05-31 10:39:12 -05:00
parent 9ae6bf08a4
commit 61ead16c48
6 changed files with 49 additions and 51 deletions

View file

@ -24,7 +24,7 @@ void Init(EmuWindow* emu_window) {
Kernel::Init();
HLE::Init();
VideoCore::Init(emu_window);
InputCommon::Init(InputCommon::SDL2_JOY);
InputCommon::Init(InputCommon::SDL2);
}
void Shutdown() {

View file

@ -46,13 +46,13 @@ void Init(ControllerBackends backend) {
switch (backend) {
#ifdef HAS_SDL
// SDL2 backend selected
case SDL2_JOY:
case SDL2:
g_user_input = new SDLController();
break;
#endif
// No backend selected
case NO_JOY:
case NONE:
break;
// What?

View file

@ -11,8 +11,8 @@ namespace InputCommon {
/// Enum defining available backends
enum ControllerBackends {
NO_JOY,
SDL2_JOY
NONE,
SDL2
};
class ControllerBase {
@ -55,6 +55,6 @@ void Init(ControllerBackends backend);
void Shutdown();
/// InputCommon 'plugin'
extern ControllerBase* g_user_input;
extern std::unique_ptr<ControllerBase> g_user_input;
} // namespace

View file

@ -63,7 +63,7 @@ void SDLController::Shutdown() {
}
void SDLController::Poll() {
if (SDL_PollEvent(&input_event)) {
while (SDL_PollEvent(&input_event)) {
if (input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_JOYBUTTONUP
|| input_event.type == SDL_JOYAXISMOTION || input_event.type == SDL_JOYHATMOTION) {
ProcessInput();
@ -100,9 +100,9 @@ void SDLController::ProcessInput() {
pad_id += (input_event.jaxis.axis * 2);
val = input_event.jaxis.value;
if (val > 0) {
pad_id += 1;
}
// Make pad_id even or odd depending on positive/negative value
// Differentiates the direction of analog input
if (val > 0) pad_id += 1;
// If analog input is beyond dead zone, set it
if (CheckDeadZone(val)) {
@ -228,11 +228,9 @@ void SDLController::SetDeadZone(int range) {
}
bool SDLController::CheckDeadZone(int range) const {
if ((range < -dead_zone) || (range > dead_zone)) {
return true;
} else if ((range > -dead_zone) && (range < dead_zone)) {
// See if the absolute range is beyond dead zone
if (std::abs(range) > std::abs(dead_zone)) return true;
return false;
}
}
}// namespace

View file

@ -46,7 +46,7 @@ private:
SDL_Event input_event;
/// Index of joystick, used for opening/closing a joystick
int index;
u32 index;
/// Keymap id for this controller
int joypad_id;