Python pygame.locals.K_h() Examples

The following are 6 code examples of pygame.locals.K_h(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygame.locals , or try the search function .
Example #1
Source File: carla08interface.py    From coiltraine with MIT License 6 votes vote down vote up
def parse_events(self, world, clock):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_BACKSPACE:
                    world.restart()
                elif event.key == K_F1:
                    world.hud.toggle_info()
                elif event.key == K_h or (
                        event.key == K_SLASH and pygame.key.get_mods() & KMOD_SHIFT):
                    world.hud.help.toggle()
                elif event.key == K_LEFT:
                    self._command_cache = 3.0
                elif event.key == K_RIGHT:
                    self._command_cache = 4.0
                elif event.key == K_DOWN:
                    self._command_cache = 2.0
                elif event.key == K_UP:
                    self._command_cache = 5.0

        world._command_cache = self._command_cache 
Example #2
Source File: carla09interface.py    From coiltraine with MIT License 6 votes vote down vote up
def parse_events(self, world, clock):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_BACKSPACE:
                    world.restart()
                elif event.key == K_F1:
                    world.hud.toggle_info()
                elif event.key == K_h or (
                        event.key == K_SLASH and pygame.key.get_mods() & KMOD_SHIFT):
                    world.hud.help.toggle()
                elif event.key == K_LEFT:
                    self._command_cache = 3.0
                elif event.key == K_RIGHT:
                    self._command_cache = 4.0
                elif event.key == K_DOWN:
                    self._command_cache = 2.0
                elif event.key == K_UP:
                    self._command_cache = 5.0

        world._command_cache = self._command_cache 
Example #3
Source File: manual_control.py    From macad-gym with MIT License 5 votes vote down vote up
def parse_events(self, world, clock):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_BACKSPACE:
                    world.restart()
                elif event.key == K_h or (event.key == K_SLASH and pygame.key.get_mods() & KMOD_SHIFT):
                    world.hud.help.toggle()
                elif event.key == K_TAB:
                    world.camera_manager.toggle_camera()
                elif event.key == K_c and pygame.key.get_mods() & KMOD_SHIFT:
                    world.next_weather(reverse=True)
                elif event.key == K_c:
                    world.next_weather()
                elif event.key == K_BACKQUOTE:
                    world.camera_manager.next_sensor()
                elif event.key > K_0 and event.key <= K_9:
                    world.camera_manager.set_sensor(event.key - 1)
                elif event.key == K_r:
                    world.camera_manager.toggle_recording()
                elif event.key == K_q:
                    self._control.reverse = not self._control.reverse
                elif event.key == K_p:
                    self._autopilot_enabled = not self._autopilot_enabled
                    world.vehicle.set_autopilot(self._autopilot_enabled)
                    world.hud.notification('Autopilot %s' % ('On' if self._autopilot_enabled else 'Off'))
        if not self._autopilot_enabled:
            self._parse_keys(pygame.key.get_pressed(), clock.get_time())
            world.vehicle.apply_control(self._control) 
Example #4
Source File: carla_manual_control.py    From ros-bridge with MIT License 5 votes vote down vote up
def parse_events(self, clock):
        """
        parse an input event
        """
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_F1:
                    self.hud.toggle_info()
                elif event.key == K_h or (event.key == K_SLASH and
                                          pygame.key.get_mods() & KMOD_SHIFT):
                    self.hud.help.toggle()
                elif event.key == K_b:
                    self.vehicle_control_manual_override = not self.vehicle_control_manual_override
                    self.set_vehicle_control_manual_override(self.vehicle_control_manual_override)
                if event.key == K_q:
                    self._control.gear = 1 if self._control.reverse else -1
                elif event.key == K_m:
                    self._control.manual_gear_shift = not self._control.manual_gear_shift
                    self.hud.notification('%s Transmission' % (
                        'Manual' if self._control.manual_gear_shift else 'Automatic'))
                elif self._control.manual_gear_shift and event.key == K_COMMA:
                    self._control.gear = max(-1, self._control.gear - 1)
                elif self._control.manual_gear_shift and event.key == K_PERIOD:
                    self._control.gear = self._control.gear + 1
                elif event.key == K_p:
                    self._autopilot_enabled = not self._autopilot_enabled
                    self.set_autopilot(self._autopilot_enabled)
                    self.hud.notification('Autopilot %s' % (
                        'On' if self._autopilot_enabled else 'Off'))
        if not self._autopilot_enabled and self.vehicle_control_manual_override:
            self._parse_vehicle_keys(pygame.key.get_pressed(), clock.get_time())
            self._control.reverse = self._control.gear < 0 
Example #5
Source File: runner.py    From PiWeatherRock with MIT License 4 votes vote down vote up
def process_pygame_events(self):
        """
        pygame events are how we learn about a window being closed or
        resized or a key being pressed. This function looks for the events
        we care about and reacts when needed.
        """

        for event in pygame.event.get():
            if event.type == QUIT:
                self.running = False
            elif event.type == VIDEORESIZE:
                self.my_weather_rock.sizing(event.size)
            elif event.type == KEYDOWN:

                # On 'q' or keypad enter key, quit the program.
                if ((event.key == K_KP_ENTER) or (event.key == K_q)):
                    self.running = False

                # On 'd' key, set mode to 'daily weather'.
                elif event.key == K_d:
                    self.current_screen = 'd'
                    self.d_count = 1
                    self.h_count = 0
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # on 'h' key, set mode to 'hourly weather'
                elif event.key == K_h:
                    self.current_screen = 'h'
                    self.d_count = 0
                    self.h_count = 1
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # On 'i' key, set mode to 'info'.
                elif event.key == K_i:
                    self.current_screen = 'i'
                    self.d_count = 0
                    self.h_count = 0
                    self.non_weather_timeout = 0
                    self.periodic_info_activation = 0

                # On 's' key, save a screen shot.
                elif event.key == K_s:
                    self.my_weather_rock.screen_cap() 
Example #6
Source File: keyboard_control.py    From macad-gym with MIT License 4 votes vote down vote up
def parse_events(self, world, clock):
        self.vehicle = world.actor_list[self.actor_id]
        self.vehicle.set_autopilot(self._autopilot_enabled)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYUP:
                if self._is_quit_shortcut(event.key):
                    return True
                elif event.key == K_BACKSPACE:
                    world.restart()
                elif event.key == K_F1:
                    world.hud.toggle_info()
                elif event.key == K_h or (event.key == K_SLASH and
                                          pygame.key.get_mods() & KMOD_SHIFT):
                    world.hud.help.toggle()
                elif event.key == K_TAB:
                    world.camera_manager.toggle_camera()
                elif event.key == K_c and pygame.key.get_mods() & KMOD_SHIFT:
                    world.next_weather(reverse=True)
                elif event.key == K_c:
                    world.next_weather()
                elif event.key == K_BACKQUOTE:
                    world.camera_manager.next_sensor()
                elif event.key > K_0 and event.key <= K_9:
                    world.camera_manager.set_sensor(event.key - 1 - K_0)
                elif event.key == K_r:
                    world.camera_manager.toggle_recording()
                elif event.key == K_q:
                    self._control.reverse = not self._control.reverse
                elif event.key == K_p:
                    self._autopilot_enabled = not self._autopilot_enabled
                    self.vehicle.set_autopilot(self._autopilot_enabled)
                    world.hud.notification(
                        'Autopilot %s' %
                        ('On' if self._autopilot_enabled else 'Off'))
        if not self._autopilot_enabled:
            if self.actor_id == 0:
                self._parse_keys1(pygame.key.get_pressed(), clock.get_time())
            elif self.actor_id == 1:
                self._parse_keys2(pygame.key.get_pressed(), clock.get_time())
            elif self.actor_id == -1:  # use default ones
                self._parse_keys(pygame.key.get_pressed(), clock.get_time())
            self.vehicle.apply_control(self._control)