fix: use ppab device instead of subprocess, need refactoring

This commit is contained in:
Laureηt 2022-03-23 21:03:44 +01:00
parent 75dc12eb49
commit f6daad73c9
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
3 changed files with 14 additions and 14 deletions

View file

@ -1,10 +1,11 @@
import itertools
import logging
from subprocess import call
from time import sleep
import numpy as np
import init
CENTER = (1000, 500)
STICKER_MENU_BTN = (220, 60)
@ -47,12 +48,11 @@ old_team = None
def tap(pos):
call(["adb", "shell", "input", "tap", str(pos[0]), str(pos[1])])
# device.shell(f"input tap {pos[0]} {pos[1]}")
init.device.shell(f"input tap {pos[0]} {pos[1]}")
def motion(pos, type):
call(["adb", "shell", "input", "motionevent", type, str(pos[0]), str(pos[1])])
init.device.shell(f"input motionevent {type} {pos[0]} {pos[1]}")
def selectColor(team: int, primary_color: float, secondary_color: float):

View file

@ -20,6 +20,7 @@ def connect_adb():
logging.debug(f"devices detected: {devices_names}")
global device
if len(devices) == 1:
device = devices[0]
elif len(devices) == 0:
@ -31,8 +32,6 @@ def connect_adb():
logging.debug(f"device selected: {device.serial}")
return device
def get_users(device):
device_users = device.shell("pm list users")

View file

@ -1,6 +1,7 @@
import logging
from time import sleep
import init
from database import connect_to_database, insert_into_database, take_screenshot
from garage import generate_loadouts, newCar, rotate
from init import (
@ -22,18 +23,18 @@ logging.getLogger("PIL.PngImagePlugin").setLevel(logging.ERROR)
if __name__ == "__main__":
device = connect_adb()
users = get_users(device)
users = detect_game(device, users)
start_game(device, users)
set_notifications(device, False)
connect_adb()
users = get_users(init.device)
users = detect_game(init.device, users)
start_game(init.device, users)
set_notifications(init.device, False)
database = connect_to_database("dataset.db")
loadouts = generate_loadouts()
NB_ROTATIONS = 20
while detect_focus(device):
while detect_focus(init.device):
for (i, loadout) in enumerate(loadouts):
((model, sticker), wheel, hat, team, primary_color, secondary_color) = loadout
@ -43,9 +44,9 @@ if __name__ == "__main__":
sleep(0.5)
for x_rotation in range(NB_ROTATIONS):
rotate(130, 0)
uuid = take_screenshot(device)
uuid = take_screenshot(init.device)
insert_into_database(database, uuid, loadout, x_rotation, 0)
set_notifications(device, True)
set_notifications(init.device, True)
database.close()