Module igeCore.input.touch
indi game engine - touch input
Expand source code
"""
indi game engine - touch input
"""
import igeCore as core
import igeVmath as vmath
try:
from igeScene import SceneManager
except:
print("igeScene not installed")
class Touch:
'''
Class Touch
'''
@staticmethod
def getPosition(fingerIndex):
"""
Get a finger position by the index of the finger.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
[x (int), y (int)] : Position
"""
x, y = core.getFingerPosition(fingerIndex)
if SceneManager is not None:
scene = SceneManager.getInstance().currentScene
if scene is not None:
delta = (scene.getViewSize() - scene.getScreenSize()) * 0.5
x = x - delta.x
y = y + delta.y
return [x, y]
@staticmethod
def isPressed(fingerIndex):
"""
Check if a finger has pressed.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
True: If the finger has pressed
False: If the finger has not pressed
"""
return core.isFingerPressed(fingerIndex)
@staticmethod
def isMoved(fingerIndex):
"""
Check if a finger has moved.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
True: If the finger has moved
False: If the finger has not moved
"""
return core.isFingerMoved(fingerIndex)
@staticmethod
def isReleased(fingerIndex):
"""
Check if a finger has released.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
True: If the finger has released
False: If the finger has not released
"""
return core.isFingerReleased(fingerIndex)
@staticmethod
def isScrolled(fingerIndex):
"""
Check if a mouse has scrolled.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
True: If the mouse has scrolled
False: If the mouse has not scrolled
"""
return core.isFingerScrolled(fingerIndex)
@staticmethod
def getScrollData(fingerIndex):
"""
Get scrolling data if mouse has scrolled.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
scrollValue (float)
"""
return core.getFingerScrolledData(fingerIndex)
@staticmethod
def getPressure(fingerIndex):
"""
Get the pressure value from a finger.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
pressureValue (int)
"""
return core.getFingerPressure(fingerIndex)
@staticmethod
def getId(fingerIndex):
"""
Get the finger unique id from finger index.
This is useful for multiple touch application when user need to check the source of an event.
Parameters
----------
fingerIndex (int): The finger index to check
Returns
-------
fingerId (int)
"""
return core.getFingerId(fingerIndex)
@staticmethod
def count():
"""
Get the total number of active fingers on screen.
Returns
-------
numberOfFingers (int)
"""
return core.getFingersCount()
Classes
class Touch-
Class Touch
Expand source code
class Touch: ''' Class Touch ''' @staticmethod def getPosition(fingerIndex): """ Get a finger position by the index of the finger. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- [x (int), y (int)] : Position """ x, y = core.getFingerPosition(fingerIndex) if SceneManager is not None: scene = SceneManager.getInstance().currentScene if scene is not None: delta = (scene.getViewSize() - scene.getScreenSize()) * 0.5 x = x - delta.x y = y + delta.y return [x, y] @staticmethod def isPressed(fingerIndex): """ Check if a finger has pressed. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the finger has pressed False: If the finger has not pressed """ return core.isFingerPressed(fingerIndex) @staticmethod def isMoved(fingerIndex): """ Check if a finger has moved. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the finger has moved False: If the finger has not moved """ return core.isFingerMoved(fingerIndex) @staticmethod def isReleased(fingerIndex): """ Check if a finger has released. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the finger has released False: If the finger has not released """ return core.isFingerReleased(fingerIndex) @staticmethod def isScrolled(fingerIndex): """ Check if a mouse has scrolled. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the mouse has scrolled False: If the mouse has not scrolled """ return core.isFingerScrolled(fingerIndex) @staticmethod def getScrollData(fingerIndex): """ Get scrolling data if mouse has scrolled. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- scrollValue (float) """ return core.getFingerScrolledData(fingerIndex) @staticmethod def getPressure(fingerIndex): """ Get the pressure value from a finger. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- pressureValue (int) """ return core.getFingerPressure(fingerIndex) @staticmethod def getId(fingerIndex): """ Get the finger unique id from finger index. This is useful for multiple touch application when user need to check the source of an event. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- fingerId (int) """ return core.getFingerId(fingerIndex) @staticmethod def count(): """ Get the total number of active fingers on screen. Returns ------- numberOfFingers (int) """ return core.getFingersCount()Static methods
def count()-
Get the total number of active fingers on screen.
Returns
numberOfFingers (int)Expand source code
@staticmethod def count(): """ Get the total number of active fingers on screen. Returns ------- numberOfFingers (int) """ return core.getFingersCount() def getId(fingerIndex)-
Get the finger unique id from finger index. This is useful for multiple touch application when user need to check the source of an event.
Parameters
fingerIndex (int): The finger index to checkReturns
fingerId (int)Expand source code
@staticmethod def getId(fingerIndex): """ Get the finger unique id from finger index. This is useful for multiple touch application when user need to check the source of an event. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- fingerId (int) """ return core.getFingerId(fingerIndex) def getPosition(fingerIndex)-
Get a finger position by the index of the finger.
Parameters
fingerIndex (int): The finger index to checkReturns
[x (int), y (int)] : PositionExpand source code
@staticmethod def getPosition(fingerIndex): """ Get a finger position by the index of the finger. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- [x (int), y (int)] : Position """ x, y = core.getFingerPosition(fingerIndex) if SceneManager is not None: scene = SceneManager.getInstance().currentScene if scene is not None: delta = (scene.getViewSize() - scene.getScreenSize()) * 0.5 x = x - delta.x y = y + delta.y return [x, y] def getPressure(fingerIndex)-
Get the pressure value from a finger.
Parameters
fingerIndex (int): The finger index to checkReturns
pressureValue (int)Expand source code
@staticmethod def getPressure(fingerIndex): """ Get the pressure value from a finger. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- pressureValue (int) """ return core.getFingerPressure(fingerIndex) def getScrollData(fingerIndex)-
Get scrolling data if mouse has scrolled.
Parameters
fingerIndex (int): The finger index to checkReturns
scrollValue (float)Expand source code
@staticmethod def getScrollData(fingerIndex): """ Get scrolling data if mouse has scrolled. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- scrollValue (float) """ return core.getFingerScrolledData(fingerIndex) def isMoved(fingerIndex)-
Check if a finger has moved.
Parameters
fingerIndex (int): The finger index to checkReturns
True: If the finger has moved False: If the finger has not movedExpand source code
@staticmethod def isMoved(fingerIndex): """ Check if a finger has moved. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the finger has moved False: If the finger has not moved """ return core.isFingerMoved(fingerIndex) def isPressed(fingerIndex)-
Check if a finger has pressed.
Parameters
fingerIndex (int): The finger index to checkReturns
True: If the finger has pressed False: If the finger has not pressedExpand source code
@staticmethod def isPressed(fingerIndex): """ Check if a finger has pressed. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the finger has pressed False: If the finger has not pressed """ return core.isFingerPressed(fingerIndex) def isReleased(fingerIndex)-
Check if a finger has released.
Parameters
fingerIndex (int): The finger index to checkReturns
True: If the finger has released False: If the finger has not releasedExpand source code
@staticmethod def isReleased(fingerIndex): """ Check if a finger has released. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the finger has released False: If the finger has not released """ return core.isFingerReleased(fingerIndex) def isScrolled(fingerIndex)-
Check if a mouse has scrolled.
Parameters
fingerIndex (int): The finger index to checkReturns
True: If the mouse has scrolled False: If the mouse has not scrolledExpand source code
@staticmethod def isScrolled(fingerIndex): """ Check if a mouse has scrolled. Parameters ---------- fingerIndex (int): The finger index to check Returns ------- True: If the mouse has scrolled False: If the mouse has not scrolled """ return core.isFingerScrolled(fingerIndex)