CAST II Game Engine |
||||||||
![]() |
MAIN | FEATURES | SCREENSHOTS | FORUMS | MANUAL | DOWNLOADS | CONTACTS | |
(C) 2006 George "Mirage" Bakhtadze. www.casteng.com
The source code may be used under either MPL 1.1 or LGPL 2.1 license. See included license.txt file
Unit contains basic input classes
| Name | Description |
|---|---|
Class TController | CAST II input controller base class |
CController = of TController; |
PBinding = ^TBinding; |
TBinding = record BindType: TEventType; BindData: Word; Next: PBinding; end; |
TBindingName = ShortString; |
TBindingStr = string; |
THotkey = type Longword; |
TInputDelegate = procedure(EventData: Integer; CustomData: SmallInt) of object; |
TInputEvent = packed record EventType: TEventType; EventData: SmallInt; end; |
TInputEvents = array of TInputEvent; |
TInputFilter = set of TInputFilterElement; |
TInputQueryResult = set of TInputQueryResultElement; |
TKeyModifiers = set of TKeyModifier; |
TMouseState = packed record lX, lY, lZ: LongInt; Buttons: array[0..3] of Byte; end; |
CController = of TController; |
PBinding = ^TBinding; |
Pointer to a binding
TBinding = record BindType: TEventType; BindData: Word; Next: PBinding; end; |
Binding contains an event type, event data and a pointer to next binding (or nil) to be able to bind a sequense of input events to a single action
TBindingName = ShortString; |
TBindingStr = string; |
Binding string type. Syntax:
BindElement = (<Key><Specifier>)|<Gesture>"^"
Key = A key name
Specifier = ","|"+"|"-"|":" - can be omitted at the end of the binding ("," will be assumed)
Gesture = "MouseMove"|"MouseMoveH"|"MouseMoveV"|"MouseRoll"| "MouseStrokeLeft"|"MouseStrokeRight"|"MouseStrokeUp"|"MouseStrokeDown"| "MouseStrokeLeftUp"|"MouseStrokeRightUp"|"MouseStrokeLeftDown"|"MouseStrokeRightDown" Binding = <BindElement> {<BindElement>}
Specifiers:
, - click
+ - key down
- - key up
: - double click
Examples:
Alt+Q - the binding will be activated when user press Alt, then click (press and release) Q (without releasing Alt)
A,B,C - the binding will be activated when user click A, then B and then C
A+B,A- - the binding will be activated when user press A, then press and release B and then release A
A maximum timeout between two consequent events can be specified when binding
THotkey = type Longword; |
Hotkey
TInputDelegate = procedure(EventData: Integer; CustomData: SmallInt) of object; |
Type of a method to which an input event sequence can be bound. CustomData is an optional user data. Value of EventData depends on type of event which finishes the sequence (the last one). If it's a keyboard event EventData contains a key code, if it's a mouse event EventData contains event-specific mouse coordinate or both (for btMouseMove event type) in format where low 16 bit is X coordinate and high 16 bit is Y coordinate.
TInputEvent = packed record EventType: TEventType; EventData: SmallInt; end; |
Input event. EventData is an event type-specific data such as a key code
TInputEvents = array of TInputEvent; |
TInputFilter = set of TInputFilterElement; |
Input filter
TInputQueryResult = set of TInputQueryResultElement; |
Query input results
TKeyModifiers = set of TKeyModifier; |
Modifier keys set
TMouseState = packed record lX, lY, lZ: LongInt; Buttons: array[0..3] of Byte; end; |
Mouse state data structure. lX, lY and lZ is mouse position at corresponding axis. Buttons - mouse buttons state
TEventType | ||
| Possible event types | ||
btKeyDown | Some key (including mouse buttons) was pushed down | |
btKeyUp | Some previously pressed key was released | |
btKeyClick | A key was clicked (btKeyDown + btKeyUp) | |
btKeyDblClick | A key was clicked two times within double click timeout | |
btMouseMove | Mouse was moved | |
btMouseHMove | Mouse was moved horizontally | |
btMouseVMove | Mouse was moved vertically | |
btMouseRoll | Mouse wheel was rolled | |
btStrokeLeft | Mouse was moved left at least by MouseStrokeTolerance units | |
btStrokeRight | Mouse was moved right at least by MouseStrokeTolerance units | |
btStrokeUp | Mouse was moved up at least by MouseStrokeTolerance units | |
btStrokeDown | Mouse was moved down at least by MouseStrokeTolerance units | |
btStrokeLeftUp | Mouse was moved left+up at least by MouseStrokeTolerance units | |
btStrokeRightUp | Mouse was moved right+up at least by MouseStrokeTolerance units | |
btStrokeLeftDown | Mouse was moved left+down at least by MouseStrokeTolerance units | |
btStrokeRightDown | Mouse was moved right+down at least by MouseStrokeTolerance units | |
btNone | No event | |
TInputFilterElement | ||
| Input event filters | ||
ifBound | Query only events which was bound using BindCommand, BindDelegate or BindPointer | |
ifNotBound | Query all events | |
TInputQueryResultElement | ||
| Query input results elements | ||
iqrKeyPressed | Some key (including mouse buttons) was pressed | |
iqrKeyChanged | Some key (including mouse buttons) state was changed | |
iqrMouseMoved | Mouse was moved | |
TKeyModifier | ||
| Modifier keys | ||
kmControl | Any CTRL | |
kmLControl | Left CTRL | |
kmRControl | Right CTRL | |
kmShift | Any Shift | |
kmLShift | Left Shift | |
kmRShift | Right Shift | |
kmAlt | Any Alt | |
kmLAlt | Left Alt | |
kmRAlt | Right Alt | |
kmLWin | Left Win | |
kmRWin | Right Win | |
kmWin | Any Win key | |
TKeyQueryState | ||
| Key query states | ||
kqsUp | Key is up | |
kqsDown | Key is down | |
atBooleanOff = 2; |
atBooleanOn = 1; |
atBooleanToggle = 3; |
atSetByte = 4; |
atSetLongWord = 6; |
atSetWord = 5; |
DefaultTimeout = 500; |
MaxEvents = 127; |
MouseStrokeTolerance = 3; |
atBooleanOff = 2; |
Reset a boolean flag
atBooleanOn = 1; |
Set a boolean flag
atBooleanToggle = 3; |
Toggle a boolean flag
atSetByte = 4; |
Set a byte value
atSetLongWord = 6; |
Set a long word (four byte) value
atSetWord = 5; |
Set a word (two byte) value
DefaultTimeout = 500; |
Default value of maximum timeout between two consequent events
MaxEvents = 127; |
Maximum simultaneous events
MouseStrokeTolerance = 3; |
Amount of mouse move to count it as a stroke
|
Last modified: Jan 6, 2010 |