Process common input (TAB, J, C, ESC)
()
| 315 | |
| 316 | |
| 317 | def process_common_input(): |
| 318 | """Process common input (TAB, J, C, ESC)""" |
| 319 | keys = pygame.key.get_pressed() |
| 320 | |
| 321 | if not hasattr(process_common_input, "tab_pressed"): |
| 322 | process_common_input.tab_pressed = False |
| 323 | process_common_input.c_pressed = False |
| 324 | process_common_input.j_pressed = False |
| 325 | |
| 326 | switch = False |
| 327 | if keys[pygame.K_TAB] and not process_common_input.tab_pressed: |
| 328 | switch = True |
| 329 | process_common_input.tab_pressed = True |
| 330 | elif not keys[pygame.K_TAB]: |
| 331 | process_common_input.tab_pressed = False |
| 332 | |
| 333 | save_poses = False |
| 334 | if keys[pygame.K_c] and not process_common_input.c_pressed: |
| 335 | save_poses = True |
| 336 | process_common_input.c_pressed = True |
| 337 | elif not keys[pygame.K_c]: |
| 338 | process_common_input.c_pressed = False |
| 339 | |
| 340 | toggle_joint = False |
| 341 | if keys[pygame.K_j] and not process_common_input.j_pressed: |
| 342 | toggle_joint = True |
| 343 | process_common_input.j_pressed = True |
| 344 | elif not keys[pygame.K_j]: |
| 345 | process_common_input.j_pressed = False |
| 346 | |
| 347 | return switch, save_poses, toggle_joint |
| 348 | |
| 349 | |
| 350 | def obs_to_state_dict(obs, scenario): |