Changeset b3eeae5 in mainline for uspace/srv/hid/display/display.c


Ignore:
Timestamp:
2023-01-15T09:24:50Z (15 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46a47c0
Parents:
46b02cb
Message:

Assigning devices to seats

File:
1 edited

Legend:

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

    r46b02cb rb3eeae5  
    101101        disp->next_wnd_id = 1;
    102102        list_initialize(&disp->ddevs);
     103        list_initialize(&disp->idevcfgs);
    103104        list_initialize(&disp->seats);
    104105        list_initialize(&disp->windows);
     
    124125        assert(list_empty(&disp->seats));
    125126        assert(list_empty(&disp->ddevs));
     127        assert(list_empty(&disp->idevcfgs));
    126128        assert(list_empty(&disp->seats));
    127129        assert(list_empty(&disp->windows));
     
    623625ds_seat_t *ds_display_seat_by_idev(ds_display_t *disp, ds_idev_id_t idev_id)
    624626{
    625         // TODO Multi-seat
    626         (void) idev_id;
    627 
     627        ds_idevcfg_t *idevcfg;
     628
     629        /*
     630         * Find input device configuration entry that maps this input device
     631         * to a seat.
     632         */
     633        idevcfg = ds_display_first_idevcfg(disp);
     634        while (idevcfg != NULL) {
     635                if (idevcfg->svc_id == idev_id)
     636                        return idevcfg->seat;
     637
     638                idevcfg = ds_display_next_idevcfg(idevcfg);
     639        }
     640
     641        /* If none was found, return the default seat */
    628642        return ds_display_first_seat(disp);
    629643}
     
    772786
    773787        return list_get_instance(link, ds_ddev_t, lddevs);
     788}
     789
     790/** Add input device configuration entry to display.
     791 *
     792 * @param disp Display
     793 * @param idevcfg Input device configuration
     794 */
     795void ds_display_add_idevcfg(ds_display_t *disp, ds_idevcfg_t *idevcfg)
     796{
     797        assert(idevcfg->display == NULL);
     798        assert(!link_used(&idevcfg->lidevcfgs));
     799
     800        idevcfg->display = disp;
     801        list_append(&idevcfg->lidevcfgs, &disp->idevcfgs);
     802}
     803
     804/** Remove input device configuration entry from display.
     805 *
     806 * @param idevcfg Input device configuration entry
     807 */
     808void ds_display_remove_idevcfg(ds_idevcfg_t *idevcfg)
     809{
     810        list_remove(&idevcfg->lidevcfgs);
     811        idevcfg->display = NULL;
     812}
     813
     814/** Get first input device configuration entry in display.
     815 *
     816 * @param disp Display
     817 * @return First input device configuration entry or @c NULL if there is none
     818 */
     819ds_idevcfg_t *ds_display_first_idevcfg(ds_display_t *disp)
     820{
     821        link_t *link = list_first(&disp->idevcfgs);
     822
     823        if (link == NULL)
     824                return NULL;
     825
     826        return list_get_instance(link, ds_idevcfg_t, lidevcfgs);
     827}
     828
     829/** Get next input device configuration entry in display.
     830 *
     831 * @param idevcfg Current input device configuration entry
     832 * @return Next input device configuration entry or @c NULL if there is none
     833 */
     834ds_idevcfg_t *ds_display_next_idevcfg(ds_idevcfg_t *idevcfg)
     835{
     836        link_t *link = list_next(&idevcfg->lidevcfgs, &idevcfg->display->idevcfgs);
     837
     838        if (link == NULL)
     839                return NULL;
     840
     841        return list_get_instance(link, ds_idevcfg_t, lidevcfgs);
    774842}
    775843
Note: See TracChangeset for help on using the changeset viewer.