summaryrefslogtreecommitdiff
path: root/src/ControllerConfig.cpp
blob: 10997bcecad983f923f92080fd65d569ecde5733 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	#define DIRECTINPUT_VERSION 0x0800
	#include <dinput.h>
#include "common.h"
#include "patcher.h"
#include "ControllerConfig.h"
#include "Pad.h"
#include "FileMgr.h"

CControllerConfigManager &ControlsManager = *(CControllerConfigManager*)0x8F43A4;

WRAPPER void CControllerConfigManager::UpdateJoyButtonState(int padnumber) { EAXJMP(0x58F5B0); }
WRAPPER void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown(int button, int padnumber) { EAXJMP(0x58C5E0); }
WRAPPER void CControllerConfigManager::AffectControllerStateOn_ButtonDown(int button, eControllerType type) { EAXJMP(0x58C730); }
WRAPPER void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonUp(int button, int padnumber) { EAXJMP(0x58CE80); }
WRAPPER void CControllerConfigManager::AffectControllerStateOn_ButtonUp(int button, int padnumber) { EAXJMP(0x58CFD0); }
WRAPPER void CControllerConfigManager::MakeControllerActionsBlank() { EAXJMP(0x58B7A0); }
WRAPPER void CControllerConfigManager::InitDefaultControlConfiguration() { EAXJMP(0x58B930); }
WRAPPER void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerState const &mousestate) { EAXJMP(0x58BD00); }
WRAPPER Int32 CControllerConfigManager::GetJoyButtonJustDown() { EAXJMP(0x58B7D0); }

void CControllerConfigManager::LoadSettings(Int32 file)
{
	Bool bValid = true;
	
	if ( file )
	{
		Char buff[29];
		CFileMgr::Read(file, buff, sizeof(buff));
		
		if ( !strncmp(buff, "THIS FILE IS NOT VALID YET", sizeof(buff) - 3) )
			bValid = false;
		else
			CFileMgr::Seek(file, 0, 0);
	}
	
	if ( bValid )
	{
		ControlsManager.MakeControllerActionsBlank();
		
		for ( int i = 0; i < 4; i++ )
		{
			for ( int j = 0; j < 41; j++ )
			{
				CFileMgr::Read(file, (Char *)&ControlsManager.m_aSettings[j][i], sizeof(tControllerConfigBind));
			}
		}
	}
}