blob: 1e0ecb89afbb99d632ac32923f0e927c85ddd912 (
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
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
|
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
PURPOSE.
Module Name:
Firefly.c
Abstract:
App to change the tail light state of MS optical mouse with the help of
firefly driver. This app uses WMI interface to talk to the driver.
Environment:
User Mode console application
--*/
#include "luminous.h"
#include <dontuse.h>
#define USAGE \
_T("Usage: Flicker <-0 | -1 | -2>\n\
\t\t-0 turns off light \n\
\t\t-1 turns on light \n\
\t\t-2 flashes light ")
int __cdecl
main(
_In_ ULONG argc,
_In_reads_(argc) PCHAR argv[]
)
{
int i, j, k;
BOOL bAdjustLight = FALSE;
BOOL bSuccessful;
ULONG lightSetting = 0;
CLuminous *luminous;
if (argc == 2) {
if (argv[1][0] == '-') {
if ((argv[1][1] >= '0') && (argv[1][1] <= '2')) {
bAdjustLight = TRUE;
lightSetting = (argv[1][1] - '0');
}
}
}
if (FALSE == bAdjustLight)
{
_tprintf(USAGE);
exit(0);
}
luminous = new CLuminous();
if (luminous == NULL) {
_tprintf(_T("Problem creating Luminous\n"));
return 0;
}
if (!luminous->Open()) {
_tprintf(_T("Problem opening Luminous\n"));
delete(luminous);
return 0;
}
if (bAdjustLight) {
if (lightSetting < 2) {
bSuccessful = luminous->Set((BOOL) lightSetting);
if (bSuccessful) {
_tprintf(_T("Adjusted light to %x\n"), lightSetting);
} else {
_tprintf(_T("Problem occured while adjusting light: %x\n"), GetLastError());
}
} else {
k=0;
j=1;
for(i = 500; (i>0)&&(j>0); i-=j) {
j = (i*9/100);
Sleep(i);
if(!luminous->Set((BOOL) k)) {
_tprintf(_T("Set operation on Luminous failed.\n"));
goto End;
}
k=1-k;
}
for(i = 12; i<500; i+=j) {
j = (i*9/100);
Sleep(i);
if(!luminous->Set((BOOL) k)) {
_tprintf(_T("Set operation on Luminous failed.\n"));
goto End;
}
k=1-k;
}
if (k) {
if(!luminous->Set((BOOL) k)) {
_tprintf(_T("Set operation on Luminous failed.\n"));
}
}
}
}
luminous->Set(TRUE);
End:
luminous->Close();
delete(luminous);
return 0;
}
|