| 144 | } |
| 145 | |
| 146 | void IInputManager::GetState( OSContPad pPad[4] ) |
| 147 | { |
| 148 | // Clear the initial state |
| 149 | for(u32 cont = 0; cont < 4; cont++) |
| 150 | { |
| 151 | pPad[cont].button = 0; |
| 152 | pPad[cont].stick_x = 0; |
| 153 | pPad[cont].stick_y = 0; |
| 154 | } |
| 155 | |
| 156 | // Check if a gamepad is connected, If not fallback to keyboard |
| 157 | if(mGamePadAvailable) |
| 158 | { |
| 159 | GetJoyPad(&pPad[0]); |
| 160 | } |
| 161 | else if(GLFWwindow* window = gWindow) |
| 162 | { |
| 163 | if (glfwGetKey( window, 'X' )) pPad[0].button |= A_BUTTON; |
| 164 | if (glfwGetKey( window, 'C' )) pPad[0].button |= B_BUTTON; |
| 165 | if (glfwGetKey( window, 'Z' )) pPad[0].button |= Z_TRIG; |
| 166 | if (glfwGetKey( window, 'Y' )) pPad[0].button |= Z_TRIG; // For German keyboards :) |
| 167 | if (glfwGetKey( window, 'A' )) pPad[0].button |= L_TRIG; |
| 168 | if (glfwGetKey( window, 'S' )) pPad[0].button |= R_TRIG; |
| 169 | |
| 170 | if (glfwGetKey( window, GLFW_KEY_ENTER )) pPad[0].button |= START_BUTTON; |
| 171 | |
| 172 | if (glfwGetKey( window, GLFW_KEY_KP_8 )) pPad[0].button |= U_JPAD; |
| 173 | if (glfwGetKey( window, GLFW_KEY_KP_2 )) pPad[0].button |= D_JPAD; |
| 174 | if (glfwGetKey( window, GLFW_KEY_KP_4 )) pPad[0].button |= L_JPAD; |
| 175 | if (glfwGetKey( window, GLFW_KEY_KP_6 )) pPad[0].button |= R_JPAD; |
| 176 | |
| 177 | if (glfwGetKey( window, GLFW_KEY_HOME )) pPad[0].button |= U_CBUTTONS; |
| 178 | if (glfwGetKey( window, GLFW_KEY_END )) pPad[0].button |= D_CBUTTONS; |
| 179 | if (glfwGetKey( window, GLFW_KEY_DELETE )) pPad[0].button |= L_CBUTTONS; |
| 180 | if (glfwGetKey( window, GLFW_KEY_PAGE_DOWN )) pPad[0].button |= R_CBUTTONS; |
| 181 | |
| 182 | if (glfwGetKey( window, GLFW_KEY_LEFT )) pPad[0].stick_x = -80; |
| 183 | if (glfwGetKey( window, GLFW_KEY_RIGHT )) pPad[0].stick_x = +80; |
| 184 | if (glfwGetKey( window, GLFW_KEY_UP )) pPad[0].stick_y = +80; |
| 185 | if (glfwGetKey( window, GLFW_KEY_DOWN )) pPad[0].stick_y = -80; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | template<> bool CSingleton< CInputManager >::Create() |
| 190 | { |