MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / handle_input_loop

Method handle_input_loop

pager/pager_display.py:274–334  ·  view source on GitHub ↗

Handle button input for navigation and pause menu.

(self)

Source from the content-addressed store, hash-verified

272 self.dim_screen()
273
274 def handle_input_loop(self):
275 """Handle button input for navigation and pause menu."""
276 logger.info("Input handler: Monitoring for button presses")
277 while not self.shared_data.display_should_exit:
278 try:
279 event = self.pager.get_input_event()
280 if not event:
281 time.sleep(0.016)
282 continue
283
284 button, event_type, timestamp = event
285 if event_type != Pager.EVENT_PRESS:
286 continue
287
288 self.wake_screen()
289
290 if button == Pager.BTN_B:
291 logger.info("Red button pressed - showing pause menu")
292 action = self.show_exit_confirmation()
293 if action is None:
294 continue
295 logger.info(f"Menu action: exit code {action}")
296 self.shared_data.should_exit = True
297 self.shared_data.display_should_exit = True
298 self.shared_data.orchestrator_should_exit = True
299 if action == 42:
300 data_dir = os.path.join(PAYLOAD_DIR, 'data')
301 os.makedirs(data_dir, exist_ok=True)
302 next_payload_path = os.path.join(data_dir, '.next_payload')
303 with open(next_payload_path, 'w') as f:
304 f.write(self._handoff_launcher_path)
305 self.cleanup()
306 os._exit(action)
307
308 elif button == Pager.BTN_LEFT:
309 self.current_screen = (self.current_screen - 1) % SCREEN_COUNT
310 self.scroll_offset = 0
311
312 elif button == Pager.BTN_RIGHT:
313 self.current_screen = (self.current_screen + 1) % SCREEN_COUNT
314 self.scroll_offset = 0
315
316 elif button == Pager.BTN_UP:
317 if self.current_screen in SETTINGS_SCREENS:
318 self._settings_move_selection(-1)
319 elif self.scroll_offset > 0:
320 self.scroll_offset -= 1
321
322 elif button == Pager.BTN_DOWN:
323 if self.current_screen in SETTINGS_SCREENS:
324 self._settings_move_selection(1)
325 else:
326 self.scroll_offset += 1
327
328 elif button == Pager.BTN_A:
329 if self.current_screen in SETTINGS_SCREENS:
330 self._settings_activate()
331

Callers

nothing calls this directly

Calls 10

wake_screenMethod · 0.95
cleanupMethod · 0.95
_settings_activateMethod · 0.95
infoMethod · 0.80
errorMethod · 0.80
get_input_eventMethod · 0.45
sleepMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected