Created
November 1, 2017 02:14
-
-
Save Prof9/23521d6700db371737a5fdc248d22022 to your computer and use it in GitHub Desktop.
Input replay PoC on PS4 Remote Play using FreePIE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
fps = 60 | |
print_interval = 10 | |
def getTime(): | |
return int(time.clock() * 1000) | |
def getFrameCount(): | |
global start, fps, delay | |
now = getTime() | |
return (now - start) * fps // 1000 | |
def update(): | |
global start, print_last, input_start, cur_tas | |
global input_right, input_left, input_jump | |
global start_right, start_left, start_jump | |
t = getFrameCount() | |
if keyboard.getKeyDown(Key.D): | |
if not input_start: | |
diagnostics.debug("starting input at " + str(t)) | |
start = getTime() | |
t = getFrameCount() | |
input_start = True | |
if not input_right: | |
#diagnostics.debug(str(t) + " Right Down") | |
start_right = t | |
keyboard.setPressed(Key.RightArrow); | |
input_right = True | |
elif input_right: | |
#diagnostics.debug(str(t) + " Right Up, lasted " + str(t - start_right)) | |
diagnostics.debug("doInput(" + str(start_right) + ", " + str(t - start_right) + ", Key.RightArrow)") | |
input_right = False | |
if keyboard.getKeyDown(Key.A): | |
if not input_left: | |
#diagnostics.debug(str(t) + " Left Down") | |
start_left = t | |
keyboard.setPressed(Key.LeftArrow); | |
input_left = True | |
elif input_left: | |
#diagnostics.debug(str(t) + " Left Up, lasted " + str(t - start_left)) | |
diagnostics.debug("doInput(" + str(start_left) + ", " + str(t - start_left) + ", Key.LeftArrow)") | |
input_left = False | |
if keyboard.getKeyDown(Key.W): | |
if not input_jump: | |
#diagnostics.debug(str(t) + " Jump Down") | |
start_jump = t | |
keyboard.setPressed(Key.Escape); | |
input_jump = True | |
elif input_jump: | |
#diagnostics.debug(str(t) + " Jump Up, lasted " + str(t - start_jump)) | |
diagnostics.debug("doInput(" + str(start_jump) + ", " + str(t - start_jump) + ", Key.Escape)") | |
input_jump = False | |
if t % print_interval == 0 and t > print_last: | |
print_last = t | |
#diagnostics.debug(t) | |
if keyboard.getKeyDown(Key.D0): | |
start = getTime() | |
cur_tas = 0 | |
if keyboard.getKeyDown(Key.D1): | |
start = getTime() | |
cur_tas = 1 | |
if keyboard.getKeyDown(Key.D2): | |
start = getTime() | |
cur_tas = 2 | |
if cur_tas == 1: | |
doTas1() | |
if cur_tas == 2: | |
doTas2() | |
def doInput(start, length, key): | |
t = getFrameCount() | |
if start <= t < start+length: | |
keyboard.setPressed(key) | |
def doTas1(): | |
t = getFrameCount() | |
doInput(518, 14, Key.Escape) | |
doInput(0, 774, Key.RightArrow) | |
doInput(774, 7, Key.LeftArrow) | |
doInput(856, 11, Key.RightArrow) | |
doInput(878, 78, Key.LeftArrow) | |
doInput(1103, 11, Key.Escape) | |
doInput(1218, 8, Key.Escape) | |
doInput(1304, 21, Key.Escape) | |
doInput(1393, 39, Key.Escape) | |
doInput(1475, 19, Key.Escape) | |
doInput(1556, 12, Key.Escape) | |
doInput(1012, 586, Key.RightArrow) | |
doInput(1964, 4, Key.RightArrow) | |
doInput(2078, 4, Key.RightArrow) | |
doInput(2382, 30, Key.LeftArrow) | |
doInput(2472, 30, Key.RightArrow) | |
def doTas2(): | |
t = getFrameCount() | |
doInput(35, 26, Key.Escape) | |
doInput(0, 73, Key.RightArrow) | |
doInput(75, 26, Key.LeftArrow) | |
if starting: | |
start = getTime() | |
print_last = 0 | |
freeTrack.update += update | |
cur_tas = 0 | |
input_start = False | |
input_right = False | |
input_left = False | |
input_jump = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment