Changeset 5e0acaa in mainline for uspace/srv/hid/remcons/remcons.c


Ignore:
Timestamp:
2024-10-10T11:52:43Z (21 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
fb06afd
Parents:
5f5d375
git-author:
Jiri Svoboda <jiri@…> (2024-10-09 17:46:33)
git-committer:
Jiri Svoboda <jiri@…> (2024-10-10 11:52:43)
Message:

Implement mouse tracking in libvt / remcons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/remcons/remcons.c

    r5f5d375 r5e0acaa  
    126126static void remcons_vt_flush(void *);
    127127static void remcons_vt_key(void *, keymod_t, keycode_t, char);
     128static void remcons_vt_pos_event(void *, pos_event_t *);
    128129
    129130static vt100_cb_t remcons_vt_cb = {
     
    131132        .control_puts = remcons_vt_cputs,
    132133        .flush = remcons_vt_flush,
    133         .key = remcons_vt_key
     134        .key = remcons_vt_key,
     135        .pos_event = remcons_vt_pos_event
    134136};
    135137
     
    369371        event->cev.ev.key.key = key;
    370372        event->cev.ev.key.c = c;
     373
     374        return event;
     375}
     376
     377/** Creates new position event.
     378 *
     379 * @param ev Position event.
     380 * @param c Pressed character.
     381 */
     382static remcons_event_t *new_pos_event(pos_event_t *ev)
     383{
     384        remcons_event_t *event = malloc(sizeof(remcons_event_t));
     385        if (event == NULL) {
     386                fprintf(stderr, "Out of memory.\n");
     387                return NULL;
     388        }
     389
     390        link_initialize(&event->link);
     391        event->cev.type = CEV_POS;
     392        event->cev.ev.pos = *ev;
    371393
    372394        return event;
     
    627649}
    628650
     651static void remcons_vt_pos_event(void *arg, pos_event_t *ev)
     652{
     653        remcons_t *remcons = (remcons_t *)arg;
     654
     655        remcons_event_t *cev = new_pos_event(ev);
     656        if (cev == NULL)
     657                return;
     658
     659        list_append(&cev->link, &remcons->in_events);
     660}
     661
    629662/** Window size update callback.
    630663 *
     
    700733                vt100_cls(remcons->vt);
    701734                vt100_set_pos(remcons->vt, 0, 0);
     735                vt100_set_button_reporting(remcons->vt, true);
    702736        }
    703737
Note: See TracChangeset for help on using the changeset viewer.