Isle
Loading...
Searching...
No Matches
LegoInputManager Class Reference

[AI] Handles keyboard, mouse, and joystick input for the game. More...

#include <legoinputmanager.h>

Inheritance diagram for LegoInputManager:
Collaboration diagram for LegoInputManager:

Public Types

enum  Keys {
  c_left = 0x01 , c_right = 0x02 , c_up = 0x04 , c_down = 0x08 ,
  c_ctrl = 0x10 , c_leftOrRight = c_left | c_right , c_upOrDown = c_up | c_down
}
 [AI] Key flags for common navigation keys and bitwise combinations used for state queries. More...
 
- Public Types inherited from MxPresenter
enum  TickleState {
  e_idle = 0 , e_ready , e_starting , e_streaming ,
  e_repeating , e_freezing , e_done
}
 [AI] Represents the state of the presenter's tickle (update) lifecycle. More...
 

Public Member Functions

 LegoInputManager ()
 [AI] Initialize default state: input device handles, notification lists, and member flags. [AI] More...
 
 ~LegoInputManager () override
 [AI] Clean up and release all acquired input devices, notification lists, control managers, and event queues. [AI] More...
 
void QueueEvent (NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, MxU8 p_key)
 [AI] Add an input event (for mouse, keyboard, or joystick) to the processing queue, or process immediately based on flags/state. More...
 
void Register (MxCore *)
 [AI] Register a core object as a recipient for keyboard events; safe for concurrent multi-threading. More...
 
void UnRegister (MxCore *)
 [AI] Unregister a previously registered recipient so it will no longer receive input notifications. More...
 
MxResult Tickle () override
 [AI] Updates input and processes the event queue. More...
 
MxResult PutData () override
 [AI] No-op, always returns SUCCESS. Place-holder for presenter put-data protocol. More...
 
MxResult Create (HWND p_hwnd)
 [AI] Set up DirectInput and joystick state, instantiate controller and notification list. More...
 
void Destroy () override
 [AI] Release all allocated DirectInput devices, notification lists, event queues, and control manager. [AI] More...
 
void CreateAndAcquireKeyboard (HWND p_hwnd)
 [AI] Create keyboard input device and acquire focus for the given window handle. More...
 
void ReleaseDX ()
 [AI] Unacquire and release all DirectInput device interfaces (keyboard). [AI] More...
 
MxResult GetJoystickId ()
 [AI] Scan for valid joystick ID based on preferred index or check all available joysticks. More...
 
MxResult GetJoystickState (MxU32 *p_joystickX, MxU32 *p_joystickY, DWORD *p_buttonsState, MxU32 *p_povPosition)
 [AI] Retrieve state of the currently assigned joystick device and normalized position/button state. More...
 
void StartAutoDragTimer ()
 [AI] Start the Windows timer used for distinguishing auto drag events during mouse interaction. [AI] More...
 
void StopAutoDragTimer ()
 [AI] Stop the running auto drag timer if any. [AI] More...
 
void EnableInputProcessing ()
 [AI] Enable event queue and input event processing. Resets relevant state. [AI] More...
 
void SetCamera (LegoCameraController *p_camera)
 [AI] Assigns a new camera controller for mouse/look operations. More...
 
void ClearCamera ()
 [AI] Remove any assigned camera controller, disabling camera navigation responses. [AI] More...
 
void SetWorld (LegoWorld *p_world)
 [AI] Assigns the current world to receive mouse/click/pick notifications. More...
 
void ClearWorld ()
 [AI] Remove any world assignment (used to clear targeting/scene changes). [AI] More...
 
void SetUnknown88 (MxBool p_unk0x88)
 [AI] Set general-purpose input block flag (purpose: temporary input disable during drag or transitions). More...
 
void SetUnknown335 (MxBool p_unk0x335)
 [AI] Typically used to allow button-down event processing during partial-blocked states. More...
 
void SetUnknown336 (MxBool p_unk0x336)
 [AI] Enables accepting input only for space-bar events (used in special UI states). More...
 
void SetUseJoystick (MxBool p_useJoystick)
 [AI] Enable or disable joystick support in input processing. More...
 
void SetJoystickIndex (MxS32 p_joystickIndex)
 [AI] Set user-preferred joystick device index (overrides auto-detection). More...
 
void DisableInputProcessing ()
 [AI] Block most input processing, allowing only button-down and space events (UI modal input blocking). More...
 
LegoControlManagerGetControlManager ()
 [AI] Retrieve the active control manager, responsible for UI and main action mapping. More...
 
LegoWorldGetWorld ()
 [AI] Retrieve the currently assigned LegoWorld for scene and actor event notifications. More...
 
LegoCameraControllerGetCamera ()
 [AI] Returns the current camera controller. More...
 
void ProcessEvents ()
 [AI] Dispatch processing of all queued input events until the queue is empty or processing requests exit. More...
 
MxBool ProcessOneEvent (LegoEventNotificationParam &p_param)
 [AI] Processes a single input event (key, mouse click, drag, etc.), sending it to appropriate targets. More...
 
MxBool FUN_1005cdf0 (LegoEventNotificationParam &p_param)
 [AI] Complex drag/click/timer event filter. More...
 
void GetKeyboardState ()
 [AI] Polls DirectInput for current keyboard state. Updates m_keyboardState and success flag. [AI] More...
 
MxResult GetNavigationKeyStates (MxU32 &p_keyFlags)
 [AI] Retrieves current navigation (arrow) key status from the keyboard, combining keypad and arrow keys into bitmask. More...
 
- Public Member Functions inherited from MxPresenter
 MxPresenter ()
 [AI] Constructor. Initializes internal tickle state and other members. More...
 
MxResult Tickle () override
 [AI] Main tickle handler, called periodically to progress presenter's internal state. More...
 
virtual void VTable0x14 ()
 [AI] Reserved for future or specialized use in derived classes. More...
 
virtual void ReadyTickle ()
 [AI] Handles the transition and setup for the Ready state. Parses extra action data and advances state. More...
 
virtual void StartingTickle ()
 [AI] Handles actions required when first starting presentation. Advances to streaming state. More...
 
virtual void StreamingTickle ()
 [AI] Handles periodic updates during the streaming/presentation stage. Advances to repeating state. More...
 
virtual void RepeatingTickle ()
 [AI] Handles updates when in a repeating (looping) stage. Advances to freezing state. More...
 
virtual void FreezingTickle ()
 [AI] Handles updates during the freezing/suspended state. Advances to done state. More...
 
 ~MxPresenter () override
 [AI] Destructor, cleans up resources (base class: does nothing beyond Init). More...
 
virtual MxResult AddToManager ()
 [AI] Optional registration with a manager (such as TickleManager); by default does nothing. More...
 
virtual void Destroy ()
 [AI] Resets presenter state or cleans up resources after completion/removal. More...
 
virtual MxResult StartAction (MxStreamController *, MxDSAction *)
 [AI] Initiates presenter for a new action, setting up context and state. More...
 
virtual void EndAction ()
 [AI] Terminates the current action, notifies listeners and resets state. More...
 
virtual void SetTickleState (TickleState p_tickleState)
 [AI] Forces the tickle state, advancing to the requested lifecycle stage. More...
 
virtual MxBool HasTickleStatePassed (TickleState p_tickleState)
 [AI] Checks if the specified tickle state has ever been passed since last reset. More...
 
virtual MxResult PutData ()
 [AI] Allows the presenter to submit pending results or output to the engine. More...
 
virtual MxBool IsHit (MxS32 p_x, MxS32 p_y)
 [AI] Returns TRUE if the given (x, y) falls within hit-test bounds for the presenter (e.g. More...
 
virtual void Enable (MxBool p_enable)
 [AI] Enables or disables this presenter (controls action flags accordingly). More...
 
const char * ClassName () const override
 [AI] Returns the run-time class name for this presenter. More...
 
MxBool IsA (const char *p_name) const override
 [AI] Determines if this object is of (or inherits) the specified named class. More...
 
MxEntityCreateEntity (const char *p_defaultName)
 [AI] Creates an entity based on action 'extra' data, or uses the provided default name. More...
 
void SendToCompositePresenter (MxOmni *p_omni)
 [AI] Notifies a composite presenter (if one exists) that this presenter wishes to join a group. More...
 
MxBool IsEnabled ()
 [AI] Returns whether this presenter is logically enabled (based on the associated action's flags). More...
 
MxS32 GetCurrentTickleState () const
 [AI] Returns the current tickle state. More...
 
MxPoint32 GetLocation () const
 [AI] Returns the presenter's screen location (in pixels). More...
 
MxS32 GetX () const
 [AI] Returns the X coordinate of screen location. More...
 
MxS32 GetY () const
 [AI] Returns the Y coordinate of screen location. More...
 
MxS32 GetDisplayZ () const
 [AI] Returns the display Z (depth) order. More...
 
MxDSActionGetAction () const
 [AI] Returns the current action being presented. More...
 
void SetAction (MxDSAction *p_action)
 [AI] Sets the action associated with this presenter. More...
 
void SetCompositePresenter (MxCompositePresenter *p_compositePresenter)
 [AI] Sets the composite presenter to notify/join on completion. More...
 
void SetDisplayZ (MxS32 p_displayZ)
 [AI] Sets the display Z (depth) order for the presenter. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MxPresenter
static const char * HandlerClassName ()
 [AI] Returns the handler class name for identification and reflection purposes. More...
 
- Protected Member Functions inherited from MxPresenter
virtual void DoneTickle ()
 [AI] Handles any post-completion logic, resetting to idle state. More...
 
virtual void ParseExtra ()
 [AI] Parses additional data from the associated action for configuration or world interaction. More...
 
void ProgressTickleState (TickleState p_tickleState)
 [AI] Helper for advancing the presenter's tickle state and updating transition history. More...
 
void Init ()
 [AI] Initializes object state to post-construction defaults. More...
 
- Protected Attributes inherited from MxPresenter
TickleState m_currentTickleState
 [AI] Current state in the tickle lifecycle. More...
 
MxU32 m_previousTickleStates
 [AI] Bitfield representing all tickle states that have already occurred during this lifetime. More...
 
MxPoint32 m_location
 [AI] 2D display location for the presenter. More...
 
MxS32 m_displayZ
 [AI] Z-order value for display stacking. More...
 
MxDSActionm_action
 [AI] The associated action currently being presented by this presenter. More...
 
MxCriticalSection m_criticalSection
 [AI] Thread synchronization for presenter state and data. More...
 
MxCompositePresenterm_compositePresenter
 [AI] Owner composite presenter, if any. More...
 

Detailed Description

[AI] Handles keyboard, mouse, and joystick input for the game.

Central input system that tracks platform input devices and manages event notification and processing. Responsible for processing DirectInput keyboard events, Windows joystick input, and mouse events.

Registers and notifies listeners of key/button/mouse actions, manages drag/timing logic, and interacts with camera and world objects to impart navigation and click/drag operations. Controls input availability/focus and their event flows. [AI]

Definition at line 57 of file legoinputmanager.h.

Member Enumeration Documentation

◆ Keys

[AI] Key flags for common navigation keys and bitwise combinations used for state queries.

Enumerator
c_left 

[AI] Left arrow key or equivalent key [AI]

c_right 

[AI] Right arrow key or equivalent key [AI]

c_up 

[AI] Up arrow key or equivalent key [AI]

c_down 

[AI] Down arrow key or equivalent key [AI]

c_ctrl 

[AI] Control key [AI]

c_leftOrRight 

[AI] Combo: left or right arrow [AI]

c_upOrDown 

[AI] Combo: up or down arrow [AI]

Definition at line 61 of file legoinputmanager.h.

Constructor & Destructor Documentation

◆ LegoInputManager()

LegoInputManager::LegoInputManager ( )

[AI] Initialize default state: input device handles, notification lists, and member flags. [AI]

Definition at line 29 of file legoinputmanager.cpp.

◆ ~LegoInputManager()

LegoInputManager::~LegoInputManager ( )
override

[AI] Clean up and release all acquired input devices, notification lists, control managers, and event queues. [AI]

Definition at line 56 of file legoinputmanager.cpp.

Member Function Documentation

◆ ClearCamera()

void LegoInputManager::ClearCamera ( )

[AI] Remove any assigned camera controller, disabling camera navigation responses. [AI]

Definition at line 322 of file legoinputmanager.cpp.

◆ ClearWorld()

void LegoInputManager::ClearWorld ( )

[AI] Remove any world assignment (used to clear targeting/scene changes). [AI]

Definition at line 336 of file legoinputmanager.cpp.

◆ Create()

MxResult LegoInputManager::Create ( HWND  p_hwnd)

[AI] Set up DirectInput and joystick state, instantiate controller and notification list.

Parameters
p_hwndWindow handle whose instance/input context should be used. [AI]
Returns
SUCCESS (0) if OK, FAILURE otherwise [AI]

Definition at line 62 of file legoinputmanager.cpp.

◆ CreateAndAcquireKeyboard()

void LegoInputManager::CreateAndAcquireKeyboard ( HWND  p_hwnd)

[AI] Create keyboard input device and acquire focus for the given window handle.

Parameters
p_hwndWindow handle to acquire for keyboard input [AI]

Definition at line 109 of file legoinputmanager.cpp.

◆ Destroy()

void LegoInputManager::Destroy ( )
overridevirtual

[AI] Release all allocated DirectInput devices, notification lists, event queues, and control manager. [AI]

Reimplemented from MxPresenter.

Definition at line 88 of file legoinputmanager.cpp.

◆ DisableInputProcessing()

void LegoInputManager::DisableInputProcessing ( )
inline

[AI] Block most input processing, allowing only button-down and space events (UI modal input blocking).

Definition at line 171 of file legoinputmanager.h.

◆ EnableInputProcessing()

void LegoInputManager::EnableInputProcessing ( )

[AI] Enable event queue and input event processing. Resets relevant state. [AI]

Definition at line 585 of file legoinputmanager.cpp.

◆ FUN_1005cdf0()

MxBool LegoInputManager::FUN_1005cdf0 ( LegoEventNotificationParam p_param)

[AI] Complex drag/click/timer event filter.

Determines if/when to convert mouse motion into clicks or drags.

Parameters
p_paramInput event (may be updated to reflect drag state) [AI]
Returns
TRUE if notification should continue, FALSE to block further handling [AI]

Definition at line 486 of file legoinputmanager.cpp.

◆ GetCamera()

LegoCameraController * LegoInputManager::GetCamera ( )
inline

[AI] Returns the current camera controller.

Returns
Camera controller or NULL [AI]

Definition at line 187 of file legoinputmanager.h.

◆ GetControlManager()

LegoControlManager * LegoInputManager::GetControlManager ( )
inline

[AI] Retrieve the active control manager, responsible for UI and main action mapping.

Returns
Control manager object [AI]

Definition at line 179 of file legoinputmanager.h.

◆ GetJoystickId()

MxResult LegoInputManager::GetJoystickId ( )

[AI] Scan for valid joystick ID based on preferred index or check all available joysticks.

Sets up internal JOYCAPS.

Returns
SUCCESS if joystick found and configured, FAILURE otherwise [AI]

Definition at line 207 of file legoinputmanager.cpp.

◆ GetJoystickState()

MxResult LegoInputManager::GetJoystickState ( MxU32 p_joystickX,
MxU32 p_joystickY,
DWORD p_buttonsState,
MxU32 p_povPosition 
)

[AI] Retrieve state of the currently assigned joystick device and normalized position/button state.

Parameters
p_joystickXNormalized X axis (0-100) [AI]
p_joystickYNormalized Y axis (0-100) [AI]
p_buttonsStateJoystick button bitmask [AI]
p_povPositionPOV (hat) position (degrees/100 or -1 if centered) [AI]
Returns
SUCCESS if state successfully retrieved, FAILURE if not [AI]

Definition at line 239 of file legoinputmanager.cpp.

◆ GetKeyboardState()

void LegoInputManager::GetKeyboardState ( )

[AI] Polls DirectInput for current keyboard state. Updates m_keyboardState and success flag. [AI]

Definition at line 141 of file legoinputmanager.cpp.

◆ GetNavigationKeyStates()

MxResult LegoInputManager::GetNavigationKeyStates ( MxU32 p_keyFlags)

[AI] Retrieves current navigation (arrow) key status from the keyboard, combining keypad and arrow keys into bitmask.

Parameters
p_keyFlagsOutput for combined key status (bitmask of enum Keys). [AI]
Returns
SUCCESS if keyboard state fetched, FAILURE if device not ready [AI]

Definition at line 161 of file legoinputmanager.cpp.

◆ GetWorld()

LegoWorld * LegoInputManager::GetWorld ( )
inline

[AI] Retrieve the currently assigned LegoWorld for scene and actor event notifications.

Returns
The assigned world object [AI]

Definition at line 183 of file legoinputmanager.h.

◆ ProcessEvents()

void LegoInputManager::ProcessEvents ( )

[AI] Dispatch processing of all queued input events until the queue is empty or processing requests exit.

Definition at line 353 of file legoinputmanager.cpp.

◆ ProcessOneEvent()

MxBool LegoInputManager::ProcessOneEvent ( LegoEventNotificationParam p_param)

[AI] Processes a single input event (key, mouse click, drag, etc.), sending it to appropriate targets.

Applies drag/click logic, entity and UI focus resolution. Returns TRUE if the event caused an exclusive action.

Parameters
p_paramInput event description [AI]
Returns
TRUE if the event consumed and should stop further processing [AI]

Definition at line 366 of file legoinputmanager.cpp.

◆ PutData()

MxResult LegoInputManager::PutData ( )
inlineoverridevirtual

[AI] No-op, always returns SUCCESS. Place-holder for presenter put-data protocol.

Reimplemented from MxPresenter.

Definition at line 98 of file legoinputmanager.h.

◆ QueueEvent()

void LegoInputManager::QueueEvent ( NotificationId  p_id,
MxU8  p_modifier,
MxLong  p_x,
MxLong  p_y,
MxU8  p_key 
)

[AI] Add an input event (for mouse, keyboard, or joystick) to the processing queue, or process immediately based on flags/state.

Parameters
p_idNotification type (e.g., key press, mouse click) [AI]
p_modifierModifier flags (e.g., mouse button state, key modifiers) [AI]
p_xX screen coordinate [AI]
p_yY screen coordinate [AI]
p_keyKey code (virtual key, DIK_*, etc.) [AI]

Definition at line 342 of file legoinputmanager.cpp.

◆ Register()

void LegoInputManager::Register ( MxCore p_notify)

[AI] Register a core object as a recipient for keyboard events; safe for concurrent multi-threading.

Parameters
p_notifyMxCore* to add to keyboard notification list [AI]

Definition at line 294 of file legoinputmanager.cpp.

◆ ReleaseDX()

void LegoInputManager::ReleaseDX ( )

[AI] Unacquire and release all DirectInput device interfaces (keyboard). [AI]

Definition at line 126 of file legoinputmanager.cpp.

◆ SetCamera()

void LegoInputManager::SetCamera ( LegoCameraController p_camera)

[AI] Assigns a new camera controller for mouse/look operations.

Parameters
p_cameraCamera controller to use (may be NULL to disable camera actions) [AI]

Definition at line 316 of file legoinputmanager.cpp.

◆ SetJoystickIndex()

void LegoInputManager::SetJoystickIndex ( MxS32  p_joystickIndex)
inline

[AI] Set user-preferred joystick device index (overrides auto-detection).

Parameters
p_joystickIndexPreferred joystick index to use [AI]

Definition at line 168 of file legoinputmanager.h.

◆ SetUnknown335()

void LegoInputManager::SetUnknown335 ( MxBool  p_unk0x335)
inline

[AI] Typically used to allow button-down event processing during partial-blocked states.

Parameters
p_unk0x335New value for flag [AI]

Definition at line 156 of file legoinputmanager.h.

◆ SetUnknown336()

void LegoInputManager::SetUnknown336 ( MxBool  p_unk0x336)
inline

[AI] Enables accepting input only for space-bar events (used in special UI states).

Parameters
p_unk0x336New value for flag [AI]

Definition at line 160 of file legoinputmanager.h.

◆ SetUnknown88()

void LegoInputManager::SetUnknown88 ( MxBool  p_unk0x88)
inline

[AI] Set general-purpose input block flag (purpose: temporary input disable during drag or transitions).

Parameters
p_unk0x88TRUE to block input, FALSE to allow [AI]

Definition at line 152 of file legoinputmanager.h.

◆ SetUseJoystick()

void LegoInputManager::SetUseJoystick ( MxBool  p_useJoystick)
inline

[AI] Enable or disable joystick support in input processing.

Parameters
p_useJoystickTRUE to use joystick, FALSE to ignore joystick [AI]

Definition at line 164 of file legoinputmanager.h.

◆ SetWorld()

void LegoInputManager::SetWorld ( LegoWorld p_world)

[AI] Assigns the current world to receive mouse/click/pick notifications.

Parameters
p_worldWorld for click/drag event targeting [AI]

Definition at line 329 of file legoinputmanager.cpp.

◆ StartAutoDragTimer()

void LegoInputManager::StartAutoDragTimer ( )

[AI] Start the Windows timer used for distinguishing auto drag events during mouse interaction. [AI]

Definition at line 570 of file legoinputmanager.cpp.

◆ StopAutoDragTimer()

void LegoInputManager::StopAutoDragTimer ( )

[AI] Stop the running auto drag timer if any. [AI]

Definition at line 577 of file legoinputmanager.cpp.

◆ Tickle()

MxResult LegoInputManager::Tickle ( )
overridevirtual

[AI] Updates input and processes the event queue.

Called by the tickle system each frame or input 'tick'.

Returns
Always returns SUCCESS [AI]

Reimplemented from MxCore.

◆ UnRegister()

void LegoInputManager::UnRegister ( MxCore p_notify)

[AI] Unregister a previously registered recipient so it will no longer receive input notifications.

Parameters
p_notifyMxCore* to remove [AI]

Definition at line 305 of file legoinputmanager.cpp.


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