Changeset e89dc0b in mainline
- Timestamp:
- 2019-05-15T18:53:09Z (6 years ago)
- Children:
- 9fe1635
- Parents:
- 8f16ede6
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/ipc/input.h
r8f16ede6 re89dc0b 39 39 40 40 typedef enum { 41 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD 41 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD, 42 INPUT_CHANGE_LAYOUT 42 43 } input_request_t; 43 44 -
uspace/srv/hid/input/input.c
r8f16ede6 re89dc0b 56 56 #include <str.h> 57 57 #include <str_error.h> 58 #include <dlfcn.h> 58 59 59 60 #include "input.h" … … 97 98 98 99 static FIBRIL_MUTEX_INITIALIZE(discovery_lock); 100 101 static void layout_change(layout_ops_t *layout) 102 { 103 list_foreach(kbd_devs, link, kbd_dev_t, kdev) { 104 layout_t *ret = layout_create(layout); 105 if (ret != NULL) { 106 layout_destroy(kdev->active_layout); 107 kdev->active_layout = ret; 108 } 109 } 110 } 111 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/"; 119 const char *suffix = ".so"; 120 size_t length = 1; 121 length += str_size(prefix); 122 length += str_size(suffix); 123 length += str_size(layout_name); 124 char *path = malloc(sizeof(char) * length); 125 126 if (path == NULL) { 127 printf("%s: Error allocating layout path. Out of memory.\n", NAME); 128 return; 129 } 130 131 str_append(path, length, prefix); 132 str_append(path, length, layout_name); 133 str_append(path, length, suffix); 134 135 void *handle = dlopen(path, 0); 136 if (handle == NULL) { 137 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"); 142 143 if (get_layout == NULL) { 144 printf("%s: Keyboard layout constructor could not be found.\n", NAME); 145 return; 146 } 147 148 layout_active = get_layout(); 149 layout_change(&layout_active); 150 } 99 151 100 152 static void *client_data_create(void) … … 198 250 199 251 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && (key == KC_F1)) { 200 layout_ destroy(kdev->active_layout);201 kdev->active_layout = layout_create(&layout_default);252 layout_active = layout_default; 253 layout_change(&layout_default); 202 254 return; 203 255 } … … 326 378 async_answer_0(&call, EOK); 327 379 break; 380 case INPUT_CHANGE_LAYOUT: { 381 char * layout_name = (char *)ipc_get_arg1(&call); 382 layout_load(layout_name); 383 free(layout_name); 384 break; 385 } 328 386 default: 329 387 async_answer_0(&call, EINVAL); … … 359 417 kdev->mods = KM_NUM_LOCK; 360 418 kdev->lock_keys = 0; 361 kdev->active_layout = layout_create(&layout_ default);419 kdev->active_layout = layout_create(&layout_active); 362 420 363 421 return kdev;
Note:
See TracChangeset
for help on using the changeset viewer.