ReactOS 0.4.15-dev-7842-g558ab78
KeyTranslator Class Reference

#include <keytrans.h>

Collaboration diagram for KeyTranslator:

Public Member Functions

 KeyTranslator ()
 
 ~KeyTranslator ()
 
int SwitchTo (int)
 
int switchMap (TKeyDef &tk)
 
const charTranslateKey (WORD wVirtualKeyCode, DWORD dwControlKeyState)
 
int AddKeyDef (WORD wVirtualKeyCode, DWORD dwControlKeyState, char *lpzKeyDef)
 
int AddKeyDef (WORD wVirtualKeyCode, DWORD dwControlKeyState, tn_ops op)
 
int DeleteKeyDef (WORD wVirtualKeyCode, DWORD dwControlKeyState)
 
void set_ext_mode (DWORD mode)
 
void unset_ext_mode (DWORD mode)
 
void clear_ext_mode ()
 
DWORD get_ext_mode ()
 

Private Member Functions

DWORD Fix_ControlKeyState (char *)
 
charFix_Tok (char *)
 
void DeleteAllDefs (void)
 
int AddGlobalDef (WORD wVirtualKeyCode, char *lpzKeyDef)
 
int LookOnGlobal (char *vkey)
 
DWORD GetGlobalCode (int i)
 

Private Attributes

DWORD ext_mode
 
TArrayAsVector< KeyMapmapArray
 
TArrayAsVector< TKeyDefglobals
 
int currentKeyMap
 
int mainKeyMap
 

Friends

class TMapLoader
 

Detailed Description

Definition at line 51 of file keytrans.h.

Constructor & Destructor Documentation

◆ KeyTranslator()

KeyTranslator::KeyTranslator ( )

Definition at line 58 of file keytrans.cpp.

58 :
59mapArray(0,0,sizeof(KeyMap)),
60globals(0,0,sizeof(TKeyDef)) {
61 ext_mode = 0; // Paul Brannan 8/28/98
63};
int currentKeyMap
Definition: keytrans.h:92
TArrayAsVector< KeyMap > mapArray
Definition: keytrans.h:84
int mainKeyMap
Definition: keytrans.h:92
DWORD ext_mode
Definition: keytrans.h:82
TArrayAsVector< TKeyDef > globals
Definition: keytrans.h:85
Definition: tkeymap.h:17

◆ ~KeyTranslator()

KeyTranslator::~KeyTranslator ( )
inline

Definition at line 55 of file keytrans.h.

55{ DeleteAllDefs(); }
void DeleteAllDefs(void)
Definition: keytrans.cpp:193

Member Function Documentation

◆ AddGlobalDef()

int KeyTranslator::AddGlobalDef ( WORD  wVirtualKeyCode,
char lpzKeyDef 
)
private

Definition at line 160 of file keytrans.cpp.

160 {
161 if ( ! globals.IsEmpty() ) {
163 for ( int i = 0; i < max ; i++ ) {
164 const char *s = globals[i].GetszKey();
165 if ( stricmp(s, lpzKeyDef) == 0 ) {
166 globals[i] = DWORD(wVirtualKeyCode);
167 return 1;
168 }
169 }
170 }
171 return globals.Add( TKeyDef(lpzKeyDef, 0, wVirtualKeyCode));
172}
int IsEmpty()
Definition: stl_bids.h:104
int Add(const T &item)
Definition: stl_bids.h:38
size_type GetItemsInContainer()
Definition: stl_bids.h:88
#define stricmp(_String1, _String2)
Definition: compat.h:24
GLdouble s
Definition: gl.h:2039
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DWORD
Definition: nt_native.h:44
#define max(a, b)
Definition: svc.c:63

Referenced by TMapLoader::LoadGlobal().

◆ AddKeyDef() [1/2]

int KeyTranslator::AddKeyDef ( WORD  wVirtualKeyCode,
DWORD  dwControlKeyState,
char lpzKeyDef 
)

Definition at line 119 of file keytrans.cpp.

121{
122 if ( ! mapArray[currentKeyMap].map.IsEmpty() ) {
123 int i = mapArray[currentKeyMap].map.Find(TKeyDef(NULL, dwControlKeyState, wVirtualKeyCode));
124 if ( i != INT_MAX) {
125 mapArray[currentKeyMap].map[i] = lpzKeyDef;
126 return 1;
127 }
128 };
129 return mapArray[currentKeyMap].map.Add( TKeyDef(lpzKeyDef, dwControlKeyState, wVirtualKeyCode));
130}
size_type Find(const T &item) const
Definition: stl_bids.h:79
Definition: _map.h:48
#define NULL
Definition: types.h:112
#define INT_MAX
Definition: limits.h:40

Referenced by TMapLoader::LoadKeyMap().

◆ AddKeyDef() [2/2]

int KeyTranslator::AddKeyDef ( WORD  wVirtualKeyCode,
DWORD  dwControlKeyState,
tn_ops  op 
)

Definition at line 133 of file keytrans.cpp.

135{
136 optype op;
137 op.sendstr = 0;
138 op.the_op = the_op;
139 if ( ! mapArray[currentKeyMap].map.IsEmpty() ) {
140 int i = mapArray[currentKeyMap].map.Find(TKeyDef(NULL, dwControlKeyState, wVirtualKeyCode));
141 if ( i != INT_MAX) {
142 mapArray[currentKeyMap].map[i] = op;
143 return 1;
144 }
145 };
146 return mapArray[currentKeyMap].map.Add( TKeyDef(op, dwControlKeyState, wVirtualKeyCode));
147}
UINT op
Definition: effect.c:236
Definition: tkeydef.h:21

◆ clear_ext_mode()

void KeyTranslator::clear_ext_mode ( )
inline

Definition at line 76 of file keytrans.h.

76{ext_mode = 0;}

Referenced by TANSIParser::Init().

◆ DeleteAllDefs()

void KeyTranslator::DeleteAllDefs ( void  )
private

Definition at line 193 of file keytrans.cpp.

194{
195 // This code wants to crash under the STL; Apparently the Destroy()
196 // function actually deletes the entry, rather than simply releasing
197 // memory. I think flush() should do the same thing, at least the
198 // way it is written with STL_BIDS (Paul Brannan 5/25/98).
199 int max;
200
202 if ( ! mapArray.IsEmpty() ) {
203 for ( int i = 0; i < max; i++ ) {
204 if ( !mapArray[i].map.IsEmpty() ) {
205 mapArray[i].map.Flush();
206 };
207 };
208 };
209 globals.Flush();
210 mapArray.Flush();
211 currentKeyMap = -1;
212 mainKeyMap = -1;
213};
void Flush()
Definition: stl_bids.h:126

Referenced by TMapLoader::Load(), and ~KeyTranslator().

◆ DeleteKeyDef()

int KeyTranslator::DeleteKeyDef ( WORD  wVirtualKeyCode,
DWORD  dwControlKeyState 
)

Definition at line 177 of file keytrans.cpp.

178{
180 return 0;
181
182 int i = mapArray[currentKeyMap].map.Find(TKeyDef(NULL, dwControlKeyState, wVirtualKeyCode));
183
184 if ( i != INT_MAX) {
186 return 1;
187 };
188 return 0;
189};
void Destroy(size_type index)
Definition: stl_bids.h:73

◆ Fix_ControlKeyState()

DWORD KeyTranslator::Fix_ControlKeyState ( char )
private

◆ Fix_Tok()

char * KeyTranslator::Fix_Tok ( char )
private

◆ get_ext_mode()

DWORD KeyTranslator::get_ext_mode ( )
inline

Definition at line 77 of file keytrans.h.

77{return ext_mode;}

Referenced by FindClosestKey().

◆ GetGlobalCode()

DWORD KeyTranslator::GetGlobalCode ( int  i)
inlineprivate

Definition at line 90 of file keytrans.h.

90{return globals[i].GetCodeKey();}

Referenced by TMapLoader::LoadKeyMap(), and TMapLoader::ParseKeyDef().

◆ LookOnGlobal()

int KeyTranslator::LookOnGlobal ( char vkey)
private

Definition at line 150 of file keytrans.cpp.

150 {
151 if ( ! globals.IsEmpty() ) {
153 for ( int i = 0; i < max ; i++ )
154 if ( stricmp(globals[i].GetszKey(), vkey) == 0 )
155 return i;
156 };
157 return INT_MAX;
158};

Referenced by TMapLoader::LoadKeyMap(), and TMapLoader::ParseKeyDef().

◆ set_ext_mode()

void KeyTranslator::set_ext_mode ( DWORD  mode)
inline

Definition at line 74 of file keytrans.h.

74{ext_mode |= mode;}
GLenum mode
Definition: glext.h:6217

Referenced by TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

◆ switchMap()

int KeyTranslator::switchMap ( TKeyDef tk)

Definition at line 67 of file keytrans.cpp.

67 {
68 if ( mapArray.IsEmpty() ) {
69 return currentKeyMap = -1;
70 };
71 int i = mapArray.Find(KeyMap(tk));
72 if ( i != INT_MAX ) {
73 if (currentKeyMap == i)
74 currentKeyMap = mainKeyMap; // restore to default
75 else currentKeyMap = i;
76 return 1;
77 };
78 return 0;
79};

Referenced by TMapLoader::Load(), and TranslateKey().

◆ SwitchTo()

int KeyTranslator::SwitchTo ( int  to)

Definition at line 82 of file keytrans.cpp.

82 {
83
85 if (max == 0) return -1;
86 if (to < 0 || to > (max-1)) return 0;
87
88 currentKeyMap = to;
89 return 1;
90};

Referenced by Telnet::SwitchKeyMap().

◆ TranslateKey()

const char * KeyTranslator::TranslateKey ( WORD  wVirtualKeyCode,
DWORD  dwControlKeyState 
)

Definition at line 94 of file keytrans.cpp.

96{
97 if ( mapArray.IsEmpty() ) return NULL;
98
99 TKeyDef ask(NULL, dwControlKeyState, wVirtualKeyCode);
100
101 // if a keymap switch pressed
102 if ( switchMap(ask) > 0 ) return "";
103
104 int i = mapArray[currentKeyMap].map.Find(ask);
105
106 if ( i != INT_MAX) return mapArray[currentKeyMap].map[i].GetszKey();
107
108 // if not found in current keymap
109 if ( currentKeyMap != mainKeyMap ) {
110 i = mapArray[mainKeyMap].map.Find(ask);
111 if ( i != INT_MAX) return mapArray[mainKeyMap].map[i].GetszKey();
112 };
113 return NULL;
114};
int switchMap(TKeyDef &tk)
Definition: keytrans.cpp:67

Referenced by ClosestStateKey().

◆ unset_ext_mode()

void KeyTranslator::unset_ext_mode ( DWORD  mode)
inline

Definition at line 75 of file keytrans.h.

75{ext_mode &= ~mode;}

Referenced by TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

Friends And Related Function Documentation

◆ TMapLoader

friend class TMapLoader
friend

Definition at line 52 of file keytrans.h.

Member Data Documentation

◆ currentKeyMap

int KeyTranslator::currentKeyMap
private

◆ ext_mode

DWORD KeyTranslator::ext_mode
private

Definition at line 82 of file keytrans.h.

Referenced by clear_ext_mode(), get_ext_mode(), KeyTranslator(), set_ext_mode(), and unset_ext_mode().

◆ globals

TArrayAsVector<TKeyDef> KeyTranslator::globals
private

Definition at line 85 of file keytrans.h.

Referenced by AddGlobalDef(), DeleteAllDefs(), GetGlobalCode(), and LookOnGlobal().

◆ mainKeyMap

int KeyTranslator::mainKeyMap
private

Definition at line 92 of file keytrans.h.

Referenced by DeleteAllDefs(), KeyTranslator(), TMapLoader::Load(), switchMap(), and TranslateKey().

◆ mapArray

TArrayAsVector<KeyMap> KeyTranslator::mapArray
private

The documentation for this class was generated from the following files: