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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//===========================================================================//
#include "inputsystem.h"
#include "key_translation.h"
#include "inputsystem/ButtonCode.h"
#include "inputsystem/AnalogCode.h"
#include "tier1/convar.h"
typedef void*(*NovintGetIHaptics_t)(void);
typedef bool (*NovintAttemptHWND_t)(void *hWnd);
typedef void (*NovintDisableHWND_t)(void);
typedef void (*NovintPollDevices_t)(void);
typedef bool (*NovintButtonState_t)(int nDevice,
int &down,
int &pressed,
int &released);
typedef int (*NovintDeviceCount_t)();
typedef int (*NovintButtonCount_t)(int nDevice);
typedef bool (__cdecl *NovintMouseModeCallback_t) (void);
typedef void (*NovintInputActive_t)(bool bGameInput);
typedef __int64 (*NovintGetDeviceID_t)(int nDevice);
NovintGetIHaptics_t NovintGetIHaptics = NULL;
NovintAttemptHWND_t NovintAttemptHWND = NULL;
NovintDisableHWND_t NovintDisableHWND = NULL;
NovintPollDevices_t NovintPollDevices = NULL;
NovintButtonState_t NovintButtonState = NULL;
NovintDeviceCount_t NovintDeviceCount = NULL;
NovintButtonCount_t NovintButtonCount = NULL;
NovintInputActive_t NovintInputActive = NULL;
NovintGetDeviceID_t NovintGetDeviceID = NULL;
static CInputSystem *pNovintInputSystem = 0;
static bool bNovintPure = false;
bool __cdecl NovintDevicesInputMode(void)
{
if(pNovintInputSystem)
{
return !bNovintPure;
}
return false;
}
void *CInputSystem::GetHapticsInterfaceAddress(void)const
{
if( NovintGetIHaptics )
return NovintGetIHaptics();
return NULL;
}
void CInputSystem::AttachWindowToNovintDevices( void * hWnd )
{
if( NovintAttemptHWND )
NovintAttemptHWND( hWnd );
}
void CInputSystem::DetachWindowFromNovintDevices(void)
{
if( NovintDisableHWND )
NovintDisableHWND();
}
void CInputSystem::InitializeNovintDevices()
{
pNovintInputSystem = this;
// assume no novint devices
m_bNovintDevices = false;
m_nNovintDeviceCount = 0;
if(!m_pNovintDLL)
return;
NovintGetIHaptics = (NovintGetIHaptics_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintGetIHaptics" );
NovintAttemptHWND = (NovintAttemptHWND_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintAttemptHWND" );
NovintDisableHWND = (NovintDisableHWND_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintDisableHWND" );
NovintPollDevices = (NovintPollDevices_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintPollDevices" );
NovintButtonState = (NovintButtonState_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintButtonState" );
NovintDeviceCount = (NovintDeviceCount_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintDeviceCount" );
NovintButtonCount = (NovintButtonCount_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintButtonCount" );
NovintGetDeviceID = (NovintGetDeviceID_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintGetDeviceID" );
NovintInputActive = (NovintInputActive_t)GetProcAddress( (HMODULE)m_pNovintDLL, "NovintInputActive" );
m_nNovintDeviceCount = NovintDeviceCount();
if( m_nNovintDeviceCount > 0 )
m_bNovintDevices = true;
}
void CInputSystem::PollNovintDevices()
{
if( NovintPollDevices )
NovintPollDevices();
for ( int i = 0; i < m_nNovintDeviceCount; i++ )
{
UpdateNovintDeviceButtonState(i);
}
}
void CInputSystem::UpdateNovintDeviceButtonState(int nDevice)
{
int nDown;
int nPressed;
int nReleased;
if(NovintButtonState(nDevice, nDown, nPressed, nReleased))
{
for ( int i = 0; i < 4; i++ )
{
ButtonCode_t code = (ButtonCode_t)( NOVINT_FIRST + ( nDevice * 4 ) + i );
if( nPressed & (1 << i) )
{
PostButtonPressedEvent(IE_ButtonPressed, m_nLastSampleTick, code, KEY_NONE);
}
if( nReleased & (1 << i) )
{
PostButtonReleasedEvent(IE_ButtonReleased, m_nLastSampleTick, code, KEY_NONE);
}
}
}
}
void CInputSystem::SetNovintPure( bool bPure )
{
bNovintPure = bPure;
if(NovintInputActive)
NovintInputActive(bNovintPure);
}
|