static int process_event(struct input_event *event) { if (event->type != EV_KEY) return 0; if (event->value == KEYHOLD && keystate.hold.num_active && modifiable(event->code)) return 0; add_key_to_queue(event->code, event->value); if (!modifiable(event->code)) { flush_queue(ACTION_NONE, 0); keystate.tap.code = event->code; keystate.hold.code = event->code; return 0; } switch (event->value) { case KEYDOWN: cancel_hold_timeout(); if (keystate.tap.code == event->code && within_tap_threshold(event)) { if (keystate.tap.state == STATE_IDLE) { syslog(LOG_WARNING, "Missed tap action due to timeout"); } else { tap_action(); memcpy(&keystate.tap.time, &event->time, sizeof keystate.tap.time); } } else { flush_queue(ACTION_NONE, 0); if (keystate.hold.num_active) { keystate.hold.code = event->code; start_hold_timeout(); } if (keystate.tap.num_active) { keystate.tap.code = event->code; memcpy(&keystate.tap.time, &event->time, sizeof keystate.tap.time); start_tap_timeout(); } } break; case KEYUP: cancel_hold_timeout(); if (keystate.tap.code != event->code || keystate.tap.state == STATE_IDLE) { flush_queue(ACTION_NONE, 0); stop_tap(); } break; case KEYHOLD: if (!keystate.hold.num_active) { stop_tap(); flush_queue(ACTION_NONE, 0); } break; default: break; } return 0; }
void UString::append( const UString & other ) { if ( !other.length() ) return; if ( !length() && ( !modifiable() || d->max < other.length() ) ) { // if this isn't modifiable, we just make a copy of the other // string. only sensible thing to do. if it's modifiable, but // we don't have enough bytes, we also just glue ourselves // onto the other. maybe we'll need to copy later, but maybe // not. *this = other; return; } reserve( length() + other.length() ); memmove( d->str+d->len, other.d->str, sizeof(uint)*other.d->len ); d->len += other.d->len; }