MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / GetControllerButtons

Method GetControllerButtons

source/SNESMAX.cpp:146–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146UINT 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
171void SNESMAXCard::InitializeIO(LPBYTE pCxRomPeripheral)
172{

Callers 1

IOWriteMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected