Changeset 11e394f in mainline
- Timestamp:
- 2020-12-31T21:19:51Z (4 years ago)
- Children:
- 19f60a38
- Parents:
- e037cf37
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-07-21 21:23:33)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-12-31 21:19:51)
- Location:
- uspace
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
re037cf37 r11e394f 50 50 #include <vfs/vfs.h> 51 51 #include <vol.h> 52 #include <ipc/services.h> 52 53 #include "untar.h" 53 54 #include "init.h" … … 70 71 #define SRV_DISPLAY "/srv/hid/display" 71 72 72 #define HID_INPUT "hid/input"73 #define HID_INPUT SERVICE_NAME_HID_INPUT 73 74 #define HID_OUTPUT "hid/output" 74 75 -
uspace/lib/c/include/ipc/input.h
re037cf37 r11e394f 39 39 40 40 typedef enum { 41 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD 41 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD, 42 INPUT_CHANGE_LAYOUT, 43 INPUT_GET_LAYOUT 42 44 } input_request_t; 43 45 -
uspace/lib/c/include/ipc/services.h
re037cf37 r11e394f 59 59 #define SERVICE_NAME_INET "net/inet" 60 60 #define SERVICE_NAME_IPC_TEST "ipc-test" 61 #define SERVICE_NAME_HID_INPUT "hid/input" 61 62 #define SERVICE_NAME_NETCONF "net/netconf" 62 63 #define SERVICE_NAME_UDP "net/udp" -
uspace/srv/hid/input/input.c
re037cf37 r11e394f 66 66 #include "serial.h" 67 67 68 #define NUM_LAYOUTS 5 68 static layout_ops_t *layout_active = &us_qwerty_ops; 69 70 #define NUM_LAYOUTS 5 69 71 70 72 static layout_ops_t *layout[NUM_LAYOUTS] = { … … 107 109 108 110 static FIBRIL_MUTEX_INITIALIZE(discovery_lock); 111 112 /* changes all kb devices to the given layout */ 113 static 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 */ 125 static 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 */ 140 static 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 */ 155 static 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 } 109 166 110 167 static void *client_data_create(void) … … 212 269 switch (key) { 213 270 case KC_F1: 214 layout_destroy(kdev->active_layout); 215 kdev->active_layout = layout_create(layout[0]); 271 layout_change(layout[0]); 216 272 break; 217 273 case KC_F2: 218 layout_destroy(kdev->active_layout); 219 kdev->active_layout = layout_create(layout[1]); 274 layout_change(layout[1]); 220 275 break; 221 276 case KC_F3: 222 layout_destroy(kdev->active_layout); 223 kdev->active_layout = layout_create(layout[2]); 277 layout_change(layout[2]); 224 278 break; 225 279 case KC_F4: 226 layout_destroy(kdev->active_layout); 227 kdev->active_layout = layout_create(layout[3]); 280 layout_change(layout[3]); 228 281 break; 229 282 case KC_F5: 230 layout_destroy(kdev->active_layout); 231 kdev->active_layout = layout_create(layout[4]); 283 layout_change(layout[4]); 232 284 break; 233 285 default: // default: is here to avoid compiler warning about unhandled cases … … 367 419 async_answer_0(&call, EOK); 368 420 break; 421 case INPUT_CHANGE_LAYOUT: 422 client_change_layout_handler(&call); 423 break; 424 case INPUT_GET_LAYOUT: 425 client_get_layout_handler(&call); 426 break; 369 427 default: 370 428 async_answer_0(&call, EINVAL); … … 400 458 kdev->mods = KM_NUM_LOCK; 401 459 kdev->lock_keys = 0; 402 kdev->active_layout = layout_create(layout [0]);460 kdev->active_layout = layout_create(layout_active); 403 461 404 462 return kdev; -
uspace/srv/hid/input/input.h
re037cf37 r11e394f 41 41 #include <stdbool.h> 42 42 #include <async.h> 43 #include <ipc/services.h> 43 44 44 #define NAME "input"45 #define NAME SERVICE_NAME_HID_INPUT 45 46 46 47 extern bool irc_service; -
uspace/srv/hid/input/layout.h
re037cf37 r11e394f 54 54 void (*destroy)(layout_t *); 55 55 char32_t (*parse_ev)(layout_t *, kbd_event_t *); 56 const char *name; 56 57 } layout_ops_t; 57 58 -
uspace/srv/hid/input/layout/ar.c
re037cf37 r11e394f 49 49 .create = ar_create, 50 50 .destroy = ar_destroy, 51 .parse_ev = ar_parse_ev 51 .parse_ev = ar_parse_ev, 52 .name = "ar" 52 53 }; 53 54 -
uspace/srv/hid/input/layout/cz.c
re037cf37 r11e394f 60 60 .create = cz_create, 61 61 .destroy = cz_destroy, 62 .parse_ev = cz_parse_ev 62 .parse_ev = cz_parse_ev, 63 .name = "cz" 63 64 }; 64 65 -
uspace/srv/hid/input/layout/fr_azerty.c
re037cf37 r11e394f 48 48 .create = fr_azerty_create, 49 49 .destroy = fr_azerty_destroy, 50 .parse_ev = fr_azerty_parse_ev 50 .parse_ev = fr_azerty_parse_ev, 51 .name = "fr_azerty" 51 52 }; 52 53 -
uspace/srv/hid/input/layout/us_dvorak.c
re037cf37 r11e394f 48 48 .create = us_dvorak_create, 49 49 .destroy = us_dvorak_destroy, 50 .parse_ev = us_dvorak_parse_ev 50 .parse_ev = us_dvorak_parse_ev, 51 .name = "us_dvorak" 51 52 }; 52 53 -
uspace/srv/hid/input/layout/us_qwerty.c
re037cf37 r11e394f 48 48 .create = us_qwerty_create, 49 49 .destroy = us_qwerty_destroy, 50 .parse_ev = us_qwerty_parse_ev 50 .parse_ev = us_qwerty_parse_ev, 51 .name = "us_qwerty" 51 52 }; 52 53
Note:
See TracChangeset
for help on using the changeset viewer.