File Index Symbol Index

#include "WindowsInputService.h"
namespace
vl
{
namespace
presentation
{
namespace
windows
{
bool
WinIsKeyPressing
(
VKEY
code
) {
return
(
GetKeyState
((
int
)
code
)&
0xF0
)!=
0
; }
bool
WinIsKeyToggled
(
VKEY
code
) {
return
(
GetKeyState
((
int
)
code
)&
0x0F
)!=
0
; }
/*********************************************************************** WindowsInputService ***********************************************************************/
WString
WindowsInputService
::
GetKeyNameInternal
(
VKEY
code
) {
if
((
vint
)
code
<
8
)
return
L"?"
;
wchar_t
name
[
256
]={
0
};
switch
((
vint
)
code
) {
scanCode
|=
1
<<
24
;
break
;
return
L"?"
; }
return
name
[
0
]?
name
:
L"?"
; }
void
WindowsInputService
::
InitializeKeyNames
() {
for
(
vint
i
=
0
;
i
<
keyNames
.
Count
();
i
++) {
keyNames
[
i
]
=
GetKeyNameInternal
((
VKEY
)
i
);
if
(
keyNames
[
i
] !=
L"?"
) {
keys
.
Set
(
keyNames
[
i
], (
VKEY
)
i
); } } }
WindowsInputService
::
WindowsInputService
() ,isTimerEnabled(
false
) ,keyNames(
146
) {
InitializeKeyNames
(); }
void
WindowsInputService
::
SetOwnerHandle
(
HWND
handle
) {
ownerHandle
=
handle
; }
void
WindowsInputService
::
StartTimer
() {
if
(!
IsTimerEnabled
()) {
isTimerEnabled
=
true
; } }
void
WindowsInputService
::
StopTimer
() {
if
(
IsTimerEnabled
()) {
KillTimer
(
ownerHandle
,
1
);
isTimerEnabled
=
false
; } }
bool
WindowsInputService
::
IsTimerEnabled
() {
return
isTimerEnabled
; }
bool
WindowsInputService
::
IsKeyPressing
(
VKEY
code
) {
return
WinIsKeyPressing
(
code
); }
bool
WindowsInputService
::
IsKeyToggled
(
VKEY
code
) {
return
WinIsKeyToggled
(
code
); }
WString
WindowsInputService
::
GetKeyName
(
VKEY
code
) {
if
(
0
<= (
vint
)
code
&& (
vint
)
code
<
keyNames
.
Count
()) {
return
keyNames
[
(
vint
)
code
]; }
else
{
return
L"?"
; } }
VKEY
WindowsInputService
::
GetKey
(
const
WString
&
name
) {
vint
index
=
keys
.
Keys
().
IndexOf
(
name
);
return
index
== -
1
?
VKEY
::
_UNKNOWN
:
keys
.
Values
()
[
index
]; } } } }