Changeset 9fe1635 in mainline for uspace/srv/hid/input/input.c


Ignore:
Timestamp:
2019-05-16T08:00:04Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
4db37d1
Parents:
e89dc0b
Message:

Adding support for changing the layout through IPC

The service hid/input is now available for other
programs to access. The service accepts a new request
type for changing the keyboard layout (INPUT_CHANGE_LAYOUT)

File:
1 edited

Legend:

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

    re89dc0b r9fe1635  
    110110}
    111111
    112 static void layout_load(const char *layout_name)
    113 {
    114 /*
    115         async_get_call(ipc_call_t *);
    116 ipc_get_arg1(ipc_call_t *);
    117 */     
    118         const char *prefix = "/lib/layouts/";
     112static errno_t layout_load(const char *layout_name)
     113{
     114#ifdef CONFIG_RTLD
     115        const char *prefix = "layouts/";
    119116        const char *suffix = ".so";
    120117        size_t length = 1;
     
    122119        length += str_size(suffix);
    123120        length += str_size(layout_name);
    124         char *path = malloc(sizeof(char) * length);
    125 
     121        char *path = malloc(sizeof(char) * (length + 1));
     122       
    126123        if (path == NULL) {
    127124                printf("%s: Error allocating layout path. Out of memory.\n", NAME);
    128                 return;
    129         }
    130 
     125                return ENOMEM;
     126        }
     127
     128        path[0] = '\0';
    131129        str_append(path, length, prefix);
    132130        str_append(path, length, layout_name);
    133131        str_append(path, length, suffix);
     132        printf("%s\n", path);
    134133
    135134        void *handle = dlopen(path, 0);
    136135        if (handle == NULL) {
    137136                printf("%s: Keyboard layout could not be found.\n", NAME);
    138                 return;
    139         }
    140 
    141         layout_ops_t (*get_layout)(void) = dlsym(handle, "dl_get_constant");
     137                return ENOENT;
     138        }
     139
     140        layout_ops_t (*get_layout)(void) = dlsym(handle, "get_layout");
    142141
    143142        if (get_layout == NULL) {
    144143                printf("%s: Keyboard layout constructor could not be found.\n", NAME);
    145                 return;
     144                return ENOENT;
    146145        }
    147146
    148147        layout_active = get_layout();
    149148        layout_change(&layout_active);
     149#endif
     150
     151        return EOK;
    150152}
    151153
     
    379381                                break;
    380382                        case INPUT_CHANGE_LAYOUT: {
    381                                 char * layout_name = (char *)ipc_get_arg1(&call);
    382                                 layout_load(layout_name);
     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);
    383391                                free(layout_name);
     392                                async_answer_0(&call, retval);
    384393                                break;
    385394                        }
Note: See TracChangeset for help on using the changeset viewer.