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
139
140
141
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#include "movieobjects/dmekeyboardinput.h"
#include "movieobjects_interfaces.h"
#include "datamodel/dmelementfactoryhelper.h"
#include "vgui/iinput.h"
#include "vgui/keycode.h"
#include "tier3/tier3.h"
#include "tier0/dbg.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// global list of all keys supported
//-----------------------------------------------------------------------------
struct KeyInfo
{
vgui::KeyCode code;
const char *str;
};
const uint g_nKeys = 48;
const KeyInfo g_keyInfo[ g_nKeys ] =
{
{ KEY_0, "0" },
{ KEY_1, "1" },
{ KEY_2, "2" },
{ KEY_3, "3" },
{ KEY_4, "4" },
{ KEY_5, "5" },
{ KEY_6, "6" },
{ KEY_7, "7" },
{ KEY_8, "8" },
{ KEY_9, "9" },
{ KEY_A, "A" },
{ KEY_B, "B" },
{ KEY_C, "C" },
{ KEY_D, "D" },
{ KEY_E, "E" },
{ KEY_F, "F" },
{ KEY_G, "G" },
{ KEY_H, "H" },
{ KEY_I, "I" },
{ KEY_J, "J" },
{ KEY_K, "K" },
{ KEY_L, "L" },
{ KEY_M, "M" },
{ KEY_N, "N" },
{ KEY_O, "O" },
{ KEY_P, "P" },
{ KEY_Q, "Q" },
{ KEY_R, "R" },
{ KEY_S, "S" },
{ KEY_T, "T" },
{ KEY_U, "U" },
{ KEY_V, "V" },
{ KEY_W, "W" },
{ KEY_X, "X" },
{ KEY_Y, "Y" },
{ KEY_Z, "Z" },
{ KEY_F1, "F1" },
{ KEY_F2, "F2" },
{ KEY_F3, "F3" },
{ KEY_F4, "F4" },
{ KEY_F5, "F5" },
{ KEY_F6, "F6" },
{ KEY_F7, "F7" },
{ KEY_F8, "F8" },
{ KEY_F9, "F9" },
{ KEY_F10, "F10" },
{ KEY_F11, "F11" },
{ KEY_F12, "F12" },
};
//-----------------------------------------------------------------------------
// Expose this class to the scene database
//-----------------------------------------------------------------------------
IMPLEMENT_ELEMENT_FACTORY( DmeKeyboardInput, CDmeKeyboardInput );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDmeKeyboardInput::OnConstruction()
{
m_keys = new CDmaVar< bool >[ g_nKeys ];
for ( uint ki = 0; ki < g_nKeys; ++ki )
{
m_keys[ ki ].Init( this, g_keyInfo[ ki ].str );
}
}
void CDmeKeyboardInput::OnDestruction()
{
delete[] m_keys;
}
bool CDmeKeyboardInput::IsDirty()
{
for ( uint ki = 0; ki < g_nKeys; ++ki )
{
if ( m_keys[ ki ].Get() != GetKeyStatus( ki ) )
return true;
}
return false;
}
void CDmeKeyboardInput::Operate()
{
for ( uint ki = 0; ki < g_nKeys; ++ki )
{
m_keys[ ki ].Set( GetKeyStatus( ki ) );
}
}
void CDmeKeyboardInput::GetInputAttributes( CUtlVector< CDmAttribute * > &attrs )
{
}
void CDmeKeyboardInput::GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs )
{
for ( uint ki = 0; ki < g_nKeys; ++ki )
{
attrs.AddToTail( m_keys[ ki ].GetAttribute() );
}
}
bool CDmeKeyboardInput::GetKeyStatus( uint ki )
{
return g_pVGuiInput->IsKeyDown( g_keyInfo[ ki ].code );
}
|