package com.firemint.realracing; import com.bda.controller.Controller; import com.bda.controller.ControllerListener; import com.bda.controller.KeyEvent; import com.bda.controller.MotionEvent; import com.bda.controller.StateEvent; import com.firemint.realracing.ControllerManager; /* loaded from: classes2.dex */ public class ControllerManager_Moga implements ControllerListener { Controller m_controller; ControllerManager m_controllerManager; MainActivity m_mainActivity; final String m_strDescriptor = "Moga"; final int m_DeviceIdOffset = 10000; public ControllerManager_Moga(MainActivity mainActivity, ControllerManager controllerManager) { this.m_controller = null; this.m_mainActivity = mainActivity; this.m_controllerManager = controllerManager; Controller controller = Controller.getInstance(mainActivity); this.m_controller = controller; if (controller != null) { controller.init(); this.m_controller.setListener(this, this.m_mainActivity.handler); } } public void onDestroy() { if (this.m_controller != null) { this.m_controllerManager.Log("Moga::onDestroy"); this.m_controller.exit(); } } public void onPause() { if (this.m_controller != null) { this.m_controllerManager.Log("Moga::onPause"); this.m_controller.onPause(); } } public void onResume() { if (this.m_controller != null) { this.m_controllerManager.Log("Moga::onResume"); this.m_controller.onResume(); } } @Override // com.bda.controller.ControllerListener public void onKeyEvent(KeyEvent keyEvent) { int keyCode = keyEvent.getKeyCode(); if ((keyCode == 104 || keyCode == 105) && this.m_controller.getState(4) == 1) { return; } this.m_controllerManager.HandleKeyEvents(keyEvent.getControllerId() + 10000, keyEvent.getKeyCode(), keyEvent.getAction()); } @Override // com.bda.controller.ControllerListener public void onStateEvent(StateEvent stateEvent) { int i; String str; int state = stateEvent.getState(); if (state != 1) { if (state == 2) { if (stateEvent.getAction() == 1) { this.m_controllerManager.Log("Moga::STATE_POWER_LOW (TRUE)"); return; } else { this.m_controllerManager.Log("Moga::STATE_POWER_LOW (FALSE)"); return; } } this.m_controllerManager.Log("Moga::Unhandled state event:"); return; } int action = stateEvent.getAction(); if (action == 0) { this.m_controllerManager.Log("Moga::ACTION_DISCONNECTED"); this.m_controllerManager.ControllerDisconnected(stateEvent.getControllerId() + 10000); return; } if (action == 1) { this.m_controllerManager.Log("Moga::ACTION_CONNECTED"); if (this.m_controller.getState(4) == 1) { str = "MOGA Pro"; i = 45; } else { i = 9; str = "MOGA Pocket"; } this.m_controllerManager.ControllerConnected(str, "Moga", stateEvent.getControllerId() + 10000, i); return; } if (action == 2) { this.m_controllerManager.Log("Moga::ACTION_CONNECTING"); return; } this.m_controllerManager.Log("Moga::Unhandled action in STATE_CONNECTION::" + stateEvent.getAction()); } @Override // com.bda.controller.ControllerListener public void onMotionEvent(MotionEvent motionEvent) { this.m_controllerManager.SetJoystickValues(motionEvent.getControllerId() + 10000, motionEvent.getAxisValue(0), ControllerManager.ControllerAxis.AXIS_LTHUMB_X); this.m_controllerManager.SetJoystickValues(motionEvent.getControllerId() + 10000, motionEvent.getAxisValue(1), ControllerManager.ControllerAxis.AXIS_LTHUMB_Y); this.m_controllerManager.SetJoystickValues(motionEvent.getControllerId() + 10000, motionEvent.getAxisValue(11), ControllerManager.ControllerAxis.AXIS_RTHUMB_X); this.m_controllerManager.SetJoystickValues(motionEvent.getControllerId() + 10000, motionEvent.getAxisValue(14), ControllerManager.ControllerAxis.AXIS_RTHUMB_Y); this.m_controllerManager.SetJoystickValues(motionEvent.getControllerId() + 10000, motionEvent.getAxisValue(17), ControllerManager.ControllerAxis.AXIS_LTRIGGER); this.m_controllerManager.SetJoystickValues(motionEvent.getControllerId() + 10000, motionEvent.getAxisValue(18), ControllerManager.ControllerAxis.AXIS_RTRIGGER); } }