mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 18: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();
|
Kernel::Init();
|
||||||
HLE::Init();
|
HLE::Init();
|
||||||
VideoCore::Init(emu_window);
|
VideoCore::Init(emu_window);
|
||||||
InputCommon::Init(InputCommon::SDL2_JOY);
|
InputCommon::Init(InputCommon::SDL2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
|
@ -46,13 +46,13 @@ void Init(ControllerBackends backend) {
|
|||||||
switch (backend) {
|
switch (backend) {
|
||||||
#ifdef HAS_SDL
|
#ifdef HAS_SDL
|
||||||
// SDL2 backend selected
|
// SDL2 backend selected
|
||||||
case SDL2_JOY:
|
case SDL2:
|
||||||
g_user_input = new SDLController();
|
g_user_input = new SDLController();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// No backend selected
|
// No backend selected
|
||||||
case NO_JOY:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// What?
|
// What?
|
||||||
|
@ -11,8 +11,8 @@ namespace InputCommon {
|
|||||||
|
|
||||||
/// Enum defining available backends
|
/// Enum defining available backends
|
||||||
enum ControllerBackends {
|
enum ControllerBackends {
|
||||||
NO_JOY,
|
NONE,
|
||||||
SDL2_JOY
|
SDL2
|
||||||
};
|
};
|
||||||
|
|
||||||
class ControllerBase {
|
class ControllerBase {
|
||||||
@ -55,6 +55,6 @@ void Init(ControllerBackends backend);
|
|||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
/// InputCommon 'plugin'
|
/// InputCommon 'plugin'
|
||||||
extern ControllerBase* g_user_input;
|
extern std::unique_ptr<ControllerBase> g_user_input;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -63,7 +63,7 @@ void SDLController::Shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SDLController::Poll() {
|
void SDLController::Poll() {
|
||||||
if (SDL_PollEvent(&input_event)) {
|
while (SDL_PollEvent(&input_event)) {
|
||||||
if (input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_JOYBUTTONUP
|
if (input_event.type == SDL_JOYBUTTONDOWN || input_event.type == SDL_JOYBUTTONUP
|
||||||
|| input_event.type == SDL_JOYAXISMOTION || input_event.type == SDL_JOYHATMOTION) {
|
|| input_event.type == SDL_JOYAXISMOTION || input_event.type == SDL_JOYHATMOTION) {
|
||||||
ProcessInput();
|
ProcessInput();
|
||||||
@ -100,9 +100,9 @@ void SDLController::ProcessInput() {
|
|||||||
pad_id += (input_event.jaxis.axis * 2);
|
pad_id += (input_event.jaxis.axis * 2);
|
||||||
val = input_event.jaxis.value;
|
val = input_event.jaxis.value;
|
||||||
|
|
||||||
if (val > 0) {
|
// Make pad_id even or odd depending on positive/negative value
|
||||||
pad_id += 1;
|
// Differentiates the direction of analog input
|
||||||
}
|
if (val > 0) pad_id += 1;
|
||||||
|
|
||||||
// If analog input is beyond dead zone, set it
|
// If analog input is beyond dead zone, set it
|
||||||
if (CheckDeadZone(val)) {
|
if (CheckDeadZone(val)) {
|
||||||
@ -228,11 +228,9 @@ void SDLController::SetDeadZone(int range) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SDLController::CheckDeadZone(int range) const {
|
bool SDLController::CheckDeadZone(int range) const {
|
||||||
if ((range < -dead_zone) || (range > dead_zone)) {
|
// See if the absolute range is beyond dead zone
|
||||||
return true;
|
if (std::abs(range) > std::abs(dead_zone)) return true;
|
||||||
} else if ((range > -dead_zone) && (range < dead_zone)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}// namespace
|
}// namespace
|
||||||
|
@ -46,7 +46,7 @@ private:
|
|||||||
SDL_Event input_event;
|
SDL_Event input_event;
|
||||||
|
|
||||||
/// Index of joystick, used for opening/closing a joystick
|
/// Index of joystick, used for opening/closing a joystick
|
||||||
int index;
|
u32 index;
|
||||||
|
|
||||||
/// Keymap id for this controller
|
/// Keymap id for this controller
|
||||||
int joypad_id;
|
int joypad_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user