Example #1
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.forward = False
     self.backward = False
     self.left = False
     self.right = False
     self.current_action = [0, 0, 0, 0]
    def __init__(self, object2notify):
        """Create KeyboardListener.

        :param object2notify: MainTimer object
        :type object2notify: MainTimer
        """
        CommonListener.__init__(self, object2notify)
        PyKeyboardEvent.__init__(self)
    def __init__(self, object2notify):
        """Create KeyboardListener.

        :param object2notify: MainTimer object
        :type object2notify: MainTimer
        """
        CommonListener.__init__(self, object2notify)
        PyKeyboardEvent.__init__(self)
    def __init__(self):
        PyKeyboardEvent.__init__(self)

        self.key_pub = rospy.Publisher("keyboard_publisher/key_event",
                                       KeyEvent,
                                       queue_size=10)

        self.thread = Thread(target=self.run)
        self.thread.start()
Example #5
0
    def __init__(self):
        PyKeyboardEvent.__init__(self)

        self.pub_command = rospy.Publisher("key_command", KeyCommand, queue_size=1)
        self.twist_msg = Twist()
        self.command_msg = KeyCommand()

        self.thread = Thread(target=self.run)
        self.thread.start()
 def __init__(self, callback=callfun):
     # super(Mzkeybodard, self).__init__()
     PyKeyboardEvent.__init__(self)
     self.callback = callback
     self.mzkeybo = PyKeyboard()
     self.decodekey = Decodekeyboard()
     self.mzkeybodardevent = []
     tm1 = threading.Thread(target=self.clientkeyboard)
     tm1.setDaemon(True)
     tm1.start()
Example #7
0
    def run(self):
        """
        Will run the recorder, using a queue to place data if provided

        data_queue : The queue to place the data in
        """
        # Create the data handler to use
        self.data_handler = HDF5Handler("a", self.save_interval)

        PyKeyboardEvent.run(self)
Example #8
0
    def get(self, buttonname):
        """Exits after one tap"""
        dialog = ConfigurationDialog()
        dialog.set_args(buttonname)
        dialog.show()
        xbmc.sleep(1) # why?
        PyKeyboardEvent.run(self)
        dialog.close()

        return self.keycode, self.character
Example #9
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.ack = 0
     self.player = HistoryPlayer.ThreadedPlayer()
     self.recorder = HistoryRecorder.ThreadedRecorder()
     self.commands = {'24': self.quitProgram,
                      '26': self.endRecording,
                      '33': self.playHistory,
                      '39': self.startRecording, 
                      '43': self.printHistory
                      }
Example #10
0
    def __init__(self, model, data_handler, episodes, batch_size,
                 sequence_length, decay, save_interval, save_path):
        """
        Will play the game using the given model.

        Args:
            model: The model to train.
            data_handler: The data handler for supervised training
            episodes: The number episodes to train for.
            batch_size: The batch size of the training inputs.
            sequence_lengh: The length of each batch
            decay: The decay of the n_step return.
            save_interal: The number of episodes between each save
            save_path: The path to save the model to
        """
        PyKeyboardEvent.__init__(self)

        # The model to use
        self.model = model
        self.data_handler = data_handler

        self.episodes = episodes
        self.batch_size = batch_size
        self.sequence_length = sequence_length
        self.decay = decay
        self.save_interval = save_interval
        self.save_path = save_path

        # If the program is currently running
        self.playing = False

        # If the program is listening to the keyboard
        self.listening = False

        # Get the information from the config
        window_size, playing_config, self.speedrunners = self.read_config()

        # Get the start, end and close key and the save interval from the
        # config
        self.start_key = playing_config["START_KEY"].lower()
        self.end_key = playing_config["END_KEY"].lower()
        self.close_key = playing_config["CLOSE_KEY"].lower()

        # Get the game screen size
        game_screen = (int(self.speedrunners["WIDTH"]),
                       int(self.speedrunners["HEIGHT"]))

        # Get the resized screen size from the config
        res_screen_size = (int(window_size["WIDTH"]),
                           int(window_size["HEIGHT"]),
                           int(window_size["DEPTH"]))

        self.sr_game = SpeedRunnersEnv(120, game_screen, res_screen_size)
Example #11
0
 def __init__(self, log_name, run_command=False):
     PyKeyboardEvent.__init__(self)
     self.logger = logging.getLogger(log_name + ".keyboard")
     self.run_command = run_command
     self.control_characters = {
         'BackSpace': lambda x: x.pop(),
         'Return': lambda x: flush_command(x, self.run_command),
         'Shift_L': lambda x: x,
         'Shift_R': lambda x: x
     }
     # self.logger.setLevel(logging.DEBUG)
     self.new_event = threading.Event()
     self.command = deque()
    def __init__(self, all_states):
        PyKeyboardEvent.__init__(self)

        self.all_states = all_states
        self.res_list = []
        self.hole_counter = 0
        self.save_root = 'D:/github_project/auto_press_down_gun/press_gun/generate_distance'

        self.in_tab_detect = Detector('in_tab')
        self.name_detect = Detector('weapon1name')
        self.scope_detect = Detector('weapon1scope')

        self.aim_point = Aim_Point()
Example #13
0
    def _tap(self, event):
        if SYSTEM == "Windows":
            keycode = event.KeyID
            press_bool = (event.Message
                          in [self.hc.WM_KEYDOWN, self.hc.WM_SYSKEYDOWN])

            if keycode in CHARACTER_MAP:
                character = CHARACTER_MAP[keycode]
            else:
                character = "Unknown character, keycode: " + str(keycode)

            self.tap(keycode, character, press_bool)
        else:
            PyKeyboardEvent._tap(self, event)
Example #14
0
    def __init__(self):
        """
        Will create a keyboard event listener to handle the recording and
        closing of the program using the settings in the config file.
        """
        PyKeyboardEvent.__init__(self)

        # If the program is currently running
        self.recording = False

        # If the program is listening to the keyboard
        self.listening = False

        # Get the information from the config
        recording_config, window_size, self.speedrunners = self.read_config()

        if (self.speedrunners["BOOST"] == ""):
            self.speedrunners["BOOST"] = " "

        # Get the start, end and close key and the save interval from the
        # config
        self.start_key = recording_config["START_KEY"].lower()
        self.end_key = recording_config["END_KEY"].lower()
        self.close_key = recording_config["CLOSE_KEY"].lower()
        self.save_interval = int(recording_config["SAVE_INTERVAL"])

        # Get the game screen size
        game_screen = (int(self.speedrunners["WIDTH"]),
                       int(self.speedrunners["HEIGHT"]))

        # Get the resized screen size from the config
        res_screen_size = (int(window_size["WIDTH"]),
                           int(window_size["HEIGHT"]),
                           int(window_size["DEPTH"]))

        self.sr_game = SpeedRunnersEnv(None, game_screen, res_screen_size)

        # The active actions and direction, right direction by default
        # Values -1 for off, 1 for on
        self.actions = [(self.speedrunners["JUMP"], 0),
                        (self.speedrunners["GRAPPLE"], 0),
                        (self.speedrunners["ITEM"], 0),
                        (self.speedrunners["BOOST"], 0),
                        (self.speedrunners["SLIDE"], 0),
                        (self.speedrunners["LEFT"], 0),
                        (self.speedrunners["RIGHT"], 0)]

        self.actions = OrderedDict(self.actions)
Example #15
0
class Listener(object):
    #log - log all key presses and mouse clicks
    #act_dict - actions dictionary like (keycode: actions list)
    log = []
    act_dict = {}#They both are static variables
    __keyboard_ev__ = PyKeyboardEvent()
    __keyboard__ = PyKeyboard()
    __mouse__ = PyMouse()

    def __init__(self):
        if self.act_dict == {}:
            for i in range(0, 255):
                self.act_dict[i] = []
    
    @classmethod
    def add_action(self):
        if (len(self.log) == 0):
            return
        pre_last = -1
        if (len(self.log) > 1):
            pre_last = self.log[-2]
        last = self.log[-1]
        new_actions = get_new_action(last, pre_last)
        self.act_dict[last].extend(new_actions)

    @classmethod
    def simulate(self, key_code):
        if (key_code > 8):#In X 11 keycodes start from 9 thats why
            #keycodes from 1 to 8 allocated to mouse buttons
            key_name = self.__keyboard_ev__.lookup_char_from_keycode(key_code)
            self.__keyboard__.tap_key(key_name)
        else:
            (x, y) = self.__mouse__.position()
            self.__mouse__.click(x, y, key_code)
Example #16
0
    def __init__(self):
        PyKeyboardEvent.__init__(self)

        self.space_pressed = True
        self.excluded_chars = [
            'b',
            'o',
            'Return',
            '!',
            '?',
            '.',
            'Shift_L',
            'Shift_R',
            'Command',
            'Alternate'
        ]
Example #17
0
    def __init__(self, model, replay_buffer, episodes, batch_size,
                 burn_in_length, sequence_length, decay, save_interval,
                 save_path):
        """
        Will play the game using the given model.

        Args:
            model: The model to train.
            replay_buffer: The replay buffer to store experiences in.
            episodes: The number episodes to train for.
            batch_size: The batch size of the training inputs.
            burn_in_length: The length of the burn in sequence of each batch.
            sequence_lengh: The length of the training sequence of each batch.
            decay: The decay of the n_step return.
            save_interal: The number of episodes between each save
            save_path: The path to save the model to
        """
        PyKeyboardEvent.__init__(self)

        # The model to use
        self.model = model
        self.data_handler = data_handler

        self.episodes = episodes
        self.batch_size = batch_size
        self.sequence_length = sequence_length
        self.decay = decay
        self.save_interval = save_interval
        self.save_path = save_path

        # If the program is currently running
        self.playing = False

        # If the program is listening to the keyboard
        self.listening = False

        # Get the information from the config
        playing_config = self.read_config()

        # Get the start, end and close key and the save interval from the
        # config
        self.start_key = playing_config["START_KEY"].lower()
        self.end_key = playing_config["END_KEY"].lower()
        self.close_key = playing_config["CLOSE_KEY"].lower()

        self.agent = Agent(model)
Example #18
0
    def __init__(self):
        PyKeyboardEvent.__init__(self)
        self.times = 1
        self.interval = 0.5
        self.maincode = str('print("start!!!")')
        self.precode = str('self.timemark=10')
        self.timemark = 1
        self.end_style = 'exit'  # ENUM: exit stop
        self.is_pre_enable = True
        self.is_main_enable = True

        self.keyboard = PyKeyboard()
        self.isF7Press = False
        self.isF8Press = False
        self.isLeftctrlPress = False
        self.isLeftaltPress = False
        self.isLeftshiftPress = False
    def __init__(self):
        PyKeyboardEvent.__init__(self)
        self.root_path = 'D:/github_project/auto_press_down_gun/auto_position_label/screen_captures'
        os.makedirs(self.root_path, exist_ok=True)

        self.state_folds = list()
        self.escape_c = '-'
        for k, v in screen_position_states.items():
            if len(v) > 0:
                for state in v:
                    self.state_folds.append(k + self.escape_c + state)

        self.state_n_max = len(self.state_folds) - 1
        self.state_n = 0
        self.im_n = 0

        self.temp_qobject = Temp_QObject()
Example #20
0
 def __init__(self, lgtv):
     PyKeyboardEvent.__init__(self)
     self.lgtv = lgtv
     self.ctrl = False
Example #21
0
 def __init__(self, key_str='ctrl+shift+alt+f8'):
     PyKeyboardEvent.__init__(self)
     self.key_map = TriggerKeyboardEvent.create_key_map(TriggerKeyboardEvent.parse_full_key_str(key_str))
     self.is_trigger = False
Example #22
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.logger = logger.getChild("keyboard")
     # self.logger.setLevel(logging.DEBUG)
     self.new_event = threading.Event()
     self._reset_data()
Example #23
0
 def stop(self):
     PyKeyboardEvent.stop(self)
Example #24
0
 def stop(self):
     PyKeyboardEvent.stop(self)
     kodi.log("keygetter stopped")
Example #25
0
 def __init__(self):
     PyKeyboardEvent.__init__(self, capture=True)
Example #26
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.state = 1  # is_running?
Example #27
0
 def run(self):
     PyKeyboardEvent.run(self)
     print "end"
Example #28
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
 def __init__(self, keyboard_type, path_config):
     PyKeyboardEvent.__init__(self)
     self.keyboard_type = keyboard_type
     self.config = util.load_json(path_config)
     self.now_keyboard_event = ''
Example #30
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.tapped = False
Example #31
0
 def __init__(self, m_listener):
     PyKeyboardEvent.__init__(self)
     self.mouse_listener = m_listener
Example #32
0
 def __init__(self, ev):
     PyKeyboardEvent.__init__(self)
     self.cntl = False;
     self.event = ev
Example #33
0
    def __init__(self, logdata):
        PyKeyboardEvent.__init__(self)
        self.logdata = logdata

        self.lastTime = time.time()
        self.lastStrokeVolume = self.logdata.keyStroke
Example #34
0
 def __init__(self, callback=callfun):
     # super(Mzkeybodard, self).__init__()
     PyKeyboardEvent.__init__(self)
     self.callback = callback
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.logger = logger.getChild("keyboard")
     # self.logger.setLevel(logging.DEBUG)
     self.new_event = threading.Event()
     self._reset_data()
Example #36
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
Example #37
0
 def __init__(self, keyboard_listener):
     self.keyboard_listener = keyboard_listener
     PyKeyboardEvent.__init__(self)
Example #38
0
 def __init__(self, capture=False):
     PyKeyboardEvent.__init__(self, capture=capture)
     self.escaped = 0
     self.ended = 0
Example #39
0
 def __init__(self, funcmap):
     self.funcmap = funcmap
     mapped_codes = set(self.funcmap)
     PyKeyboardEvent.__init__(self, capture_codes=mapped_codes)
Example #40
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.input = ""
     self.diagnostic = True
     self.k = pykeyboard.PyKeyboard()
Example #41
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.mouse_click = MouseClick()
 def run(self):
     PyKeyboardEvent.run(self)
Example #43
0
 def __init__(self, keyboard_activity_event):
     PyKeyboardEvent.__init__(self)
     self.keyboard_activity_event = keyboard_activity_event
 def __init__(self,wLocation):
     PyKeyboardEvent.__init__(self)
     self._startTime = time.time()
     self._lastEventTime = self._startTime
     self._writeLocation = wLocation
     self._keyEventList = []
Example #45
0
 def __init__(self):
     PyKeyboardEvent.__init__(self)
     self.callno = 0
     self.pressedkeys = set()
Example #46
0
    def __init__(self):
        PyKeyboardEvent.__init__(self)

        # list of listener functions
        self.tapListeners = []