mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 16:41:05 +00:00
Review Changes 8
This commit is contained in:
parent
9ae6bf08a4
commit
61ead16c48
@ -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() {
|
||||
|
@ -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?
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user