MCPcopy
hub / github.com/Sentdex/pygta5 / parseKeyString

Method parseKeyString

original_project/keys.py:265–372  ·  view source on GitHub ↗
(self, string)

Source from the content-addressed store, hash-verified

263
264 # parses keys string and adds keys to the queue
265 def parseKeyString(self, string):
266
267 # print keys
268 if not self.standalone:
269 self.common.info("Processing keys: %s" % string)
270
271 key_queue = []
272 errors = []
273
274 # defaults to direct keys
275 key_type = self.direct_keys
276
277 # split by comma
278 keys = string.upper().split(",")
279
280 # translate
281 for key in keys:
282
283 # up, down or stroke?
284 up = True
285 down = True
286 direction = key.split("_")
287 subkey = direction[0]
288 if len(direction) >= 2:
289 if direction[1] == 'UP':
290 down = False
291 else:
292 up = False
293
294 # switch to virtual keys
295 if subkey == "VK":
296 key_type = self.virtual_keys
297
298 # switch to direct keys
299 elif subkey == "DK":
300 key_type = self.direct_keys
301
302 # key code
303 elif subkey.startswith("0x"):
304 subkey = int(subkey, 16)
305 if subkey > 0 and subkey < 256:
306 key_queue.append({
307 "key": int(subkey),
308 "okey": subkey,
309 "time": 0,
310 "up": up,
311 "down": down,
312 "type": key_type,
313 })
314 else:
315 errors.append(key)
316
317 # pause
318 elif subkey.startswith("-"):
319 time = float(subkey.replace("-", ""))/1000
320 if time > 0 and time <= 10:
321 key_queue.append({
322 "key": None,

Callers 1

keys.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected