Skip to content

Commit

Permalink
Merge pull request LmeSzinc#429 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Apr 21, 2024
2 parents 2e7c39d + ef7214c commit 42a5fdd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
Binary file modified bin/MaaTouch/maatouch
Binary file not shown.
2 changes: 1 addition & 1 deletion module/device/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def list_known_packages(self, show_log=True):
list[str]: List of package names
"""
packages = self.list_package(show_log=show_log)
packages = [p for p in packages if p in server_.VALID_PACKAGE]
packages = [p for p in packages if p in server_.VALID_PACKAGE or p in server_.VALID_CLOUD_PACKAGE]
return packages

def detect_package(self, set_config=True):
Expand Down
10 changes: 10 additions & 0 deletions module/device/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ def release_during_wait(self):
if self.config.Emulator_ScreenshotMethod == 'nemu_ipc':
self.nemu_ipc_release()

def get_orientation(self):
"""
Callbacks when orientation changed.
"""
o = super().get_orientation()

self.on_orientation_change_maatouch()

return o

def stuck_record_add(self, button):
self.detect_record.add(str(button))

Expand Down
31 changes: 30 additions & 1 deletion module/device/method/maatouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ class MaaTouch(Connection):
"""
max_x: int
max_y: int
_maatouch_stream = socket.socket
_maatouch_stream: socket.socket = None
_maatouch_stream_storage = None
_maatouch_init_thread = None
_maatouch_orientation: int = None

@cached_property
@retry
Expand Down Expand Up @@ -137,12 +138,40 @@ def early_maatouch_init_func():
self._maatouch_init_thread = thread
thread.start()

def on_orientation_change_maatouch(self):
"""
MaaTouch caches devices orientation at its startup
A restart is required when orientation changed
"""
if self._maatouch_orientation is None:
return
if self.orientation == self._maatouch_orientation:
return

logger.info(f'Orientation changed {self._maatouch_orientation} => {self.orientation}, re-init MaaTouch')
del_cached_property(self, '_maatouch_builder')
self.early_maatouch_init()

def maatouch_init(self):
logger.hr('MaaTouch init')
max_x, max_y = 1280, 720
max_contacts = 2
max_pressure = 50

# Try to close existing stream
if self._maatouch_stream is not None:
try:
self._maatouch_stream.close()
except Exception as e:
logger.error(e)
del self._maatouch_stream
if self._maatouch_stream_storage is not None:
del self._maatouch_stream_storage

# MaaTouch caches devices orientation at its startup
super(MaaTouch, self).get_orientation()
self._maatouch_orientation = self.orientation

# CLASSPATH=/data/local/tmp/maatouch app_process / com.shxyke.MaaTouch.App
stream = self.adb_shell(
['CLASSPATH=/data/local/tmp/maatouch', 'app_process', '/', 'com.shxyke.MaaTouch.App'],
Expand Down
11 changes: 10 additions & 1 deletion module/device/method/minitouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def init():

class Minitouch(Connection):
_minitouch_port: int = 0
_minitouch_client: socket.socket
_minitouch_client: socket.socket = None
_minitouch_pid: int
_minitouch_ws: websockets.WebSocketClientProtocol
max_x: int
Expand Down Expand Up @@ -409,6 +409,15 @@ def minitouch_init(self):
max_x, max_y = 1280, 720
max_contacts = 2
max_pressure = 50

# Try to close existing stream
if self._minitouch_client is not None:
try:
self._minitouch_client.close()
except Exception as e:
logger.error(e)
del self._minitouch_client

self.get_orientation()

self._minitouch_port = self.adb_forward("localabstract:minitouch")
Expand Down
5 changes: 5 additions & 0 deletions tasks/rogue/route/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ def _position_match_special(
'Combat_Herta_SupplyZone_F2_X45Y369',
] and similarity > 0.20:
return True
# Before Occurrence_Luofu_DivinationCommission_F2_X425Y791
if route.name in [
'Occurrence_Jarilo_RivetTown_F1_X157Y435',
] and similarity > 0.15:
return True
if route.name in [
'Combat_Herta_StorageZone_F1_X273Y92',
'Occurrence_Herta_StorageZone_F1_X273Y93',
Expand Down

0 comments on commit 42a5fdd

Please sign in to comment.