mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-20 14:51:15 +00:00
Squashed commit of the following:
commit 1fe03a4a787693616c56f59622bcaae8fd53b30b
Author: ecumber <ecumber05@gmail.com>
Date: Thu Jul 6 21:04:15 2023 -0700
data types
commit 7c8432f88236c42c17998d51e820b5e219f3c326
Author: ecumber <ecumber05@gmail.com>
Date: Thu Jul 6 12:39:13 2023 -0700
Destroy
commit f60eb3923b24bc87bb31ba783676c6a50d48e9b8
Author: ecumber <ecumber05@gmail.com>
Date: Thu Jul 6 12:15:33 2023 -0700
compile fix
commit e2f78d557f223c2552a046470578d154c29e473b
Author: ecumber <ecumber05@gmail.com>
Date: Tue Jul 4 13:37:33 2023 -0700
Timer functions
commit 447e234e6324a5b0958e9e94c5cda53703abada2
Author: ecumber <ecumber05@gmail.com>
Date: Thu Jul 6 02:40:10 2023 -0700
fix
commit 4670fd790b16a15b5797d50bc3cd1f6e2c9e890d
Author: ecumber <ecumber05@gmail.com>
Date: Thu Jul 6 02:39:04 2023 -0700
improvements
commit 7f70bce1eefe550fe6bef193e7ee54948af354b6
Author: ecumber <ecumber05@gmail.com>
Date: Tue Jul 4 03:42:47 2023 -0700
Update legoinputmanager.cpp
commit 0d3433a75d2b20a3fff1da8147ce502b279b1e9c
Author: ecumber <ecumber05@gmail.com>
Date: Tue Jul 4 03:38:32 2023 -0700
Add ReleaseDX
commit 72d27fd402efb37da1ce8c41a3350df66c99db1d
Author: ecumber <ecumber05@gmail.com>
Date: Tue Jul 4 02:27:12 2023 -0700
Update CMakeLists.txt
commit 09626a62f9d2c56a523ca582be95a4dfb29ee188
Author: ecumber <ecumber05@gmail.com>
Date: Mon Jul 3 13:48:46 2023 -0700
Move to new branch
This commit is contained in:
parent
67115e32d3
commit
055b83c1ab
@ -177,8 +177,9 @@ add_library(lego1 SHARED
|
||||
LEGO1/viewmanager.cpp
|
||||
)
|
||||
|
||||
target_include_directories(lego1 PRIVATE "dx5sdk/inc")
|
||||
# Link libraries
|
||||
target_link_libraries(lego1 PRIVATE ddraw dsound winmm)
|
||||
target_link_libraries(lego1 PRIVATE ddraw dsound winmm "${CMAKE_SOURCE_DIR}/dx5sdk/lib/dinput.lib" "${CMAKE_SOURCE_DIR}/dx5sdk/lib/dxguid.lib")
|
||||
|
||||
# Make sure filenames are ALL CAPS
|
||||
set_property(TARGET lego1 PROPERTY OUTPUT_NAME LEGO1)
|
||||
@ -192,10 +193,10 @@ if (ISLE_BUILD_APP)
|
||||
)
|
||||
|
||||
# Include LEGO1 headers in ISLE
|
||||
target_include_directories(isle PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1")
|
||||
target_include_directories(isle PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1" "dx5sdk/inc")
|
||||
|
||||
# Link DSOUND, WINMM, and LEGO1
|
||||
target_link_libraries(isle PRIVATE dsound winmm lego1)
|
||||
target_link_libraries(isle PRIVATE dsound winmm lego1 "${CMAKE_SOURCE_DIR}/dx5sdk/lib/dinput.lib" "${CMAKE_SOURCE_DIR}/dx5sdk/lib/dxguid.lib")
|
||||
|
||||
# Make sure filenames are ALL CAPS
|
||||
set_property(TARGET isle PROPERTY OUTPUT_NAME ISLE)
|
||||
|
||||
@ -1,13 +1,35 @@
|
||||
#include "legoinputmanager.h"
|
||||
|
||||
#include "decomp.h"
|
||||
#include "legoomni.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoInputManager, 0x338); // 0x10059085
|
||||
//DECOMP_SIZE_ASSERT(LegoInputManager, 0x338); // 0x10059085
|
||||
|
||||
// OFFSET: LEGO1 0x1005b790 STUB
|
||||
// OFFSET: LEGO1 0x1005b790
|
||||
LegoInputManager::LegoInputManager()
|
||||
{
|
||||
// TODO
|
||||
m_unknown5C = 0;
|
||||
m_unknown64 = NULL;
|
||||
m_unknown60 = NULL;
|
||||
m_unknown_classptr68 = NULL;
|
||||
m_unknown80 = 0;
|
||||
m_timer = 0;
|
||||
m_unknown6C = 0;
|
||||
m_unknown70 = 0;
|
||||
m_controlManager = NULL;
|
||||
m_bool81 = FALSE;
|
||||
m_bool88 = FALSE;
|
||||
m_directinputInterface = NULL;
|
||||
m_directinputDeviceInterface = NULL;
|
||||
m_unused94 = 0;
|
||||
m_unknown195 = 0;
|
||||
m_joyid = (UINT)-1;
|
||||
m_unknown19C = (UINT)-1;
|
||||
m_joystickIndex = 0;
|
||||
m_useJoystick = FALSE;
|
||||
m_unknown336 = 0;
|
||||
m_unknown74 = 0x19;
|
||||
m_timeout = 1000;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x1005b8f0 STUB
|
||||
@ -35,10 +57,150 @@ void LegoInputManager::UnRegister(MxCore *)
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x1005b8b0 STUB
|
||||
MxLong LegoInputManager::Tickle()
|
||||
{
|
||||
// TODO
|
||||
//MxLong LegoInputManager::Tickle()
|
||||
//{
|
||||
// // TODO
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
return 0;
|
||||
void LegoInputManager::Destroy()
|
||||
{
|
||||
ReleaseDX();
|
||||
|
||||
if (m_unknown_classptr68 != NULL) delete[] m_unknown_classptr68;
|
||||
if (m_controlManager != NULL) delete[] m_controlManager;
|
||||
return;
|
||||
}
|
||||
|
||||
void LegoInputManager::SetTimer()
|
||||
{
|
||||
LegoOmni* omni = LegoOmni::GetInstance();
|
||||
UINT timer = ::SetTimer(*omni->GetWindowHandle(), 1, m_timeout, NULL);
|
||||
m_timer = timer;
|
||||
}
|
||||
|
||||
void LegoInputManager::KillTimer()
|
||||
{
|
||||
if (m_timer != 0)
|
||||
{
|
||||
LegoOmni* omni = LegoOmni::GetInstance();
|
||||
::KillTimer(*omni->GetWindowHandle(), m_timer);
|
||||
}
|
||||
}
|
||||
|
||||
// this function currently does not match 100% due to some member variables
|
||||
// being at the wrong offsets, but the functionality is the same
|
||||
|
||||
// OFFSET: LEGO1 0x1005c030
|
||||
void LegoInputManager::CreateAndAcquireKeyboard(HWND hwnd)
|
||||
{
|
||||
HINSTANCE hinstance = (HINSTANCE)GetWindowLongA(hwnd, GWL_HINSTANCE);
|
||||
HRESULT hresult = DirectInputCreateA(hinstance, 0x500, &m_directinputInterface, NULL); // 0x500 for DX5
|
||||
if (hresult == DI_OK)
|
||||
{
|
||||
HRESULT createdeviceresult = m_directinputInterface->CreateDevice(GUID_SysKeyboard, &m_directinputDeviceInterface, NULL);
|
||||
if (createdeviceresult == DI_OK)
|
||||
{
|
||||
m_directinputDeviceInterface->RunControlPanel(hwnd, 6);
|
||||
m_directinputDeviceInterface->SetDataFormat(&c_dfDIKeyboard);
|
||||
m_directinputDeviceInterface->Acquire();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MxS32 LegoInputManager::GetJoystickState(unsigned int* joystick_x, unsigned int* joystick_y, DWORD* buttons_state, unsigned int* pov_position)
|
||||
{
|
||||
if ((m_joystickIndex != JOYSTICKID1) && (m_joyid < 0) && (GetJoystickId() == -1))
|
||||
{
|
||||
m_joystickIndex = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
JOYINFOEX joyinfoex;
|
||||
joyinfoex.dwSize = 0x34;
|
||||
joyinfoex.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNBUTTONS;
|
||||
MxU32 capabilities = m_joyCapsA.wCaps;
|
||||
if ((capabilities & JOYCAPS_HASPOV) != 0)
|
||||
{
|
||||
joyinfoex.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNPOV | JOY_RETURNBUTTONS;
|
||||
if ((capabilities & JOYCAPS_POVCTS) != 0)
|
||||
{
|
||||
joyinfoex.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNPOV | JOY_RETURNBUTTONS | JOY_RETURNPOVCTS;
|
||||
}
|
||||
}
|
||||
MMRESULT mmresult = joyGetPosEx(m_joyid, &joyinfoex);
|
||||
if (mmresult == MMSYSERR_NOERROR)
|
||||
{
|
||||
*buttons_state = joyinfoex.dwButtons;
|
||||
MxU32 xmin = m_joyCapsA.wXmin;
|
||||
MxU32 ymax = m_joyCapsA.wYmax;
|
||||
MxU32 ymin = m_joyCapsA.wYmin;
|
||||
*joystick_x = ((joyinfoex.dwXpos - xmin) * 100) / (m_joyCapsA.wXmax - xmin);
|
||||
*joystick_y = ((joyinfoex.dwYpos - m_joyCapsA.wYmin) * 100) / (ymax - ymin);
|
||||
if ((m_joyCapsA.wCaps & (JOYCAPS_POV4DIR | JOYCAPS_POVCTS)) == 0)
|
||||
{
|
||||
*pov_position = (MxU32)-1;
|
||||
return 0;
|
||||
}
|
||||
if (joyinfoex.dwPOV == JOY_POVCENTERED)
|
||||
{
|
||||
*pov_position = (MxU32)-1;
|
||||
return 0;
|
||||
}
|
||||
*pov_position = joyinfoex.dwPOV / 100;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// FIXME: there's 2 different variables for the joystick id??? also the lines that
|
||||
// set dwSize and dwFlags result in incorrect offsets in the JOYINFOEX struct
|
||||
|
||||
// OFFSET: LEGO1 0x1005c240
|
||||
MxS32 LegoInputManager::GetJoystickId()
|
||||
{
|
||||
JOYINFOEX joyinfoex;
|
||||
if (m_joystickIndex != JOYSTICKID1)
|
||||
{
|
||||
MxS32 joyid = m_unknown19C;
|
||||
if (-1 < joyid)
|
||||
{
|
||||
joyinfoex.dwSize = 0x34;
|
||||
joyinfoex.dwFlags = 0xFF;
|
||||
if (joyGetPosEx(joyid, &joyinfoex) == JOYERR_NOERROR && joyGetDevCapsA(joyid, &m_joyCapsA, 0x194) == JOYERR_NOERROR)
|
||||
{
|
||||
m_joyid = joyid;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (joyid = JOYSTICKID1; joyid < 16; joyid++)
|
||||
{
|
||||
joyinfoex.dwSize = 0x34;
|
||||
joyinfoex.dwFlags = 0xFF;
|
||||
if (joyGetPosEx(joyid, &joyinfoex) == JOYERR_NOERROR && joyGetDevCapsA(joyid, &m_joyCapsA, 0x194) == JOYERR_NOERROR)
|
||||
{
|
||||
m_joyid = joyid;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void LegoInputManager::ReleaseDX()
|
||||
{
|
||||
if (m_directinputDeviceInterface != NULL)
|
||||
{
|
||||
m_directinputDeviceInterface->Unacquire();
|
||||
m_directinputDeviceInterface->Release();
|
||||
m_directinputDeviceInterface = NULL;
|
||||
}
|
||||
if (m_directinputInterface != NULL)
|
||||
{
|
||||
m_directinputInterface->Release();
|
||||
m_directinputInterface = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxpresenter.h"
|
||||
#include "legocontrolmanager.h"
|
||||
#include <dinput.h>
|
||||
|
||||
enum NotificationId
|
||||
{
|
||||
@ -25,13 +27,48 @@ class LegoInputManager : public MxPresenter
|
||||
__declspec(dllexport) void QueueEvent(NotificationId id, unsigned char p2, MxLong p3, MxLong p4, unsigned char p5);
|
||||
__declspec(dllexport) void Register(MxCore *);
|
||||
__declspec(dllexport) void UnRegister(MxCore *);
|
||||
void Destroy();
|
||||
MxS32 GetJoystickState(unsigned int* something_x, unsigned int* something_y, DWORD* buttons_state, unsigned int* pov_position);
|
||||
void CreateAndAcquireKeyboard(HWND hwnd);
|
||||
MxS32 GetJoystickId();
|
||||
void ReleaseDX();
|
||||
void SetTimer();
|
||||
void KillTimer();
|
||||
|
||||
virtual MxLong Tickle() override; // vtable+0x8
|
||||
|
||||
undefined m_pad40[0x15c];
|
||||
int m_joystickIndex;
|
||||
undefined m_pad200[0x194];
|
||||
MxBool m_useJoystick;
|
||||
//virtual MxLong Tickle() override; // vtable+0x8
|
||||
MxCriticalSection m_criticalsection; // 0x40
|
||||
MxS32 m_unknown5C; // 0x5C
|
||||
MxS32* m_unknown60; // 0x60
|
||||
MxS32* m_unknown64; // 0x64
|
||||
void* m_unknown_classptr68; // 0x68
|
||||
MxS32 m_unknown6C; // 0x6C
|
||||
MxS32 m_unknown70; // 0x70
|
||||
MxS32 m_unknown74; // 0x74
|
||||
UINT m_timer; // 0x78
|
||||
UINT m_timeout; // 0x7C
|
||||
MxU8 m_unknown80; // 0x80
|
||||
MxBool m_bool81; // 0x81
|
||||
MxU8 m_unknown82; // 0x82
|
||||
MxU8 m_unknown83; // 0x83
|
||||
LegoControlManager* m_controlManager; // 0x84
|
||||
MxBool m_bool88; // 0x88
|
||||
MxU8 m_unknown89[3]; // 0x89
|
||||
IDirectInputA* m_directinputInterface; // 0x8C
|
||||
IDirectInputDeviceA* m_directinputDeviceInterface; // 0x90
|
||||
MxU8 m_unused94; // 0x94
|
||||
MxU8 m_unknown95[3]; // 0x95
|
||||
void* m_unknown98; // 0x98
|
||||
MxU8 m_unknown9C[0xF8]; // 0x9C
|
||||
MxBool m_unknown195; // 0x195
|
||||
MxU8 m_unknown196[2]; // 0x196
|
||||
UINT m_joyid; // 0x198
|
||||
UINT m_unknown19C; // 0x19C
|
||||
JOYCAPSA m_joyCapsA; // 0x1a0
|
||||
MxU8 m_joystickIndex; // 0x334
|
||||
MxBool m_useJoystick; // 0x335
|
||||
MxU8 m_unknown336; // 0x336
|
||||
MxU8 m_unknown337; // 0x337
|
||||
MxU8 m_unknown338; // 0x338
|
||||
};
|
||||
|
||||
#endif // LEGOINPUTMANAGER_H
|
||||
|
||||
@ -47,6 +47,9 @@ class MxOmni : public MxCore
|
||||
MxVariableTable* GetVariableTable() const { return this->m_variableTable; }
|
||||
MxMusicManager* GetMusicManager() const { return this->m_musicManager; }
|
||||
MxEventManager* GetEventManager() const { return this->m_eventManager; }
|
||||
|
||||
// FIXME: put this in the correct spot, just a hack for LegoInputManager
|
||||
HWND* GetWindowHandle() const { return this->m_windowHandle; }
|
||||
protected:
|
||||
static MxOmni* g_instance;
|
||||
|
||||
|
||||
5
dx5sdk/.gitignore
vendored
Normal file
5
dx5sdk/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
inc/
|
||||
lib/
|
||||
samples/
|
||||
bin/
|
||||
readme.txt
|
||||
Loading…
Reference in New Issue
Block a user