当前位置: 首页>>代码示例>>Python>>正文


Python pybullet.getKeyboardEvents方法代码示例

本文整理汇总了Python中pybullet.getKeyboardEvents方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.getKeyboardEvents方法的具体用法?Python pybullet.getKeyboardEvents怎么用?Python pybullet.getKeyboardEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybullet的用法示例。


在下文中一共展示了pybullet.getKeyboardEvents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_key_pressed

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getKeyboardEvents [as 别名]
def get_key_pressed(self, relevant=None):
        pressed_keys = []
        events = p.getKeyboardEvents()
        key_codes = events.keys()
        for key in key_codes:
            pressed_keys.append(key)
        return pressed_keys 
开发者ID:gkahn13,项目名称:GtS,代码行数:9,代码来源:env_modalities.py

示例2: _key_events_fetcher

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import getKeyboardEvents [as 别名]
def _key_events_fetcher(self):
        """Fetch and decode keyboard events in Bullet GUI.

        Returns:
            events: list of (key, key_act, modifiers) tuples.
        """
        # Fetch events
        bullet_events = p.getKeyboardEvents()
        # Map event id to key name
        if self._key_dict is None:
            key_dict = {}
            for i in xrange(128):
                key_dict[i] = str(unichr(i))
            key_dict[65295] = 'LEFT'
            key_dict[65296] = 'RIGHT'
            key_dict[65297] = 'UP'
            key_dict[65298] = 'DOWN'
            key_dict[65309] = 'ENTER'
            self._key_dict = key_dict
        # Map event id to key activity name
        if self._key_act_dict is None:
            key_act_dict = {}
            key_act_dict[1] = 'DOWN'
            key_act_dict[2] = 'TRIGGERED'
            key_act_dict[3] = 'UNKNOWN(3L)'
            key_act_dict[4] = 'RELEASED'
            key_act_dict[5] = 'UNKNOWN(5L)'
            key_act_dict[6] = 'UNKNOWN(6L)'
            self._key_act_dict = key_act_dict
        # Map event id to modifier key names
        if self._modifier_dict is None:
            modifier_dict = {}
            modifier_dict[65306] = 'SHIFT'
            modifier_dict[65307] = 'CTRL'
            modifier_dict[65308] = 'OPTION'
            self._modifier_dict = modifier_dict
        # Decode events
        events = []
        for key, key_act in bullet_events.items():
            if self._key_dict.has_key(key):
                key_name = self._key_dict[key]
            elif self._modifier_dict.has_key(key):
                key_name = self._modifier_dict[key]
            else:
                key_name = None
            key_act_name = self._key_act_dict[key_act]
            events.append((key_name, key_act_name))
        return events 
开发者ID:StanfordVL,项目名称:NTP-vat-release,代码行数:50,代码来源:bullet_world.py


注:本文中的pybullet.getKeyboardEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。