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
|
# File 'lib/MINT-core/model/ir/mouse_old.rb', line 48
def initialize_statemachine
if @statemachine.blank?
@pointer_timer = nil
@wheel_timer = nil
@statemachine = Statemachine.build do
trans :disconnected,:connect, :connected
trans :connected, :disconnect, :disconnected
superstate :connected do
parallel :p do
statemachine :s1 do
superstate :pointer do
on_entry :start_coordinates_tracker
on_exit :stop_coordinates_tracker
trans :stopped, :move, :moving
trans :moving,:move, :moving
trans :moving,:stop,:stopped
state :moving do
on_entry :start_timeout_pointer on_exit :stop_timeout_pointer
end
end
end
statemachine :s2 do
superstate :right_button do trans :right_released, :right_press, :right_pressed
trans :right_pressed, :right_release, :right_released
end
end
statemachine :s3 do
superstate :left_button do trans :left_released, :left_press, :left_pressed
trans :left_pressed, :left_release, :left_released
end
end
statemachine :s4 do
superstate :middle_button do trans :middle_released, :middle_press, :middle_pressed
trans :middle_pressed, :middle_release, :middle_released
end
end
statemachine :s5 do
superstate :wheel do
trans :wheel_stopped,:regress, :regressing
trans :wheel_stopped,:progress, :progressing
trans :regressing, :regress, :regressing
trans :regressing, :stop_wheel, :wheel_stopped
trans :regressing, :progress, :progressing
trans :progressing, :progress, :progressing
trans :progressing, :stop_wheel, :wheel_stopped
trans :progressing, :regress, :regressing
state :regressing do
on_entry :start_timeout_wheel
on_exit :stop_timeout_wheel
end
state :progressing do
on_entry :start_timeout_wheel
on_exit :stop_timeout_wheel
end
end
end
end
end
end
end
def start_timeout_wheel
if not @wheel_timer
@wheel_timer = EventMachine::Timer.new(0.3) do
process_event("stop_wheel")
end
else
puts "wheel timer already started!!!"
end
end
def stop_timeout_wheel
stop_timeout(@wheel_timer)
end
def start_timeout_pointer
if not @pointer_timer
@pointer_timer = EventMachine::Timer.new(0.3) do
@mouse.x=@x
@mouse.y=@y
@mouse.process_event("stop")
end
else
puts "pointer timer already started!!!"
end
end
def stop_timeout_pointer
stop_timeout(@pointer_timer)
end
def stop_timeout(timer)
if timer
timer.cancel
timer = nil
end
end
end
|