| 144 | } |
| 145 | |
| 146 | UINT SNESMAXCard::GetControllerButtons(UINT joyNum, JOYINFOEX& infoEx, bool altControllerType) |
| 147 | { |
| 148 | UINT xAxis = (infoEx.dwXpos >> 8) & 0xFF; |
| 149 | UINT yAxis = (infoEx.dwYpos >> 8) & 0xFF; |
| 150 | |
| 151 | UINT controllerButtons = 0; |
| 152 | controllerButtons |= ((yAxis < 103 || infoEx.dwPOV == 0 || infoEx.dwPOV == 4500 || infoEx.dwPOV == 31500) << 4); // U Button |
| 153 | controllerButtons |= ((yAxis > 153 || (infoEx.dwPOV >= 13500 && infoEx.dwPOV <= 22500)) << 5); // D Button |
| 154 | controllerButtons |= ((xAxis < 103 || (infoEx.dwPOV >= 22500 && infoEx.dwPOV <= 31500)) << 6); // L Button |
| 155 | controllerButtons |= ((xAxis > 153 || (infoEx.dwPOV >= 4500 && infoEx.dwPOV <= 13500)) << 7); // R Button |
| 156 | |
| 157 | UINT* controllerButtonMappings = !altControllerType ? (UINT*)m_mainControllerButtons : (UINT*)(&m_altControllerButtons[joyNum][0]); |
| 158 | |
| 159 | for (UINT i = 0; i < NUM_BUTTONS; i++) |
| 160 | { |
| 161 | if (infoEx.dwButtons & (1 << i)) |
| 162 | { |
| 163 | if (controllerButtonMappings[i] != UNUSED) |
| 164 | controllerButtons |= (1 << controllerButtonMappings[i]); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | return controllerButtons | 0x10000; // Controller plugged in status. |
| 169 | } |
| 170 | |
| 171 | void SNESMAXCard::InitializeIO(LPBYTE pCxRomPeripheral) |
| 172 | { |