Changeset 1388f7f0 in mainline for uspace/srv


Ignore:
Timestamp:
2020-02-21T10:50:48Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
265989d
Parents:
6c2aba3
git-author:
Jiri Svoboda <jiri@…> (2020-02-19 19:38:03)
git-committer:
Jiri Svoboda <jiri@…> (2020-02-21 10:50:48)
Message:

Support absolute movement events from input device

Location:
uspace/srv/hid/display
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/input.c

    r6c2aba3 r1388f7f0  
    9797    unsigned max_x, unsigned max_y)
    9898{
    99         printf("ds_input_ev_abs_move x=%u y=%u mx=%u my=%u\n",
    100             x, y, max_x, max_y);
    101         return EOK;
     99        ds_display_t *disp = (ds_display_t *) input->user;
     100        ptd_event_t event;
     101
     102        event.type = PTD_ABS_MOVE;
     103        event.apos.x = x;
     104        event.apos.y = y;
     105        event.abounds.p0.x = 0;
     106        event.abounds.p0.y = 0;
     107        event.abounds.p1.x = max_x + 1;
     108        event.abounds.p1.y = max_y + 1;
     109
     110        return ds_display_post_ptd_event(disp, &event);
    102111}
    103112
  • uspace/srv/hid/display/seat.c

    r6c2aba3 r1388f7f0  
    256256 * @return EOK on success or an error code
    257257 */
     258#include <stdio.h>
    258259errno_t ds_seat_post_ptd_event(ds_seat_t *seat, ptd_event_t *event)
    259260{
     
    306307        }
    307308
     309        if (event->type == PTD_ABS_MOVE) {
     310                /*
     311                 * Project input device area onto display area. Technically
     312                 * we probably want to project onto the area of a particular
     313                 * display device. The tricky part is figuring out which
     314                 * display device the input device is associated with.
     315                 */
     316                gfx_coord2_project(&event->apos, &event->abounds,
     317                    &disp->rect, &npos);
     318
     319                gfx_coord2_clip(&npos, &disp->rect, &npos);
     320
     321                (void) ds_seat_clear_pointer(seat);
     322                seat->pntpos = npos;
     323
     324                pevent.pos_id = 0;
     325                pevent.type = POS_UPDATE;
     326                pevent.btn_num = 0;
     327                pevent.hpos = seat->pntpos.x;
     328                pevent.vpos = seat->pntpos.y;
     329
     330                rc = ds_seat_post_pos_event(seat, &pevent);
     331                if (rc != EOK)
     332                        return rc;
     333
     334                (void) ds_seat_draw_pointer(seat);
     335        }
     336
    308337        return EOK;
    309338}
  • uspace/srv/hid/display/types/display/ptd_event.h

    r6c2aba3 r1388f7f0  
    4040typedef enum {
    4141        PTD_MOVE,
     42        PTD_ABS_MOVE,
    4243        PTD_PRESS,
    4344        PTD_RELEASE
     
    5152        /** Relative move vector for PTD_MOVE */
    5253        gfx_coord2_t dmove;
     54        /** Absolute position for PTD_ABS_MOVE */
     55        gfx_coord2_t apos;
     56        /** Absolute position bounds for PTD_ABS_MOVE */
     57        gfx_rect_t abounds;
    5358} ptd_event_t;
    5459
Note: See TracChangeset for help on using the changeset viewer.