Skip to content

Commit

Permalink
Added source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gloryness committed Sep 22, 2023
1 parent 80ac120 commit 582307a
Show file tree
Hide file tree
Showing 103 changed files with 828 additions and 0 deletions.
672 changes: 672 additions & 0 deletions joystick-movement.py

Large diffs are not rendered by default.

Binary file added templates/00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/24.png
Binary file added templates/25.png
Binary file added templates/26.png
Binary file added templates/27.png
Binary file added templates/28.png
Binary file added templates/29.png
Binary file added templates/30.png
Binary file added templates/31.png
Binary file added templates/32.png
Binary file added templates/33.png
Binary file added templates/34.png
Binary file added templates/35.png
Binary file added templates/36.png
Binary file added templates/37.png
Binary file added templates/38.png
Binary file added templates/39.png
Binary file added templates/40.png
Binary file added templates/41.png
Binary file added templates/42.png
Binary file added templates/43.png
Binary file added templates/44.png
Binary file added templates/45.png
Binary file added templates/46.png
Binary file added templates/47.png
Binary file added templates/48.png
Binary file added templates/49.png
Binary file added templates/50.png
Binary file added templates/51.png
Binary file added templates/52.png
Binary file added templates/53.png
Binary file added templates/54.png
Binary file added templates/55.png
Binary file added templates/56.png
Binary file added templates/57.png
Binary file added templates/58.png
Binary file added templates/59.png
Binary file added templates/60.png
Binary file added templates/61.png
Binary file added templates/62.png
Binary file added templates/63.png
Binary file added templates/64.png
Binary file added templates/65.png
Binary file added templates/66.png
Binary file added templates/67.png
Binary file added templates/68.png
Binary file added templates/69.png
Binary file added templates/70.png
Binary file added templates/71.png
Binary file added templates/72.png
Binary file added templates/73.png
Binary file added templates/74.png
Binary file added templates/75.png
Binary file added templates/76.png
Binary file added templates/77.png
Binary file added templates/78.png
Binary file added templates/79.png
Binary file added templates/80.png
Binary file added templates/81.png
Binary file added templates/82.png
Binary file added templates/83.png
Binary file added templates/84.png
Binary file added templates/85.png
Binary file added templates/86.png
Binary file added templates/87.png
Binary file added templates/88.png
Binary file added templates/89.png
Binary file added templates/90.png
Binary file added templates/91.png
Binary file added templates/92.png
Binary file added templates/93.png
Binary file added templates/94.png
Binary file added templates/95.png
Binary file added templates/96.png
Binary file added templates/97.png
Binary file added templates/98.png
Binary file added templates/99.png
156 changes: 156 additions & 0 deletions throttle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import cv2 as cv
import numpy as np
from mss import mss

sct = mss()

templates = []
for i in range(0, 101):
templates.append(cv.imread(f'templates/{i:02}.png')[:, :, 0])

def get_current_throttle():
sct_img = sct.grab((898, 89, 987, 102))
npimg = np.array(sct_img)[:, :, 0]
thresh = cv.adaptiveThreshold(npimg, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY, 9, -40)
thresh[:, :30] = 0
thresh[:, 61:] = 0

results = [np.count_nonzero(cv.bitwise_xor(thresh, template)) for template in templates]

return results.index(min(results))

throttle_precision = {
1: 0.0375,
2: 0.0610,
3: 0.1030,
4: 0.1350,
5: 0.1640,
6: 0.1880,
7: 0.2220,
8: 0.2620,
9: 0.29475,
10: 0.3245,
11: 0.371,
12: 0.404,
13: 0.430,
14: 0.462,
15: 0.4961070,
16: 0.543,
17: 0.575,
18: 0.596,
19: 0.613,
20: 0.660,
21: 0.690,
22: 0.720,
23: 0.762,
24: 0.798,
25: 0.8225,
26: 0.854,
27: 0.895,
28: 0.930,
29: 0.9625,
30: 0.995,
31: 1.020,
32: 1.062,
33: 1.096,
34: 1.125,
35: 1.162,
36: 1.19525,
37: 1.215,
38: 1.252,
39: 1.294,
40: 1.328,
41: 1.364,
42: 1.396,
43: 1.4275,
44: 1.462,
45: 1.4925,
46: 1.526,
47: 1.558,
48: 1.596,
49: 1.628,
50: 1.66311,
51: 1.700,
52: 1.731,
53: 1.752,
54: 1.794,
55: 1.828,
56: 1.862,
57: 1.894,
58: 1.926,
59: 1.960,
60: 1.985,
61: 2.029,
62: 2.062,
63: 2.095,
64: 2.119,
65: 2.156,
66: 2.196,
67: 2.228,
68: 2.252,
69: 2.294,
70: 2.328,
71: 2.362,
72: 2.386,
73: 2.426,
74: 2.462,
75: 2.496,
76: 2.529,
77: 2.562,
78: 2.590,
79: 2.617,
80: 2.664,
81: 2.6875,
82: 2.728,
83: 2.755,
84: 2.795,
85: 2.820,
86: 2.867,
87: 2.900,
88: 2.929,
89: 2.962,
90: 2.995,
91: 3.029,
92: 3.055,
93: 3.101,
94: 3.120,
95: 3.158,
96: 3.190,
97: 3.229,
98: 3.252,
99: 3.296,
100: 3.335
}

import pydirectinput
import threading
import time

event = threading.Event()
current = 0

def increase_throttle(value):
duration = throttle_precision[value]
while not event.is_set():
pydirectinput.keyDown("w", _pause=False)
event.wait(duration)
break

pydirectinput.keyUp("w", _pause=False)
print("All done!")
# perform any cleanup here
event.clear()
time.sleep(0.1)
print(f"Current Throttle: {get_current_throttle()}%")

def interrupt_throttle():
import time
time.sleep(throttle_precision[10])
event.set()

if __name__ == '__main__':
time.sleep(1.5)

thread = threading.Thread(target=interrupt_throttle)
thread.start()
increase_throttle(10)

0 comments on commit 582307a

Please sign in to comment.