Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 07cdb11 in mainline


Ignore:
Timestamp:
2020-06-14T18:49:04Z (3 weeks ago)
Author:
GitHub <noreply@…>
Parents:
128359eb (diff), d8b4082c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Matthieu Riolo <matthieu.riolo@…> (2020-06-14 18:49:04)
git-committer:
GitHub <noreply@…> (2020-06-14 18:49:04)
Message:

Merge d8b4082ce596b52d55fa156bb54ef14f6048c540 into 128359ebc085c950da1f7e34c3928f12654b438f

Location:
uspace
Files:
2 added
14 edited

Legend:

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

    r128359eb r07cdb11  
    4848#include <io/logctl.h>
    4949#include <vol.h>
     50#include <ipc/services.h>
    5051#include "untar.h"
    5152#include "init.h"
     
    6869#define SRV_COMPOSITOR  "/srv/hid/compositor"
    6970
    70 #define HID_INPUT              "hid/input"
     71#define HID_INPUT              SERVICE_NAME_HID_INPUT
    7172#define HID_OUTPUT             "hid/output"
    7273#define HID_COMPOSITOR_SERVER  ":0"
  • uspace/app/meson.build

    r128359eb r07cdb11  
    5252        'killall',
    5353        'kio',
     54        'layout',
    5455        'loc',
    5556        'logset',
  • uspace/lib/c/generic/io/input.c

    r128359eb r07cdb11  
    4242#include <ipc/input.h>
    4343#include <stdlib.h>
     44#include <str.h>
    4445
    4546static void input_cb_conn(ipc_call_t *icall, void *arg);
     
    202203}
    203204
     205/**
     206 * Retrieves the active keyboard layout
     207 * @param sess Active session to the input server
     208 * @param layout The name of the currently active layout,
     209 *        needs to be freed by the caller
     210 * @return EOK if sucessful or the corresponding error code.
     211 *         If a failure occurs the param layout is already freed
     212 */
     213errno_t input_layout_get(async_sess_t *sess, char **layout)
     214{
     215        errno_t rc;
     216        ipc_call_t call;
     217        async_exch_t *exch = async_exchange_begin(sess);
     218        aid_t mid = async_send_0(exch, INPUT_GET_LAYOUT, &call);
     219        async_wait_for(mid, &rc);
     220
     221        if (rc != EOK) {
     222                goto error;
     223        }
     224
     225        size_t length = ipc_get_arg1(&call);
     226
     227        *layout = malloc(length * sizeof(char *));
     228        if (layout == NULL) {
     229                rc = ENOMEM;
     230                free(*layout);
     231                goto error;
     232        }
     233
     234        rc = async_data_read_start(exch, *layout, length);
     235
     236        if (rc != EOK)
     237                free(*layout);
     238
     239error:
     240        async_exchange_end(exch);
     241        return rc;
     242}
     243
     244/**
     245 * Changes the keyboard layout
     246 * @param sess Active session to the input server
     247 * @param layout The name of the layout which should be activated
     248 * @return EOK if sucessful or the corresponding error code.
     249 */
     250errno_t input_layout_set(async_sess_t *sess, const char *layout)
     251{
     252        errno_t rc;
     253        ipc_call_t call;
     254        async_exch_t *exch = async_exchange_begin(sess);
     255
     256        aid_t mid = async_send_0(exch, INPUT_CHANGE_LAYOUT, &call);
     257        rc = async_data_write_start(exch, layout, str_size(layout));
     258
     259        if (rc == EOK)
     260                async_wait_for(mid, &rc);
     261
     262        async_exchange_end(exch);
     263        return rc;
     264}
     265
    204266/** @}
    205267 */
  • uspace/lib/c/include/io/input.h

    r128359eb r07cdb11  
    6060extern errno_t input_activate(input_t *);
    6161
     62extern errno_t input_layout_get(async_sess_t *sess, char **layout_name);
     63extern errno_t input_layout_set(async_sess_t *sess, const char *layout_name);
    6264#endif
    6365
  • uspace/lib/c/include/ipc/input.h

    r128359eb r07cdb11  
    3939
    4040typedef enum {
    41         INPUT_ACTIVATE = IPC_FIRST_USER_METHOD
     41        INPUT_ACTIVATE = IPC_FIRST_USER_METHOD,
     42        INPUT_CHANGE_LAYOUT,
     43        INPUT_GET_LAYOUT
    4244} input_request_t;
    4345
  • uspace/lib/c/include/ipc/services.h

    r128359eb r07cdb11  
    4949} service_t;
    5050
    51 #define SERVICE_NAME_CHARDEV_TEST_SMALLX "chardev-test/smallx"
    52 #define SERVICE_NAME_CHARDEV_TEST_LARGEX "chardev-test/largex"
     51#define SERVICE_NAME_CHARDEV_TEST_SMALLX   "chardev-test/smallx"
     52#define SERVICE_NAME_CHARDEV_TEST_LARGEX   "chardev-test/largex"
    5353#define SERVICE_NAME_CHARDEV_TEST_PARTIALX "chardev-test/partialx"
    54 #define SERVICE_NAME_CLIPBOARD "clipboard"
    55 #define SERVICE_NAME_CORECFG  "corecfg"
    56 #define SERVICE_NAME_DHCP     "net/dhcp"
    57 #define SERVICE_NAME_DNSR     "net/dnsr"
    58 #define SERVICE_NAME_INET     "net/inet"
    59 #define SERVICE_NAME_IPC_TEST "ipc-test"
    60 #define SERVICE_NAME_NETCONF  "net/netconf"
    61 #define SERVICE_NAME_UDP      "net/udp"
    62 #define SERVICE_NAME_TCP      "net/tcp"
    63 #define SERVICE_NAME_VBD      "vbd"
    64 #define SERVICE_NAME_VOLSRV   "volsrv"
     54#define SERVICE_NAME_CLIPBOARD             "clipboard"
     55#define SERVICE_NAME_CORECFG               "corecfg"
     56#define SERVICE_NAME_DHCP                  "net/dhcp"
     57#define SERVICE_NAME_DNSR                  "net/dnsr"
     58#define SERVICE_NAME_INET                  "net/inet"
     59#define SERVICE_NAME_IPC_TEST              "ipc-test"
     60#define SERVICE_NAME_HID_INPUT             "hid/input"
     61#define SERVICE_NAME_NETCONF               "net/netconf"
     62#define SERVICE_NAME_UDP                   "net/udp"
     63#define SERVICE_NAME_TCP                   "net/tcp"
     64#define SERVICE_NAME_VBD                   "vbd"
     65#define SERVICE_NAME_VOLSRV                "volsrv"
    6566
    6667#endif
  • uspace/srv/hid/input/input.c

    r128359eb r07cdb11  
    6666#include "serial.h"
    6767
    68 #define NUM_LAYOUTS 5
     68static layout_ops_t *layout_active = &us_qwerty_ops;
     69
     70#define NUM_LAYOUTS  5
    6971
    7072static layout_ops_t *layout[NUM_LAYOUTS] = {
     
    107109
    108110static FIBRIL_MUTEX_INITIALIZE(discovery_lock);
     111
     112/* changes all kb devices to the given layout */
     113static void layout_change(layout_ops_t *layout)
     114{
     115        list_foreach(kbd_devs, link, kbd_dev_t, kdev) {
     116                layout_t *ret = layout_create(layout);
     117                if (ret != NULL) {
     118                        layout_destroy(kdev->active_layout);
     119                        kdev->active_layout = ret;
     120                }
     121        }
     122}
     123
     124/* similiar like layout_change but takes as an argument the name of the layout */
     125static errno_t layout_load(const char *layout_name)
     126{
     127        /* TODO: change this into a loader for kb layout maps */
     128        for (int i = 0; i < NUM_LAYOUTS; i++) {
     129                if (str_cmp(layout[i]->name, layout_name) == 0) {
     130                        layout_active = layout[i];
     131                        layout_change(layout_active);
     132                        return EOK;
     133                }
     134        }
     135
     136        return ENOTSUP;
     137}
     138
     139/* Handler for IPC call INPUT_CHANGE_LAYOUT */
     140static void client_change_layout_handler(ipc_call_t *call)
     141{
     142        void *layout_name;
     143        errno_t ret = async_data_write_accept(&layout_name, true, 0, 0, 0, 0);
     144        if (ret != EOK) {
     145                async_answer_0(call, ret);
     146                return;
     147        }
     148
     149        errno_t retval = layout_load((char *)layout_name);
     150        free(layout_name);
     151        async_answer_0(call, retval);
     152}
     153
     154/* Handler for IPC call INPUT_GET_LAYOUT */
     155static void client_get_layout_handler(ipc_call_t *call)
     156{
     157        const char *layout_name = layout_active->name;
     158        size_t length = str_size(layout_name) + 1;
     159        ipc_call_t id;
     160
     161        async_answer_1(call, EOK, length);
     162        if (async_data_read_receive(&id, NULL)) {
     163                async_data_read_finalize(&id, layout_name, length);
     164        }
     165}
    109166
    110167static void *client_data_create(void)
     
    212269                switch (key) {
    213270                case KC_F1:
    214                         layout_destroy(kdev->active_layout);
    215                         kdev->active_layout = layout_create(layout[0]);
     271                        layout_change(layout[0]);
    216272                        break;
    217273                case KC_F2:
    218                         layout_destroy(kdev->active_layout);
    219                         kdev->active_layout = layout_create(layout[1]);
     274                        layout_change(layout[1]);
    220275                        break;
    221276                case KC_F3:
    222                         layout_destroy(kdev->active_layout);
    223                         kdev->active_layout = layout_create(layout[2]);
     277                        layout_change(layout[2]);
    224278                        break;
    225279                case KC_F4:
    226                         layout_destroy(kdev->active_layout);
    227                         kdev->active_layout = layout_create(layout[3]);
     280                        layout_change(layout[3]);
    228281                        break;
    229282                case KC_F5:
    230                         layout_destroy(kdev->active_layout);
    231                         kdev->active_layout = layout_create(layout[4]);
     283                        layout_change(layout[4]);
    232284                        break;
    233285                default: // default: is here to avoid compiler warning about unhandled cases
     
    359411                                async_answer_0(&call, EOK);
    360412                                break;
     413                        case INPUT_CHANGE_LAYOUT:
     414                                client_change_layout_handler(&call);
     415                                break;
     416                        case INPUT_GET_LAYOUT:
     417                                client_get_layout_handler(&call);
     418                                break;
    361419                        default:
    362420                                async_answer_0(&call, EINVAL);
     
    392450        kdev->mods = KM_NUM_LOCK;
    393451        kdev->lock_keys = 0;
    394         kdev->active_layout = layout_create(layout[0]);
     452        kdev->active_layout = layout_create(layout_active);
    395453
    396454        return kdev;
  • uspace/srv/hid/input/input.h

    r128359eb r07cdb11  
    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;
  • uspace/srv/hid/input/layout.h

    r128359eb r07cdb11  
    5454        void (*destroy)(layout_t *);
    5555        wchar_t (*parse_ev)(layout_t *, kbd_event_t *);
     56        const char *name;
    5657} layout_ops_t;
    5758
  • uspace/srv/hid/input/layout/ar.c

    r128359eb r07cdb11  
    4949        .create = ar_create,
    5050        .destroy = ar_destroy,
    51         .parse_ev = ar_parse_ev
     51        .parse_ev = ar_parse_ev,
     52        .name = "ar"
    5253};
    5354
  • uspace/srv/hid/input/layout/cz.c

    r128359eb r07cdb11  
    6060        .create = cz_create,
    6161        .destroy = cz_destroy,
    62         .parse_ev = cz_parse_ev
     62        .parse_ev = cz_parse_ev,
     63        .name = "cz"
    6364};
    6465
  • uspace/srv/hid/input/layout/fr_azerty.c

    r128359eb r07cdb11  
    4848        .create = fr_azerty_create,
    4949        .destroy = fr_azerty_destroy,
    50         .parse_ev = fr_azerty_parse_ev
     50        .parse_ev = fr_azerty_parse_ev,
     51        .name = "fr_azerty"
    5152};
    5253
  • uspace/srv/hid/input/layout/us_dvorak.c

    r128359eb r07cdb11  
    4848        .create = us_dvorak_create,
    4949        .destroy = us_dvorak_destroy,
    50         .parse_ev = us_dvorak_parse_ev
     50        .parse_ev = us_dvorak_parse_ev,
     51        .name = "us_dvorak"
    5152};
    5253
  • uspace/srv/hid/input/layout/us_qwerty.c

    r128359eb r07cdb11  
    4848        .create = us_qwerty_create,
    4949        .destroy = us_qwerty_destroy,
    50         .parse_ev = us_qwerty_parse_ev
     50        .parse_ev = us_qwerty_parse_ev,
     51        .name = "us_qwerty"
    5152};
    5253
Note: See TracChangeset for help on using the changeset viewer.