2004-05-30 11:09:46 +00:00
|
|
|
# $Id$
|
2004-05-24 07:49:50 +00:00
|
|
|
# Documentation for SCA_KeyboardSensor
|
|
|
|
from SCA_ISensor import *
|
|
|
|
|
|
|
|
class SCA_KeyboardSensor(SCA_ISensor):
|
|
|
|
"""
|
|
|
|
A keyboard sensor detects player key presses.
|
|
|
|
|
2004-06-26 09:15:41 +00:00
|
|
|
See module L{GameKeys} for keycode values.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
@ivar key: The key code this sensor is looking for.
|
|
|
|
@type key: keycode from L{GameKeys} module
|
|
|
|
@ivar hold1: The key code for the first modifier this sensor is looking for.
|
|
|
|
@type hold1: keycode from L{GameKeys} module
|
|
|
|
@ivar hold2: The key code for the second modifier this sensor is looking for.
|
|
|
|
@type hold2: keycode from L{GameKeys} module
|
|
|
|
@ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
|
|
|
|
@type toggleProperty: string
|
|
|
|
@ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
|
|
|
|
@type targetProperty: string
|
|
|
|
@ivar useAllKeys: Flag to determine whether or not to accept all keys.
|
|
|
|
@type useAllKeys: boolean
|
2009-04-20 15:06:46 +00:00
|
|
|
@ivar events: a list of pressed keys that have either been pressed, or just released, or are active this frame. (read only).
|
|
|
|
|
|
|
|
- 'keycode' matches the values in L{GameKeys}.
|
|
|
|
- 'status' uses...
|
|
|
|
- L{GameLogic.KX_INPUT_NONE}
|
|
|
|
- L{GameLogic.KX_INPUT_JUST_ACTIVATED}
|
|
|
|
- L{GameLogic.KX_INPUT_ACTIVE}
|
|
|
|
- L{GameLogic.KX_INPUT_JUST_RELEASED}
|
|
|
|
|
|
|
|
@type events: list [[keycode, status], ...]
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
def getKeyStatus(keycode):
|
|
|
|
"""
|
|
|
|
Get the status of a key.
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
@rtype: key state L{GameLogic} members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
|
2009-01-26 08:34:40 +00:00
|
|
|
@return: The state of the given key
|
|
|
|
@type keycode: integer
|
|
|
|
@param keycode: The code that represents the key you want to get the state of
|
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
#--The following methods are DEPRECATED--
|
2004-05-24 07:49:50 +00:00
|
|
|
def getKey():
|
|
|
|
"""
|
|
|
|
Returns the key code this sensor is looking for.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use the "key" property instead}.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
@rtype: keycode from L{GameKeys} module
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def setKey(keycode):
|
|
|
|
"""
|
|
|
|
Set the key this sensor should listen for.
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use the "key" property instead}.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2004-06-26 09:15:41 +00:00
|
|
|
@type keycode: keycode from L{GameKeys} module
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def getHold1():
|
|
|
|
"""
|
|
|
|
Returns the key code for the first modifier this sensor is looking for.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use the "hold1" property instead}.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
@rtype: keycode from L{GameKeys} module
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
2009-01-26 08:34:40 +00:00
|
|
|
def setHold1(keycode):
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
Sets the key code for the first modifier this sensor should look for.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use the "hold1" property instead}.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
@type keycode: keycode from L{GameKeys} module
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def getHold2():
|
|
|
|
"""
|
|
|
|
Returns the key code for the second modifier this sensor is looking for.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use the "hold2" property instead}.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
@rtype: keycode from L{GameKeys} module
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
2009-01-26 08:34:40 +00:00
|
|
|
def setHold2(keycode):
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
Sets the key code for the second modifier this sensor should look for.
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use the "hold2" property instead.}
|
2009-01-26 08:34:40 +00:00
|
|
|
|
|
|
|
@type keycode: keycode from L{GameKeys} module
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def getPressedKeys():
|
|
|
|
"""
|
|
|
|
Get a list of keys that have either been pressed, or just released this frame.
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use "events" instead.}
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2004-05-24 07:49:50 +00:00
|
|
|
@rtype: list of key status. [[keycode, status]]
|
|
|
|
"""
|
|
|
|
|
|
|
|
def getCurrentlyPressedKeys():
|
|
|
|
"""
|
|
|
|
Get a list of currently pressed keys that have either been pressed, or just released
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
B{DEPRECATED: Use "events" instead.}
|
2009-01-26 08:34:40 +00:00
|
|
|
|
2004-05-24 07:49:50 +00:00
|
|
|
@rtype: list of key status. [[keycode, status]]
|
2009-01-26 08:34:40 +00:00
|
|
|
"""
|