static void clutter_input_device_evdev_process_kbd_a11y_event (ClutterEvent *event, ClutterInputDevice *device, ClutterEmitInputDeviceEvent emit_event_func) { ClutterInputDeviceEvdev *device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (device); /* Ignore key events injected from IM */ if (event->key.flags & CLUTTER_EVENT_FLAG_INPUT_METHOD) goto emit_event; if (device_evdev->a11y_flags & CLUTTER_A11Y_KEYBOARD_ENABLED) { if (event->type == CLUTTER_KEY_PRESS) handle_enablekeys_press (event, device_evdev); else handle_enablekeys_release (event, device_evdev); } if (device_evdev->a11y_flags & CLUTTER_A11Y_MOUSE_KEYS_ENABLED) { if (event->type == CLUTTER_KEY_PRESS && handle_mousekeys_press (event, device_evdev)) return; /* swallow event */ if (event->type == CLUTTER_KEY_RELEASE && handle_mousekeys_release (event, device_evdev)) return; /* swallow event */ } if ((device_evdev->a11y_flags & CLUTTER_A11Y_BOUNCE_KEYS_ENABLED) && (get_debounce_delay (device) != 0)) { if ((event->type == CLUTTER_KEY_PRESS) && debounce_key (event, device_evdev)) { notify_bounce_keys_reject (device_evdev); return; } else if (event->type == CLUTTER_KEY_RELEASE) start_bounce_keys (event, device_evdev); } if ((device_evdev->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_ENABLED) && (get_slow_keys_delay (device) != 0)) { if (event->type == CLUTTER_KEY_PRESS) start_slow_keys (event, device_evdev, emit_event_func); else if (event->type == CLUTTER_KEY_RELEASE) stop_slow_keys (event, device_evdev, emit_event_func); return; } if (device_evdev->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_ENABLED) { if (event->type == CLUTTER_KEY_PRESS) handle_stickykeys_press (event, device_evdev); else if (event->type == CLUTTER_KEY_RELEASE) handle_stickykeys_release (event, device_evdev); } emit_event: emit_event_func (event, device); }
void main() { int state; long timeout; int bytes_read; static char buffer[64]; static tcp_Socket socket; // Initialize I/O to use PowerCoreFLEX prototyping board brdInit(); serXopen(BAUD_RATE); // set up serial port serMode(0); sock_init(); // initialize DCRTCP tcp_reserveport(PORT); // set up PORT for SYN Queueing // which will hold a pending connection // until we are ready to process it. state=CONNECTION_INIT; while(1) { if(state==CONNECTION_OPEN) { if(debounce_key()) { sock_close(&socket); state=CONNECTION_CLOSED; } } /* * Make sure that the connection hasn't closed on us. * */ if(tcp_tick(&socket)==0 && state!=CONNECTION_INIT) { sock_close(&socket); state=CONNECTION_CLOSED; } switch(state) { case CONNECTION_INIT: tcp_listen(&socket,PORT,0,0,NULL,0); state=CONNECTION_LISTEN; break; case CONNECTION_LISTEN: if(sock_established(&socket)) { state=CONNECTION_OPEN; timeout=SEC_TIMER+TIMEOUT; serXrdFlush(); serXwrFlush(); led(RESET_LED); } break; case CONNECTION_OPEN: /* * close the socket on a timeout * */ if((long) (SEC_TIMER-timeout) >= 0) { sock_close(&socket); state=CONNECTION_CLOSED; break; } /* * read as many bytes from the socket as we have * room in the serial buffer. Also strip out the * telnet commands. */ bytes_read = 0; if(sock_bytesready(&socket) != -1) { bytes_read=sock_fastread(&socket, buffer, min(sizeof(buffer), serXwrFree())); bytes_read=strip_telnet_cmds(buffer, bytes_read); } /* * close the socket on an error * */ if(bytes_read<0) { sock_close(&socket); state=CONNECTION_CLOSED; break; } /* * copy any bytes that we read * */ if(bytes_read > 0) { timeout=SEC_TIMER+TIMEOUT; serXwrite(buffer, bytes_read); } /* * read as many bytes from the serial port as we * have room in the socket buffer. * */ bytes_read=serXread(buffer,min(sizeof(buffer),sock_tbleft(&socket)),100); if(bytes_read>0) { timeout=SEC_TIMER+TIMEOUT; if(sock_fastwrite(&socket,buffer,bytes_read)<0) { sock_close(&socket); state=CONNECTION_CLOSED; } } led(TOGGLE_LED); break; case CONNECTION_CLOSED: serXrdFlush(); serXwrFlush(); sprintf(buffer, "\n\rConnection closed\n\r"); serXwrite(buffer, strlen(buffer)); led(RESET_LED); state=CONNECTION_INIT; break; } } }