Changeset a8171b86 in mainline for uspace/srv/hid/input/input.c


Ignore:
Timestamp:
2019-05-18T06:42:01Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Parents:
f9edc7b
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-05-16 09:48:08)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-05-18 06:42:01)
Message:

Implementing layout get

The command layout can now display the current active
keyboard layout. The service hid/input has been extended
for the IPC call INPUT_GET_LAYOUT

File:
1 edited

Legend:

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

    rf9edc7b ra8171b86  
    120120        length += str_size(layout_name);
    121121        char *path = malloc(sizeof(char) * (length + 1));
    122        
     122
    123123        if (path == NULL) {
    124124                printf("%s: Error allocating layout path. Out of memory.\n", NAME);
     
    130130        str_append(path, length, layout_name);
    131131        str_append(path, length, suffix);
    132         printf("%s\n", path);
    133132
    134133        void *handle = dlopen(path, 0);
     
    340339}
    341340
     341/* Handler for IPC call INPUT_CHANGE_LAYOUT */
     342static void client_change_layout_handler(ipc_call_t *call)
     343{
     344        void *layout_name;
     345        errno_t ret = async_data_write_accept(&layout_name, true, 0, 0, 0, 0);
     346        if (ret != EOK) {
     347                async_answer_0(call, ret);
     348                return;
     349        }
     350
     351        errno_t retval = layout_load((char *)layout_name);
     352        free(layout_name);
     353        async_answer_0(call, retval);
     354}
     355
     356/* Handler for IPC call INPUT_GET_LAYOUT */
     357static void client_get_layout_handler(ipc_call_t *call)
     358{
     359        const char *layout_name = layout_active.get_name();
     360        size_t length = str_size(layout_name) + 1;
     361        ipc_call_t id;
     362
     363        async_answer_1(call, EOK, length);
     364        if (async_data_read_receive(&id, NULL)) {
     365                async_data_read_finalize(&id, layout_name, length);
     366        }
     367}
     368
    342369/** New client connection */
    343370static void client_connection(ipc_call_t *icall, void *arg)
     
    380407                                async_answer_0(&call, EOK);
    381408                                break;
    382                         case INPUT_CHANGE_LAYOUT: {
    383                                 void * layout_name;
    384                                 errno_t ret = async_data_write_accept(&layout_name, true, 0, 0, 0, 0);
    385                                 if (ret != EOK) {
    386                                         async_answer_0(&call, ret);
    387                                         break;
    388                                 }
    389 
    390                                 errno_t retval = layout_load((char *)layout_name);
    391                                 free(layout_name);
    392                                 async_answer_0(&call, retval);
     409                        case INPUT_CHANGE_LAYOUT:
     410                                client_change_layout_handler(&call);
    393411                                break;
    394                         }
     412                        case INPUT_GET_LAYOUT:
     413                                client_get_layout_handler(&call);
     414                                break;
    395415                        default:
    396416                                async_answer_0(&call, EINVAL);
Note: See TracChangeset for help on using the changeset viewer.