Back to index

freevial  1.2
Public Member Functions | Public Attributes | Private Member Functions
common.events.EventHandle Class Reference

List of all members.

Public Member Functions

def __init__
def isKey
def isUp
def isDown
def isClick
def isRelease
def keyUp
def keyDown
def isWindowMinimize
def isWindowRestore
def isWindowFocusLose
def isWindowFocusGain
def isQuit
def str
def base_actions

Public Attributes

 event
 handled

Private Member Functions

def _convert_joystick_event
def _getKey
def _isKeyEvent
def _isStateEvent
def _hasKey

Detailed Description

Definition at line 39 of file events.py.


Constructor & Destructor Documentation

def common.events.EventHandle.__init__ (   self,
  event,
  do_base_actions = True 
)

Definition at line 44 of file events.py.

00044 
00045        def __init__( self, event, do_base_actions = True ):
00046               
00047               if event.type == pygame.JOYBUTTONDOWN:
00048                      event = self._convert_joystick_event()
00049               
00050               self.event = event
00051               self.handled = False
00052               
00053               if do_base_actions and self.base_actions():
00054                      self.handled = True
00055        
       

Here is the call graph for this function:


Member Function Documentation

Definition at line 56 of file events.py.

00056 
00057        def _convert_joystick_event( self ):
00058               
00059               # Aliases for PS2 remotes
00060               joystick_aliases = {
00061                      0: K_RETURN,
00062                      1: K_ESCAPE,
00063                      2: K_RETURN,
00064                      3: K_s,
00065                      4: K_F2,
00066                      5: K_a,
00067                      6: K_F1,
00068                      7: K_F3,      
00069                      8: K_SPACE,
00070                      9: K_ESCAPE,
00071                      12: K_UP,
00072                      13: K_RIGHT,
00073                      14: K_DOWN,
00074                      15: K_LEFT,
00075               }
00076        
00077               if joystick_aliases.get( event.button ):
00078                      return pygame.event.Event( pygame.KEYUP, { 'key': joystick_aliases[ event.button ], 'unicode': u's', 'mod': 0 } )
00079        
       

Here is the caller graph for this function:

def common.events.EventHandle._getKey (   self,
  key 
) [private]

Definition at line 80 of file events.py.

00080 
00081        def _getKey( self, key ):
00082               
00083               if type(key) is str:
00084                      
00085                      if key[:2] != 'K_':
00086                             key = 'K_' + key
00087                      
00088                      key = getattr(pygame, key)
00089               
00090               return key
00091        
       

Here is the caller graph for this function:

def common.events.EventHandle._hasKey (   self,
  keynames 
) [private]

Definition at line 102 of file events.py.

00102 
00103        def _hasKey( self, keynames ):
00104               
00105               if not self._isKeyEvent():
00106                      return False
00107               
00108               if len(keynames) == 1 and type(keynames[0]) is tuple:
00109                      keynames = keynames[0]
00110               
00111               for key in keynames:
00112                      
00113                      if self.event.key == self._getKey(key):
00114                             return True
00115               
00116               return False
00117        
       

Here is the call graph for this function:

Here is the caller graph for this function:

def common.events.EventHandle._isKeyEvent (   self) [private]

Definition at line 92 of file events.py.

00092 
00093        def _isKeyEvent( self ):
00094               
00095               return True if hasattr(self.event, 'key') else False
00096        
       

Here is the caller graph for this function:

def common.events.EventHandle._isStateEvent (   self) [private]

Definition at line 97 of file events.py.

00097 
00098        def _isStateEvent( self ):
00099               
00100               return True if hasattr(self.event, 'state') else False
00101        
       

Here is the caller graph for this function:

Definition at line 214 of file events.py.

00214 
00215        def base_actions( self ):
00216               
00217               if self.isQuit():
00218                      sys.exit()
00219               
00220               elif self.keyDown('PRINT'):
00221                      screenshot(pygame.display.get_surface())
00222                      return True
00223               
00224               elif self.isWindowFocusLose() or self.isWindowFocusGain():
00225                      # Those aren't interesting, skip them.
00226                      # We could also do some CPU saving here, but this would produce
00227                      # bad synchronization between the music and the images.
00228                      return True
00229               
00230               elif self.keyUp('F11'):
00231                      pygame.display.toggle_fullscreen()
00232                      return True
00233               
00234               elif self.isWindowMinimize():
00235                      pauseGameUntilRestore()
00236                      return True
00237               
00238               else:
00239                      return False
00240 

Here is the call graph for this function:

def common.events.EventHandle.isClick (   self,
  request = 0 
)

Definition at line 133 of file events.py.

00133 
00134        def isClick( self, request = 0 ):
00135               
00136               if type(request) is not int:
00137                      request = mouseButtons[ request ]
00138               
00139               return True if self.event.type == pygame.MOUSEBUTTONDOWN and (self.event.button == request or request == 0) else False
00140        
       

Definition at line 128 of file events.py.

00128 
00129        def isDown( self ):
00130               
00131               return True if self.event.type == pygame.KEYDOWN else False
00132        
       

Here is the caller graph for this function:

def common.events.EventHandle.isKey (   self,
  keynames 
)

Definition at line 118 of file events.py.

00118 
00119        def isKey( self, *keynames ):
00120               
00121               return True if self._hasKey(keynames) else False
00122        
       

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 198 of file events.py.

00198 
00199        def isQuit( self ):
00200               
00201               if self.event.type == pygame.QUIT:
00202                      return True
00203               
00204               return False
00205        
       

Here is the caller graph for this function:

def common.events.EventHandle.isRelease (   self,
  request = 0 
)

Definition at line 141 of file events.py.

00141 
00142        def isRelease( self, request = 0 ):
00143               
00144               if type(request) is not int:
00145                      request = mouseButtons[ request ]
00146               
00147               return True if self.event.type == pygame.MOUSEBUTTONUP and (self.event.button == request or request == 0) else False
00148               
       

Definition at line 123 of file events.py.

00123 
00124        def isUp( self ):
00125               
00126               return True if self.event.type == pygame.KEYUP else False
00127        
       

Here is the caller graph for this function:

Definition at line 193 of file events.py.

00193 
00194        def isWindowFocusGain( self ):
00195               
00196               if self._isStateEvent() and self.event.state == 1 and self.event.gain == 1:
00197                      return True
       

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 186 of file events.py.

00186 
00187        def isWindowFocusLose( self ):
00188               
00189               if self._isStateEvent() and self.event.state == 1 and self.event.gain == 0:
00190                      return True
00191               
00192               return False
       

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 171 of file events.py.

00171 
00172        def isWindowMinimize( self ):
00173               
00174               if self._isStateEvent() and self.event.state == 6 and self.event.gain == 0:
00175                      return True
00176               
00177               return False
00178        
       

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 179 of file events.py.

00179 
00180        def isWindowRestore( self ):
00181               
00182               if self._isStateEvent() and self.event.state == 4 and self.event.gain == 1:
00183                      return True
00184               
00185               return False
       

Here is the call graph for this function:

def common.events.EventHandle.keyDown (   self,
  keynames 
)

Definition at line 160 of file events.py.

00160 
00161        def keyDown( self, *keynames ):
00162               
00163               if not self.isDown():
00164                      return False
00165               
00166               if len(keynames) == 0:
00167                      return True
00168               
00169               return self.isKey(keynames)
00170        
       

Here is the call graph for this function:

Here is the caller graph for this function:

def common.events.EventHandle.keyUp (   self,
  keynames 
)

Definition at line 149 of file events.py.

00149 
00150        def keyUp( self, *keynames ):
00151               
00152               if not self.isUp():
00153                      return False
00154               
00155               if len(keynames) == 0:
00156                      return True
00157               
00158               return self.isKey(*keynames)
00159        
       

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 206 of file events.py.

00206 
00207        def str( self ):
00208               
00209               if not self._isKeyEvent():
00210                      return ''
00211               
00212               return printKey(self.event.key)
00213        
       

Here is the call graph for this function:


Member Data Documentation

Definition at line 49 of file events.py.

Definition at line 50 of file events.py.


The documentation for this class was generated from the following file: