Home | History | Annotate | Download | only in event_injector

Lines Matching refs:con

83 emulatorConsole_eatInput( EmulatorConsole* con )
87 int ret = socket_recv(con->fd, temp, sizeof temp);
102 emulatorConsole_sendOutput( EmulatorConsole* con )
104 if (con->state != STATE_CONNECTED) {
109 while (con->out_msg != NULL) {
110 Msg* msg = con->out_msg;
113 ret = socket_send(con->fd,
121 con->out_msg = msg->next;
129 con->state = STATE_ERROR;
133 iolooper_del_write(con->looper, con->fd);
138 emulatorConsole_completeConnect(EmulatorConsole* con)
141 iolooper_add_read(con->looper, con->fd);
142 iolooper_del_write(con->looper, con->fd);
143 con->state = STATE_CONNECTED;
144 if (con->out_msg != NULL) {
145 iolooper_add_write(con->looper, con->fd);
146 emulatorConsole_sendOutput(con);
151 emulatorConsole_retry(EmulatorConsole* con)
155 con->state = STATE_WAITING;
156 con->waitUntil = iolooper_now() + 5000;
160 emulatorConsole_connect(EmulatorConsole* con)
163 if (con->fd < 0) {
164 con->fd = socket_create_inet( SOCKET_STREAM );
165 if (con->fd < 0) {
167 con->state = STATE_ERROR;
170 socket_set_nonblock(con->fd);
172 con->state = STATE_CONNECTING;
173 if (socket_connect(con->fd, &con->address) < 0) {
175 iolooper_add_write(con->looper, con->fd);
177 emulatorConsole_retry(con);
182 emulatorConsole_completeConnect(con);
186 emulatorConsole_reset( EmulatorConsole* con )
189 while (con->out_msg) {
190 Msg* msg = con->out_msg;
191 con->out_msg = msg->next;
194 iolooper_del_read(con->looper, con->fd);
195 iolooper_del_write(con->looper, con->fd);
196 socket_close(con->fd);
197 con->fd = -1;
198 emulatorConsole_connect(con);
208 EmulatorConsole* con;
211 ANEW0(con);
212 con->looper = looper;
213 con->fd = -1;
214 sock_address_init_inet(&con->address, SOCK_ADDRESS_INET_LOOPBACK, port);
216 emulatorConsole_connect(con);
217 return con;
221 emulatorConsole_poll( EmulatorConsole* con )
225 if (con->state == STATE_WAITING) {
226 if (iolooper_now() >= con->waitUntil)
227 emulatorConsole_connect(con);
231 if (!iolooper_is_read(con->looper, con->fd) &&
232 !iolooper_is_write(con->looper, con->fd))
238 switch (con->state) {
244 if (socket_get_error(con->fd) != 0) {
245 emulatorConsole_retry(con);
247 emulatorConsole_completeConnect(con);
253 if (iolooper_is_read(con->looper, con->fd)) {
254 if (emulatorConsole_eatInput(con) < 0) {
259 if (iolooper_is_write(con->looper, con->fd)) {
260 if (emulatorConsole_sendOutput(con) < 0) {
273 con->state = STATE_ERROR;
274 emulatorConsole_reset(con);
281 emulatorConsole_send( EmulatorConsole* con, const char* command )
292 plast = &con->out_msg;
297 if (con->out_msg == msg) {
298 iolooper_add_write(con->looper, con->fd);
300 emulatorConsole_sendOutput(con);
305 emulatorConsole_sendMouseDown( EmulatorConsole* con, int x, int y )
313 emulatorConsole_send(con, temp);
317 emulatorConsole_sendMouseMotion( EmulatorConsole* con, int x, int y )
320 emulatorConsole_sendMouseDown(con, x, y);
324 emulatorConsole_sendMouseUp( EmulatorConsole* con, int x, int y )
332 emulatorConsole_send(con, temp);
338 emulatorConsole_sendKey( EmulatorConsole* con, int keycode, int down )
344 emulatorConsole_send(con, temp);