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 itertools
import logging import logging
from subprocess import call
from time import sleep from time import sleep
import numpy as np import numpy as np
import init
CENTER = (1000, 500) CENTER = (1000, 500)
STICKER_MENU_BTN = (220, 60) STICKER_MENU_BTN = (220, 60)
@ -47,12 +48,11 @@ old_team = None
def tap(pos): def tap(pos):
call(["adb", "shell", "input", "tap", str(pos[0]), str(pos[1])]) init.device.shell(f"input tap {pos[0]} {pos[1]}")
# device.shell(f"input tap {pos[0]} {pos[1]}")
def motion(pos, type): 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): 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}") logging.debug(f"devices detected: {devices_names}")
global device
if len(devices) == 1: if len(devices) == 1:
device = devices[0] device = devices[0]
elif len(devices) == 0: elif len(devices) == 0:
@ -31,8 +32,6 @@ def connect_adb():
logging.debug(f"device selected: {device.serial}") logging.debug(f"device selected: {device.serial}")
return device
def get_users(device): def get_users(device):
device_users = device.shell("pm list users") device_users = device.shell("pm list users")

View file

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