[添付ファイル一覧]
[全ページの添付ファイル一覧]
- mousegesture.cpp
- 格納ファイル名:attach/446576656C6F702F34_6D6F757365676573747572652E637070
- ページ:Develop/4
- 格納ファイル名:attach/446576656C6F702F34_6D6F757365676573747572652E637070
- MD5ハッシュ値:6369028fa109d4b5cca3181cac045d7b
- サイズ:4.8KB (4937 bytes)
- Content-type:application/octet-stream
- 登録日時:2006/12/18 21:26:50
- アクセス数:293
- MD5ハッシュ値:6369028fa109d4b5cca3181cac045d7b
0
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
| |
#define MG_BUFFER_SIZE 16
#define MG_CMD_MAX 32
#define MG_RANGE 32
#define MG_RIGHT 1
#define MG_DOWN 2
#define MG_LEFT 3
#define MG_UP 4
typedef struct{
int FuncCode;
int BufferLength;
short Buffer[MG_BUFFER_SIZE];
}MG_CMD;
POINT MG_pos;
int MG_IsGesture;
int MG_BufferLength;
short MG_Buffer[MG_BUFFER_SIZE];
MG_CMD MG_CMD_LIST[MG_CMD_MAX];
void MouseGesture_Start( int xPos, int yPos );
void MouseGesture_Execute( int xPos, int yPos );
bool MouseGesture_Finish();
int MouseGesture_Check( MG_CMD *MG_Command );
bool MouseGesture_IsGesture();
void MouseGesture_Start( int xPos, int yPos )
{
MG_pos.x = xPos;
MG_pos.y = yPos;
MG_IsGesture = true;
MG_BufferLength = 0;
memset( MG_Buffer, 0, sizeof(short)*MG_BUFFER_SIZE );
}
void MouseGesture_Execute( int xPos, int yPos )
{
int xlen = xPos - MG_pos.x;
int ylen = yPos - MG_pos.y;
int arrow = 0;
if( xlen > MG_RANGE ){
arrow = MG_RIGHT;
}else
if( ylen > MG_RANGE ){
arrow = MG_DOWN;
}else
if( xlen < -MG_RANGE ){
arrow = MG_LEFT;
}else
if( ylen < -MG_RANGE ){
arrow = MG_UP;
}
if( arrow ){
MG_pos.x = xPos;
MG_pos.y = yPos;
if( !(MG_BufferLength && MG_Buffer[ MG_BufferLength-1 ] == arrow) ){
if( MG_BufferLength < MG_BUFFER_SIZE ){
MG_Buffer[ MG_BufferLength++ ] = arrow;
MG_CMD *MG_Command = NULL;
MouseGesture_Check( MG_Command );
if( MG_Command ){
}
}
}
}
}
bool MouseGesture_Finish()
{
if( MG_IsGesture ){
MG_IsGesture = false;
MG_CMD *MG_Command = NULL;
if( MouseGesture_Check( MG_Command ) ){
return true;
}
}
return false;
}
bool MouseGesture_IsGesture()
{
return MG_IsGesture;
}
int MouseGesture_Check( MG_CMD *MG_Command )
{
int i;
int ret = false;
for( i = 0; i < MG_CMD_MAX; i++ ){
if( !MG_CMD_LIST[i].BufferLength ){
break;
}
if( MG_BufferLength == MG_CMD_LIST[i].BufferLength ){
if( !memcmp( MG_Buffer, MG_CMD_LIST[i].Buffer, sizeof(short)*MG_BufferLength ) ){
if( MG_Command ){
MG_Command = &MG_CMD_LIST[i];
}
ret = true;
break;
}
}
}
return ret;
}
|