@@ -1722,6 +1722,8 @@ class Button(object):
17221722 in /include/uapi/linux/input.h for details.
17231723 """
17241724
1725+ #~autogen
1726+
17251727 KEY_MAX = 0x2FF
17261728 KEY_BUF_LEN = int ((KEY_MAX + 7 ) / 8 )
17271729 EVIOCGKEY = (2 << (14 + 8 + 8 ) | KEY_BUF_LEN << (8 + 8 ) | ord ('E' ) << 8 | 0x18 )
@@ -1750,7 +1752,8 @@ def read_buttons(self):
17501752 for b in self .buffer_cache :
17511753 fcntl .ioctl (self .filehandle_cache [b ], self .EVIOCGKEY , self .buffer_cache [b ])
17521754
1753- def check_buttons (self ):
1755+ @property
1756+ def buttons_pressed (self ):
17541757 pressed = []
17551758 self .read_buttons ()
17561759 for k ,v in self ._buttons .items ():
@@ -1762,24 +1765,19 @@ def check_buttons(self):
17621765
17631766 @property
17641767 def any (self ):
1765- return bool (len ( self .check_buttons ()) != 0 )
1768+ return bool (self .buttons_pressed )
17661769
1767- @property
1768- def which (self ):
1769- return self .check_buttons ()
1770-
1771- def these (self ,buttons = {}):
1770+ def check_buttons (self ,buttons = []):
17721771 if len (buttons ) == 0 :
17731772 return False
1774- s = self .check_buttons ()
1773+ s = self .buttons_pressed
17751774 if len (s ) == 0 :
17761775 return False
17771776 for b in buttons :
17781777 if b not in s :
17791778 return False
17801779 return True
17811780
1782- #~autogen
17831781 if current_platform () == 'ev3' :
17841782#~autogen button-property platforms.ev3.button>currentClass
17851783 _buttons = {
@@ -1793,27 +1791,27 @@ def these(self,buttons={}):
17931791
17941792 @property
17951793 def up (self ):
1796- return 'up' in self .check_buttons ()
1794+ return 'up' in self .buttons_pressed
17971795
17981796 @property
17991797 def down (self ):
1800- return 'down' in self .check_buttons ()
1798+ return 'down' in self .buttons_pressed
18011799
18021800 @property
18031801 def left (self ):
1804- return 'left' in self .check_buttons ()
1802+ return 'left' in self .buttons_pressed
18051803
18061804 @property
18071805 def right (self ):
1808- return 'right' in self .check_buttons ()
1806+ return 'right' in self .buttons_pressed
18091807
18101808 @property
18111809 def enter (self ):
1812- return 'enter' in self .check_buttons ()
1810+ return 'enter' in self .buttons_pressed
18131811
18141812 @property
18151813 def backspace (self ):
1816- return 'backspace' in self .check_buttons ()
1814+ return 'backspace' in self .buttons_pressed
18171815
18181816
18191817#~autogen
0 commit comments