| 218 | } |
| 219 | |
| 220 | bool CtrUi::ProcessEvents() { |
| 221 | if (!aptMainLoop()) { |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | hidScanInput(); |
| 226 | u32 input = hidKeysHeld(); |
| 227 | keys[Input::Keys::JOY_DPAD_UP] = (input & KEY_DUP); |
| 228 | keys[Input::Keys::JOY_DPAD_DOWN] = (input & KEY_DDOWN); |
| 229 | keys[Input::Keys::JOY_DPAD_RIGHT] = (input & KEY_DRIGHT); |
| 230 | keys[Input::Keys::JOY_DPAD_LEFT] = (input & KEY_DLEFT); |
| 231 | keys[Input::Keys::JOY_A] = (input & KEY_A); |
| 232 | keys[Input::Keys::JOY_B] = (input & KEY_B); |
| 233 | keys[Input::Keys::JOY_X] = (input & KEY_X); |
| 234 | keys[Input::Keys::JOY_Y] = (input & KEY_Y); |
| 235 | keys[Input::Keys::JOY_SHOULDER_LEFT] = (input & KEY_L); |
| 236 | keys[Input::Keys::JOY_SHOULDER_RIGHT] = (input & KEY_R); |
| 237 | keys[Input::Keys::JOY_BACK] = (input & KEY_SELECT); |
| 238 | keys[Input::Keys::JOY_START] = (input & KEY_START); |
| 239 | |
| 240 | #if defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS) |
| 241 | // CirclePad support |
| 242 | circlePosition circlepad; |
| 243 | hidCircleRead(&circlepad); |
| 244 | |
| 245 | auto normalize = [](int value) { |
| 246 | return static_cast<float>(value) / 0x9C; |
| 247 | }; |
| 248 | |
| 249 | analog_input.primary.x = normalize(circlepad.dx); |
| 250 | analog_input.primary.y = -normalize(circlepad.dy); |
| 251 | #endif |
| 252 | |
| 253 | #ifndef _DEBUG |
| 254 | // Touchscreen support |
| 255 | u32 keys_tbl[16] = { |
| 256 | Input::Keys::N7, Input::Keys::N8, Input::Keys::N9, Input::Keys::NONE, |
| 257 | Input::Keys::N4, Input::Keys::N5, Input::Keys::N6, Input::Keys::KP_DIVIDE, |
| 258 | Input::Keys::N1, Input::Keys::N2, Input::Keys::N3, Input::Keys::KP_MULTIPLY, |
| 259 | Input::Keys::N0, Input::Keys::KP_PERIOD, Input::Keys::KP_ADD, Input::Keys::KP_SUBTRACT |
| 260 | }; |
| 261 | |
| 262 | for (int i = 0; i < 16; i++) |
| 263 | keys[keys_tbl[i]] = false; |
| 264 | |
| 265 | if (input & KEY_TOUCH) { |
| 266 | if(bottom_state != screen_state::off) { |
| 267 | bottom_state = screen_state::touched; |
| 268 | touchPosition pos; |
| 269 | hidTouchRead(&pos); |
| 270 | u8 col = pos.px / button_width; |
| 271 | u8 row = pos.py / button_height; |
| 272 | |
| 273 | // Turn off touchscreen for top right button |
| 274 | if (row == 0 && col == 3) { |
| 275 | if(released_touch) { |
| 276 | ToggleBottomScreen(false); |
| 277 | released_touch = false; |
no outgoing calls
no test coverage detected