CAST II Game Engine

   MAIN       FEATURES       SCREENSHOTS       FORUMS       MANUAL       DOWNLOADS       CONTACTS   
Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Class TController

Unit

Input

Declaration

type TController = class(TSubsystem)

Description

CAST II input controller base class

TController polls input, checks if it matches specified in bindings event sequences and performs bond actions. Also some input-related routines and properties are provided.

Fields

 NameDescription
ProtectedCaptureMouseXMouse X before mouse was captured
ProtectedCaptureMouseYMouse Y before mouse was captured
PublicDblClickTimeoutDouble click timeout. Used by events with btKeyDblClick event type.
PublicEnableCharactersInputIf True all entered aplhabetical characters will be stored in InputBuffer
ProtectedFInputBufferCurrent user input buffer
ProtectedFMouseCaptureMouse capture state
ProtectedHandleApplication window handle
ProtectedKeyboardStateCurrent keyboard state
ProtectedKeyQueryStateCurrent key query state
ProtectedKeyStrString names of keys
ProtectedLastKeyStateLast keyboard state
ProtectedLastMouseStateLast mouse state
PublicMessageHandlerA message handler to direct events to
PublicMouseQueryTimeOutMinimum time in ms between queries for mouse strokes
ProtectedMouseStateCurrent mouse state
ProtectedMouseWindowA rectangle where the mouse cursor can be
PublicMouseXCurrent mouse X
PublicMouseYCurrent mouse Y

Methods

Overview

Publicconstructor Create(AHandle: Cardinal; AMessageHandler: BaseMsg.TMessageHandler); virtual;
Publicdestructor Destroy; override;
Protectedprocedure ApplyMouseCapture(Value: Boolean); virtual;
Publicprocedure BindCommand(const ABinding: TBindingStr; MsgType: CMessage; const ATimeoutMs: LongWord = DefaultTimeout); virtual;
Publicprocedure BindDelegate(const ABinding: TBindingStr; Delegate: TInputDelegate; ACustomData: SmallInt; const ATimeoutMs: LongWord = 0); virtual;
Publicprocedure BindPointer(const ABinding: TBindingStr; const ActionType: Longword; const Data: Pointer; const Value: Word = 0; const ATimeoutMs: LongWord = 0); virtual;
Publicfunction GetHotKey(Key: Word; Modifiers: TKeyModifiers): THotkey;
Publicfunction GetHotkeyModifiers(HotKey: THotkey): TKeyModifiers;
Protectedfunction GetInputBuffer: string;
Publicprocedure GetInputState; virtual; abstract;
Protectedfunction GetMouseEvent: TEventType;
Publicprocedure HandleMessage(const Msg: TMessage); override;
Publicfunction HotKeyToStr(HotKey: THotkey): string;
Publicprocedure InputEventsToMessages;
Publicfunction IsModifierKey(Key: Word): Boolean;
Publicfunction KeyToStr(Key: Integer): string;
Publicprocedure ProcessInput(const EventFilter: TInputFilter);
Protectedfunction QueryInput: TInputQueryResult; virtual;
Protectedprocedure SetCursorCapturePos;
Protectedprocedure SetMouseCapture(const Value: Boolean); virtual;
Publicprocedure SetMouseWindow(const X1, Y1, X2, Y2: Longint); virtual;
Publicfunction StrToHotKey(const BindStr: TBindingStr): THotkey;
Publicfunction StrToKey(Name: string): Integer;
Publicprocedure UnBindAll;

Description

Publicconstructor Create(AHandle: Cardinal; AMessageHandler: BaseMsg.TMessageHandler); virtual;

 

Publicdestructor Destroy; override;

 

Protectedprocedure ApplyMouseCapture(Value: Boolean); virtual;

Implementation-specific mouse capture routine

Publicprocedure BindCommand(const ABinding: TBindingStr; MsgType: CMessage; const ATimeoutMs: LongWord = DefaultTimeout); virtual;

Parses the specified binding string and binds the specified message class to it. ATimeoutMs specifies the maximum time between two consequent events.

Publicprocedure BindDelegate(const ABinding: TBindingStr; Delegate: TInputDelegate; ACustomData: SmallInt; const ATimeoutMs: LongWord = 0); virtual;

Parses the specified binding string and binds the specified delegate call to it. ATimeoutMs specifies the maximum time between two consequent events.

Publicprocedure BindPointer(const ABinding: TBindingStr; const ActionType: Longword; const Data: Pointer; const Value: Word = 0; const ATimeoutMs: LongWord = 0); virtual;

Parses the specified binding string and binds the specified pointer action to it. ATimeoutMs specifies the maximum time between two consequent events.
ActionType can be one of the following:
atBooleanOn, atBooleanOff, atBooleanToggle, atSetByte, atSetWord, atSetLongWord It's recommended to use BindCommand or BindDelegate instead.

Publicfunction GetHotKey(Key: Word; Modifiers: TKeyModifiers): THotkey;

Returns a hot key by key and set of modifiers

Publicfunction GetHotkeyModifiers(HotKey: THotkey): TKeyModifiers;

Returns a set of modifiers from a hotkey

Protectedfunction GetInputBuffer: string;

Returns user input buffer and clear it

Publicprocedure GetInputState; virtual; abstract;

Implementation-specific input poll

Protectedfunction GetMouseEvent: TEventType;

Returns mouse event which occured since last process

Publicprocedure HandleMessage(const Msg: TMessage); override;

Default message handler

Publicfunction HotKeyToStr(HotKey: THotkey): string;

Returns a string representation of the specified hot key

Publicprocedure InputEventsToMessages;

Transforms all input events to corresponding messages and directs them to MessageHandler

Publicfunction IsModifierKey(Key: Word): Boolean;

Returns True if Key is a one of modifiers key (CTRL, ALT, etc)

Publicfunction KeyToStr(Key: Integer): string;

Returns a string name of the specified key

Publicprocedure ProcessInput(const EventFilter: TInputFilter);

Pools input and checks if any of bindings should be activated

Protectedfunction QueryInput: TInputQueryResult; virtual;

Performs input query. Returns set of input query elements and fills internal events array.

Protectedprocedure SetCursorCapturePos;

Places mouse cursor to capture position (center of current window)

Protectedprocedure SetMouseCapture(const Value: Boolean); virtual;

If set to True captures mouse and hide its cursor

Publicprocedure SetMouseWindow(const X1, Y1, X2, Y2: Longint); virtual;

Sets mouse window

Publicfunction StrToHotKey(const BindStr: TBindingStr): THotkey;

Parses a binding string and returns hot key

Publicfunction StrToKey(Name: string): Integer;

Returns a key which corresponds to the specified name

Publicprocedure UnBindAll;

Clears all bindings

Properties

Overview

Publicproperty InputBuffer: string;
Publicproperty MouseCapture: Boolean;
Publicproperty SystemCursor: Boolean;

Description

Publicproperty InputBuffer: string;

Current user input buffer. Reading this property will clear the buffer.

Publicproperty MouseCapture: Boolean;

If set to True captures mouse and hide its cursor

Publicproperty SystemCursor: Boolean;

Read/write this property to determine if system mouse cursor is used.

Last modified: Jan 6, 2010
Copyright (C) 2006-2010, casteng.com