Changeset 9fe1635 in mainline


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)

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    re89dc0b r9fe1635  
    4848#include <io/logctl.h>
    4949#include <vol.h>
     50#include <ipc/services.h>
    5051#include "untar.h"
    5152#include "init.h"
     
    6566#define SRV_COMPOSITOR  "/srv/hid/compositor"
    6667
    67 #define HID_INPUT              "hid/input"
     68#define HID_INPUT              SERVICE_NAME_HID_INPUT
    6869#define HID_OUTPUT             "hid/output"
    6970#define HID_COMPOSITOR_SERVER  ":0"
  • uspace/lib/c/include/ipc/services.h

    re89dc0b r9fe1635  
    5858#define SERVICE_NAME_INET     "net/inet"
    5959#define SERVICE_NAME_IPC_TEST "ipc-test"
     60#define SERVICE_NAME_HID_INPUT    "hid/input"
    6061#define SERVICE_NAME_NETCONF  "net/netconf"
    6162#define SERVICE_NAME_UDP      "net/udp"
  • 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                        }
  • uspace/srv/hid/input/input.h

    re89dc0b r9fe1635  
    4141#include <stdbool.h>
    4242#include <async.h>
     43#include <ipc/services.h>
    4344
    44 #define NAME  "input"
     45#define NAME SERVICE_NAME_HID_INPUT
    4546
    4647extern bool irc_service;
Note: See TracChangeset for help on using the changeset viewer.