Add key_up and key_down methods in GameIO
Add key_up() and key_down() methods in GameIO. key_press() does the aforementioned two functions one after the other.
This commit is contained in:
parent
1a1e8efef8
commit
d04a0b172c
28
gameio.py
28
gameio.py
|
@ -25,10 +25,22 @@ class AbstractGameIO(ABC):
|
|||
"""Creates a screenshot, and returns it in Pillow format."""
|
||||
pass
|
||||
|
||||
# TODO: Implement the following two functions in descendants.
|
||||
|
||||
@abstractmethod
|
||||
def key_up(self, key: str):
|
||||
"""Holds a key on a virtual keyboard."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def key_up(self, key: str):
|
||||
"""Lets go of a key on a virtual keyboard."""
|
||||
pass
|
||||
|
||||
def send_key(self, key: str):
|
||||
"""Presses a key on a virtual keyboard."""
|
||||
pass
|
||||
self.key_up(key)
|
||||
self.key_down(key)
|
||||
|
||||
|
||||
class WindowsGameIO(AbstractGameIO):
|
||||
|
@ -39,8 +51,11 @@ class WindowsGameIO(AbstractGameIO):
|
|||
def fetch_sshot(self):
|
||||
return self.d.screenshot() # TODO: Cut this to self.loc(x, y, w, h)
|
||||
|
||||
def send_key(self, key: str):
|
||||
pass # TODO: Add send_key method
|
||||
def key_up(self, key: str):
|
||||
pass
|
||||
|
||||
def key_up(self, key: str):
|
||||
pass
|
||||
|
||||
|
||||
class LinuxGameIO(AbstractGameIO):
|
||||
|
@ -52,5 +67,8 @@ class LinuxGameIO(AbstractGameIO):
|
|||
def fetch_sshot(self):
|
||||
return pyautogui.screenshot(region=self.loc)
|
||||
|
||||
def send_key(self, key: str):
|
||||
pass # TODO: Add send_key method
|
||||
def key_up(self, key: str):
|
||||
pass
|
||||
|
||||
def key_up(self, key: str):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue