31 m_keyboardNotifyList =
NULL;
36 m_autoDragTimerID = 0;
39 m_controlManager =
NULL;
43 m_directInputDevice =
NULL;
44 m_kbStateSuccess =
FALSE;
48 m_useJoystick =
FALSE;
52 m_autoDragTime = 1000;
68 if (!m_keyboardNotifyList) {
79 if (!m_keyboardNotifyList || !m_eventQueue || !m_directInputDevice) {
92 if (m_keyboardNotifyList) {
93 delete m_keyboardNotifyList;
95 m_keyboardNotifyList =
NULL;
102 if (m_controlManager) {
103 delete m_controlManager;
111 HINSTANCE hinstance = (HINSTANCE) GetWindowLong(p_hwnd, GWL_HINSTANCE);
115 if (m_directInput->CreateDevice(GUID_SysKeyboard, &m_directInputDevice,
NULL) ==
DI_OK) {
118 if (m_directInputDevice->Acquire()) {
119 MxTrace(
"Can't acquire the keyboard!\n");
128 if (m_directInputDevice !=
NULL) {
129 m_directInputDevice->Unacquire();
130 m_directInputDevice->Release();
131 m_directInputDevice =
NULL;
134 if (m_directInput !=
NULL) {
135 m_directInput->Release();
136 m_directInput =
NULL;
143 m_kbStateSuccess =
FALSE;
145 if (m_directInputDevice) {
146 HRESULT hr = m_directInputDevice->GetDeviceState(
sizeOfArray(m_keyboardState), &m_keyboardState);
149 if (m_directInputDevice->Acquire() == S_OK) {
150 hr = m_directInputDevice->GetDeviceState(
sizeOfArray(m_keyboardState), &m_keyboardState);
155 m_kbStateSuccess =
TRUE;
165 if (!m_kbStateSuccess) {
170 if (m_keyboardState[
DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) {
174 if (m_keyboardState[
DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) {
201 p_keyFlags = keyFlags;
211 if (m_useJoystick !=
FALSE) {
212 MxS32 joyid = m_joystickIndex;
214 joyinfoex.dwSize = 0x34;
215 joyinfoex.dwFlags = 0xFF;
217 if (joyGetPosEx(joyid, &joyinfoex) == JOYERR_NOERROR &&
218 joyGetDevCaps(joyid, &m_joyCaps, 0x194) == JOYERR_NOERROR) {
224 for (joyid = JOYSTICKID1; joyid < 16; joyid++) {
225 joyinfoex.dwSize = 0x34;
226 joyinfoex.dwFlags = 0xFF;
227 if (joyGetPosEx(joyid, &joyinfoex) == JOYERR_NOERROR &&
228 joyGetDevCaps(joyid, &m_joyCaps, 0x194) == JOYERR_NOERROR) {
242 DWORD* p_buttonsState,
246 if (m_useJoystick !=
FALSE) {
248 m_useJoystick =
FALSE;
253 joyinfoex.dwSize = 0x34;
254 joyinfoex.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNBUTTONS;
255 MxU32 capabilities = m_joyCaps.wCaps;
257 if ((capabilities & JOYCAPS_HASPOV) != 0) {
258 joyinfoex.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNPOV | JOY_RETURNBUTTONS;
260 if ((capabilities & JOYCAPS_POVCTS) != 0) {
261 joyinfoex.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNPOV | JOY_RETURNBUTTONS | JOY_RETURNPOVCTS;
265 MMRESULT mmresult = joyGetPosEx(m_joyid, &joyinfoex);
267 if (mmresult == MMSYSERR_NOERROR) {
268 *p_buttonsState = joyinfoex.dwButtons;
269 MxU32 xmin = m_joyCaps.wXmin;
270 MxU32 ymax = m_joyCaps.wYmax;
271 MxU32 ymin = m_joyCaps.wYmin;
272 MxS32 ydiff = ymax - ymin;
273 *p_joystickX = ((joyinfoex.dwXpos - xmin) * 100) / (m_joyCaps.wXmax - xmin);
274 *p_joystickY = ((joyinfoex.dwYpos - m_joyCaps.wYmin) * 100) / ydiff;
275 if ((m_joyCaps.wCaps & (JOYCAPS_POV4DIR | JOYCAPS_POVCTS)) != 0) {
276 if (joyinfoex.dwPOV == JOY_POVCENTERED) {
277 *p_povPosition = (
MxU32) -1;
280 *p_povPosition = joyinfoex.dwPOV / 100;
284 *p_povPosition = (
MxU32) -1;
299 if (!cursor.
Find(p_notify)) {
300 m_keyboardNotifyList->
Append(p_notify);
310 if (cursor.
Find(p_notify)) {
347 ((m_unk0x336 && (p_key == VK_SPACE)))) {
358 while (m_eventQueue->
Dequeue(event)) {
371 if (!
Lego()->IsPaused() || p_param.
GetKey() == VK_PAUSE) {
372 if (p_param.
GetKey() == VK_SHIFT) {
378 m_camera->
Notify(p_param);
382 m_unk0x195 = !m_unk0x195;
389 while (cursor.
Next(target)) {
390 if (target->
Notify(p_param) != 0) {
397 if (!
Lego()->IsPaused()) {
400 if (m_unk0x335 != 0) {
406 while (cursor.
Next(target)) {
407 if (target->
Notify(notification) != 0) {
421 if (m_world !=
NULL && m_world->
Notify(p_param) != 0) {
432 if (m_controlManager->
FUN_10029210(p_param, presenter)) {
468 if (entity && entity->
Notify(p_param) != 0) {
474 if (m_camera && m_camera->
Notify(p_param) != 0) {
492 m_x = p_param.
GetX();
493 m_y = p_param.
GetY();
505 else if (m_unk0x81) {
523 m_x = p_param.
GetX();
524 m_y = p_param.
GetY();
529 MxS32 t = diffX * diffX + diffY * diffY;
531 if (m_unk0x195 || t > m_unk0x74) {
579 if (m_autoDragTimerID) {
Camera controller for 3D scenes, handles interactive camera manipulation and view transformation.
MxLong Notify(MxParam &p_param) override
Handles notifications for camera-relevant events (like mouse drag and mouse clicks).
[AI] Manages control presenters and dispatches notifications for control/input events within the LEGO...
undefined4 GetUnknown0x0c()
[AI] Gets the internal flag at offset 0x0c.
undefined GetUnknown0x10()
[AI] Gets the internal flag at offset 0x10.
MxBool FUN_10029210(LegoEventNotificationParam &p_param, MxPresenter *p_presenter)
[AI] Handles event notification logic, taking an event and possibly updating the manager/presenter st...
[AI] Represents an entity that can be placed and managed in the LEGO Island world.
MxLong Notify(MxParam &p_param) override
[AI] Handles event notification for the entity, most notably user clicks, using polymorphic dispatch.
Notification parameter class for LEGO event notifications such as mouse events and modifier keys.
MxS32 GetY() const
Returns Y (vertical) coordinate for the event, usually screen-relative in pixels.
void SetX(MxS32 p_x)
Sets the X (horizontal) coordinate for the event.
MxU8 GetModifier()
Returns modifier bitmask for this event (mouse/keyboard state).
void SetY(MxS32 p_y)
Sets the Y (vertical) coordinate for the event.
MxU8 GetKey() const
Returns the keycode for this event, or 0 if not used.
MxS32 GetX() const
Returns X (horizontal) coordinate for the event, usually screen-relative in pixels.
void SetModifier(MxU8 p_modifier)
Sets the modifier state bitmask for the event.
void SetROI(LegoROI *p_roi)
Sets the ROI reference (object involved in the event).
[AI] Event queue for processing Lego input (mouse/keyboard/joystick) events.[AI] Queue of input event...
[AI] Cursor (iterator) for traversing a LegoNotifyList. Used to find or detach notification targets....
[AI] A list of notification targets (MxCore*) interested in input events (primarily keyboard).
static LegoOmni * GetInstance()
[AI] Returns the current LegoOmni singleton pointer, cast from MxOmni.
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
LegoEntity * GetEntity()
[AI] Gets the entity associated with this ROI (or NULL).
virtual MxPresenter * GetPresenterAt(MxS32 p_x, MxS32 p_y)
[AI] Finds a presenter at the specific screen coordinates (for hit testing).
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
[AI] Base virtual class for all Mindscape engine (Mx) objects.
virtual MxLong Notify(MxParam &p_param)
[AI] Virtual callback notification mechanism.
NotificationId GetNotification() const
[AI] Retrieves the current notification type of this parameter.
void SetNotification(NotificationId p_type)
[AI] Sets the notification type for this parameter object.
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
MxS32 GetDisplayZ() const
[AI] Returns the display Z (depth) order.
MxBool Dequeue(T &p_obj)
Removes the object from the front of the queue and copies it to p_obj.
[AI] Represents an ROI (Real-time Object Instance) that can be oriented in world space,...
OrientableROI * GetParentROI() const
Accessor for the parent ROI in the transformation hierarchy.
unsigned char GetVisibility()
[AI] Returns the visibility flag; true if visible, false if hidden.
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DECOMP_SIZE_ASSERT(T, S)
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
LegoROI * PickROI(MxLong p_x, MxLong p_y)
[AI] Picks the ROI (Renderable Object Instance) at screen coordinates.
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
LegoOmni * Lego()
[AI] Retrieves the global LegoOmni singleton instance, providing access to core subsystems.
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
#define MxTrace(args)
[AI] Macro for trace logging (non-variadic version, MSVC compatibility), expands to nothing.
NotificationId
Several of those should be defined in LegoOmni.
@ c_notificationTimer
[AI] Timer-related event [AI]
@ c_notificationDragEnd
[AI] End of drag event [AI]
@ c_notificationButtonUp
[AI] Mouse/gamepad button release [AI]
@ c_notificationButtonDown
[AI] Mouse/gamepad button press [AI]
@ c_notificationDragStart
[AI] Start of a drag event (mouse/touch) [AI]
@ c_notificationDrag
[AI] Ongoing drag/move event [AI]
@ c_notificationMouseMove
[AI] Mouse movement event [AI]
@ c_notificationKeyPress
[AI] Keyboard key press detected [AI]
@ c_notificationClick
[AI] Mouse click event [AI]