Beispiel #1
0
 def _check_modifiers_against_pressed_keys(self, modifiers):
     modifiers_from_keys = self._translate_option_modifier(self._get_modifiers_from_pressed_keys())
     modifiers = self._translate_option_modifier(modifiers)
     if modifiers != modifiers_from_keys:
         self.fail_test('Received modifiers "{}" do not match pressed keys "{}"'.format(
                             key.modifiers_string(modifiers),
                             key.modifiers_string(modifiers_from_keys)))
Beispiel #2
0
 def on_key_press(self, symbol, modifiers):
     letter = key.symbol_string(symbol)
     if self.verbose:
         print("press:",letter,key.modifiers_string(modifiers))
     _keyboard.add(key.symbol_string(symbol))
     if self.keypress is not None:
         kwargs = {
         "window":self,
         "symbol":key.symbol_string(symbol),
         "modifiers":key.modifiers_string(modifiers)
         }
         self.keypress(**kwargs)
Beispiel #3
0
 def on_key_release(self, symbol, modifiers):
     letter = key.symbol_string(symbol)
     if self.verbose: print("release:",letter,key.modifiers_string(modifiers))
     
     _keyboard.remove(key.symbol_string(symbol))
     if self.keyrelease is not None:
         kwargs = {
         "window":self,
         "symbol":key.symbol_string(symbol),
         "modifiers":key.modifiers_string(modifiers)
         }
         self.keyrelease(**kwargs)
Beispiel #4
0
 def on_key_press(self, symbol, modifiers):
     letter = key.symbol_string(symbol)
     if self.verbose:
         print("press:", letter, key.modifiers_string(modifiers))
     _keyboard.add(key.symbol_string(symbol))
     if self.keypress is not None:
         kwargs = {
             "window": self,
             "symbol": key.symbol_string(symbol),
             "modifiers": key.modifiers_string(modifiers)
         }
         self.keypress(**kwargs)
Beispiel #5
0
    def on_key_release(self, symbol, modifiers):
        letter = key.symbol_string(symbol)
        if self.verbose: print("release:",letter,key.modifiers_string(modifiers))

        _keyboard.remove(key.symbol_string(symbol))
        if self.keyrelease is not None:
            kwargs = {
            "window":self,
            "symbol":key.symbol_string(symbol),
            "modifiers":key.modifiers_string(modifiers)
            }
            self.keyrelease(**kwargs)
Beispiel #6
0
    def on_key_press(self, symbol, modifiers):
        if pymterm.debug_log:
            LOGGER.debug('on_key_press:{}, {}'.format(
                key.symbol_string(symbol),
                key.modifiers_string(modifiers)))

        key_state = KeyState(symbol, modifiers)

        if symbol == key.Q and \
           (modifiers == key.MOD_COMMAND or modifiers == key.MOD_CTRL):
            self.close()
            return

        if self.session.terminal.process_key(key_state):
            if pymterm.debug_log:
                LOGGER.debug(' processed by pyterm')
            return

        v, handled = term.term_keyboard.translate_key(self.session.terminal,
                                                      key_state)

        if len(v) > 0:
            self.session.send(v)

        self._key_first_down = True
Beispiel #7
0
    def on_key_press(self, symbol, modifiers):
        import p5.globals
        from pyglet.window import key
        try:
            if modifiers == 0:
                p5.globals.keycode.set(ord(key.symbol_string(symbol)))
            else:
                p5.globals.keycode.set(None)
        except TypeError:
            p5.globals.keycode.set(None)
        p5.globals.key.set(key.symbol_string(symbol).replace("_", ""))
        if modifiers != 0:
            p5.globals.modifiers.set(
                key.modifiers_string(modifiers).replace("|", ",").replace(
                    "MOD_", ""))
        else:
            p5.globals.modifiers.set(None)
        p5.globals.keyispressed.set(True)
        try:
            self.KeyPressed()
        except AttributeError:
            pass

        if modifiers == 0:
            try:
                self.KeyTyped()
            except AttributeError:
                pass
Beispiel #8
0
 def print_keypress_actions(self):
     items = sorted(self.keypress_actions.items())
     for keypress, action in items:
         keysymbol = key.symbol_string(keypress[0]).lstrip(' _')
         modifiers = key.modifiers_string(keypress[1]).replace('MOD_', '').replace('|', ' ').lstrip(' ')
         func, args, kwargs = action[0].__name__, action[1], action[2]
         print('{:<10} {:<6} --- {:<30}({}, {})'.format(modifiers, keysymbol, func, args, kwargs))
    def on_key_press(self, symbol, modifiers):
        print 'Pressed %s with modifiers %s' % \
            (key.symbol_string(symbol), key.modifiers_string(modifiers))

        if symbol == key.E:
            exclusive = not (modifiers & key.MOD_SHIFT)
            self.w.set_exclusive_keyboard(exclusive)
            print 'Exclusive keyboard is now %r' % exclusive
Beispiel #10
0
 def on_mouse_drag(self, x, y, dx, dy, button, modifiers):
     if self.verbose:
         print("drag")
     if self.mousedrag is not None:
         kwargs = {
         "window":self, 
         "posn":(x,y), 
         "button":button, 
         "modifiers":key.modifiers_string(modifiers)
         }
         self.mousedrag(**kwargs)
Beispiel #11
0
 def on_mouse_drag(self, x, y, dx, dy, button, modifiers):
     if self.verbose:
         print("drag")
     if self.mousedrag is not None:
         kwargs = {
             "window": self,
             "posn": (x, y),
             "button": button,
             "modifiers": key.modifiers_string(modifiers)
         }
         self.mousedrag(**kwargs)
Beispiel #12
0
 def on_mouse_release(self, x, y, button, modifiers):
     if self.verbose:
         print("release")
     _mouse.remove(_button_string(button))
     if self.mouserelease is not None:
         kwargs = {
             "window": self,
             "posn": (x, y),
             "button": _button_string(button),
             "modifiers": key.modifiers_string(modifiers)
         }
         self.mouserelease(**kwargs)
Beispiel #13
0
 def on_mouse_press(self, x, y, button, modifiers):
     if self.verbose:
         print("press")
     _mouse.add(_button_string(button))
     if self.mousepress is not None:
         kwargs = {
             "window": self,
             "posn": (x, y),
             "button": _button_string(button),
             "modifiers": key.modifiers_string(modifiers)
         }
         self.mousepress(**kwargs)
Beispiel #14
0
 def on_mouse_press(self, x, y, button, modifiers):
     if self.verbose:
         print("press")
     _mouse.add(_button_string(button))
     if self.mousepress is not None:
         kwargs = {
         "window":self,
         "posn":(x,y),
         "button":_button_string(button),
         "modifiers":key.modifiers_string(modifiers)
         }
         self.mousepress(**kwargs)
Beispiel #15
0
 def on_mouse_release(self, x, y, button, modifiers):
     if self.verbose:
         print("release")
     _mouse.remove(_button_string(button))
     if self.mouserelease is not None:
         kwargs = {
         "window":self, 
         "posn":(x,y), 
         "button":_button_string(button), 
         "modifiers":key.modifiers_string(modifiers)
         }
         self.mouserelease(**kwargs)
Beispiel #16
0
def check(binding):
    possible_keys = bindings.get(binding)
    for keyset in possible_keys:
        try:
            sym, mods = keyset
        except TypeError:
            sym = keyset
            mods = 0
        allk = [sym,]
        # TODO: the modifiers code isn't working properly
        mods = key.modifiers_string(mods)
        for m in filter(None, mods.split('|')):
            allk.append(getattr(key, m))
        pressedk = filter(lambda x: blackmango.ui.game_window.keyboard[x], allk)
        return pressedk == allk
Beispiel #17
0
Datei: gui.py Projekt: 2bam/afe
def on_key_press(symbol, modifiers):
	global selected
	global process
	global game_running

	if symbol == key.UP:
		selected = (selected - 1) % len(game_infos)
		refresh()
	elif symbol == key.DOWN:
		selected = (selected + 1) % len(game_infos)
		refresh()
	elif symbol == key.F and (modifiers&key.MOD_ALT) != 0:
		#window.set_fullscreen(not window.fullscreen, **mconf.window_size)
		pass
	elif symbol == key.ESCAPE:
		kill_proc()
		raise SystemExit()
	elif symbol == key.RETURN:
		kill_proc()
		exec = game_infos[selected]['execute']
		if exec:
			exec_dir = os.path.join(mconf.games_folder, game_infos[selected]['name'])
			print(_('Ejecutando [{exe}] con CWD=[{cwd}]').format(exe=exec, cwd=exec_dir))
			exec_list = shlex.split(exec, posix=True)
			exec_list[0] = os.path.join(exec_dir, exec_list[0])
			print(exec_list)
			try:
				#Windows hack: Give focus to window TODO: is this still needed?
				#windows-only
				si = subprocess.STARTUPINFO()
				si.dwFlags = subprocess.STARTF_USESHOWWINDOW
				SW_SHOW = 5
				si.wShowWindow = SW_SHOW

				process = subprocess.Popen(exec_list, cwd=exec_dir, startupinfo=si)
				last_input = 0
				game_running = game_infos[selected]['name']
				# gui.process = subprocess.Popen(exec_path, cwd=exec_dir)
				print(_('OK'))
			except:
				print(_('ERROR AL EJECUTAR: ') + str(sys.exc_info()[0]))
				process = None
				game_running = None

	print('A key was pressed sym=' + key.symbol_string(symbol) + ' mod=' + key.modifiers_string(modifiers))
Beispiel #18
0
    def on_key_press(self, symbol, modifiers):
        if pymterm.debug_log:
            LOGGER.debug('on_key_press:{}, {}'.format(
                key.symbol_string(symbol), key.modifiers_string(modifiers)))

        key_state = KeyState(symbol, modifiers)

        if symbol == key.Q and \
           (modifiers == key.MOD_COMMAND or modifiers == key.MOD_CTRL):
            self.close()
            return

        if self.session.terminal.process_key(key_state):
            if pymterm.debug_log:
                LOGGER.debug(' processed by pyterm')
            return

        v, handled = term.term_keyboard.translate_key(self.session.terminal,
                                                      key_state)

        if len(v) > 0:
            self.session.send(v)

        self._key_first_down = True
Beispiel #19
0
def check(binding):
    """
    Check *binding* to see if it is being pressed at the moment. The value of
    *binding* should be one of the keys in :data:`bindings`.
    """
    possible_keys = bindings.get(binding)
    try:
        iter(possible_keys)
    except TypeError:
        possible_keys = [possible_keys,]
    for keyset in possible_keys:
        try:
            sym, mods = keyset
        except TypeError:
            sym = keyset
            mods = 0
        allk = [sym,]
        # TODO: the modifiers code isn't working properly
        mods = key.modifiers_string(mods)
        for m in filter(None, mods.split('|')):
            allk.append(getattr(key, m))
        pressedk = filter(lambda x: deltav.ui.game_window.keyboard[x], allk)
        pressedk = list(pressedk)
        return pressedk == allk
Beispiel #20
0
 def on_key_release(self, symbol, modifiers):
     print('on_key_release(symbol=%s, modifiers=%s)' %
           (key.symbol_string(symbol), key.modifiers_string(modifiers)),
           file=self.file)
Beispiel #21
0
 def on_mouse_release(self, x, y, button, modifiers):
     print 'Mouse button %d released at %f,%f with %s' % \
         (button, x, y, key.modifiers_string(modifiers))
Beispiel #22
0
def key_str((symbol, modifiers)):
    return (key.symbol_string(symbol), key.modifiers_string(modifiers))
Beispiel #23
0
    def on_key_press(self, symb, mods):
        self.symb, self.mods, self.symbStr, self.modsStr = symb, mods, pygwink.symbol_string(symb), pygwink.modifiers_string(mods)
        self.kbk = self.symbStr  ;  kbk = self.kbk
        self.log('(BGN) {}'.format(self.kpEvntTxt()))
        if                  self.isTab(kbk):                          self.addTab(kbk, 'on_key_press')
        elif kbk == 'Q' and self.isCtrl(mods) and self.isShift(mods): self.quit('keyPress({})'.format(kbk))
        elif kbk == 'Q' and self.isCtrl(mods):                        self.quit('keyPress({})'.format(kbk))
        elif kbk == 'F' and self.isCtrl(mods) and self.isShift(mods): self.toggleFullScreen()
        elif kbk == 'F' and self.isCtrl(mods):                        self.toggleFullScreen()
#        self.updateCaption()
        self.log('(END) {}'.format(self.kpEvntTxt()))
Beispiel #24
0
 def on_mouse_release(self, x, y, button, modifiers):
     print('on_mouse_release(x=%d, y=%d, button=%r, '\
                         'modifiers=%s)' % (x, y, 
         mouse.buttons_string(button), key.modifiers_string(modifiers)), file=self.file)
Beispiel #25
0
 def on_key_release(self, symbol, modifiers):
     print('on_key_release(symbol=%s, modifiers=%s)' % (
         key.symbol_string(symbol), key.modifiers_string(modifiers)), file=self.file)
Beispiel #26
0
 def on_key_press(self, symbol, modifiers):
     print >> self.file, 'on_key_press(symbol=%s, modifiers=%s)' % (
         key.symbol_string(symbol), key.modifiers_string(modifiers))
 def on_key_release(self, symbol, modifiers):
     print 'Released %s with modifiers %s' % \
         (key.symbol_string(symbol), key.modifiers_string(modifiers))
Beispiel #28
0
 def on_key_press(self, symbol, modifiers):
     print >> self.file, 'on_key_press(symbol=%s, modifiers=%s)' % (
         key.symbol_string(symbol), key.modifiers_string(modifiers))
Beispiel #29
0
 def on_key_press(self, symbol, modifiers):
     print 'Pressed %s with modifiers %s' % \
         (key.symbol_string(symbol), key.modifiers_string(modifiers))
Beispiel #30
0
 def on_mouse_press(self, x, y, button, modifiers):
     print >> self.file, 'on_mouse_press(x=%d, y=%d, button=%r, '\
                         'modifiers=%s)' % (x, y,
         mouse.buttons_string(button), key.modifiers_string(modifiers))
Beispiel #31
0
 def on_mouse_press(self, x, y, button, modifiers):
     print >> self.file, 'on_mouse_press(x=%d, y=%d, button=%r, '\
                         'modifiers=%s)' % (x, y,
         mouse.buttons_string(button), key.modifiers_string(modifiers))
Beispiel #32
0
 def on_mouse_press(self, x, y, button, modifiers):
     print "on_mouse_press(x={}, y={}, button={}, modifiers={})".format(
         x, y, mouse.buttons_string(button),
         key.modifiers_string(modifiers))
Beispiel #33
0
 def __str__(self):
     return key.symbol_string(self.key) + ' ' + key.modifiers_string(self.modifiers)
Beispiel #34
0
 def on_key_press(self, symb, mods):
     self.symb, self.mods, self.symbStr, self.modsStr = symb, mods, pygwink.symbol_string(symb), pygwink.modifiers_string(mods)
     self.kbk = self.symbStr ; kbk = self.kbk
     print('on_key_press(BGN)     {}'.format(self.kpEvntTxt()), file=DBG_FILE)
     if                  self.isTab(kbk):                          self.addTab(kbk)
     elif kbk == 'Q' and self.isCtrl(mods) and self.isShift(mods): self.quit('on_key_press({})'.format(kbk))
     elif kbk == 'Q' and self.isCtrl(mods):                        self.quit('on_key_press({})'.format(kbk))
     elif kbk == 'C' and self.isCtrl(mods) and self.isShift(mods): self.updateFontColor( 1)
     elif kbk == 'C' and self.isCtrl(mods):                        self.updateFontColor(-1)
     elif kbk == 'D' and self.isCtrl(mods) and self.isShift(mods): self.updateFontDpi(   1)
     elif kbk == 'D' and self.isCtrl(mods):                        self.updateFontDpi(  -1)
     elif kbk == 'N' and self.isCtrl(mods) and self.isShift(mods): self.updateFontName(  1)
     elif kbk == 'N' and self.isCtrl(mods):                        self.updateFontName( -1)
     elif kbk == 'S' and self.isCtrl(mods) and self.isShift(mods): self.updateFontSize(  1)
     elif kbk == 'S' and self.isCtrl(mods):                        self.updateFontSize( -1)
     elif kbk == 'B' and self.isCtrl(mods) and self.isShift(mods): self.toggleFontBold()
     elif kbk == 'B' and self.isCtrl(mods):                        self.toggleFontBold()
     elif kbk == 'I' and self.isCtrl(mods) and self.isShift(mods): self.toggleFontItalic()
     elif kbk == 'I' and self.isCtrl(mods):                        self.toggleFontItalic()
     self.updateCaption()
Beispiel #35
0
 def on_key_press(self, symbol, modifiers):
     print '{} was pressed with modifers: {}'.format(
         key.symbol_string(symbol), key.modifiers_string(modifiers))
Beispiel #36
0
 def on_mouse_release(self, x, y, button, modifiers):
     print('Mouse button %d released at %f,%f with %s' % \
         (button, x, y, key.modifiers_string(modifiers)))
Beispiel #37
0
 def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
     print('on_mouse_drag(x=%d, y=%d, dx=%d, dy=%d, '\
                         'buttons=%s, modifiers=%s)' % (
           x, y, dx, dy,
           mouse.buttons_string(buttons), key.modifiers_string(modifiers)), file=self.file)
Beispiel #38
0
 def on_mouse_drag(self, x, y, dx, dy, button, modifiers):
     print('Mouse dragged. Button %d pressed. dx, dy %f,%f with %s' % \
         (button, dx, dy, key.modifiers_string(modifiers)))
Beispiel #39
0
 def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
     print "on_mouse_release(x={}, y={}, dx={}, dy={}, button={}, modifiers={})".format(
         x, y, dx, dy, mouse.buttons_string(buttons),
         key.modifiers_string(modifiers))
Beispiel #40
0
 def on_key_press(self, symbol, modifiers):
     print('Pressed %s with modifiers %s' %
           (key.symbol_string(symbol), key.modifiers_string(modifiers)))
Beispiel #41
0
 def on_mouse_release(self, x, y, button, modifiers):
     print('on_mouse_release(x=%d, y=%d, button=%r, modifiers=%s)' %
           (x, y, mouse.buttons_string(button),
            key.modifiers_string(modifiers)),
           file=self.file)
Beispiel #42
0
 def on_key_press(self, symbol, modifiers):
     print '{} was pressed with modifers: {}'.format(key.symbol_string(symbol), key.modifiers_string(modifiers))
Beispiel #43
0
 def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
     print(
         'on_mouse_drag(x=%d, y=%d, dx=%d, dy=%d, buttons=%s, modifiers=%s)'
         % (x, y, dx, dy, mouse.buttons_string(buttons),
            key.modifiers_string(modifiers)),
         file=self.file)
Beispiel #44
0
 def on_mouse_press(self, x, y, button, modifiers):
     print('Mouse button %d pressed at %f,%f with %s' %
           (button, x, y, key.modifiers_string(modifiers)))