Changeset 166dccf in mainline
- Timestamp:
- 2021-01-08T00:48:12Z (12 days ago)
- Parents:
- d70dc1c4 (diff), 8fb674b (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@…> (2021-01-08 00:48:12)
- git-committer:
- GitHub <noreply@…> (2021-01-08 00:48:12)
- Location:
- uspace
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
rd70dc1c4 r166dccf 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/app/meson.build
rd70dc1c4 r166dccf 56 56 'kio', 57 57 'launcher', 58 'layout', 58 59 'loc', 59 60 'logset', -
uspace/lib/c/generic/io/input.c
rd70dc1c4 r166dccf 42 42 #include <ipc/input.h> 43 43 #include <stdlib.h> 44 #include <str.h> 44 45 45 46 static void input_cb_conn(ipc_call_t *icall, void *arg); … … 202 203 } 203 204 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 */ 213 errno_t input_layout_get(async_sess_t *sess, char **layout) 214 { 215 *layout = NULL; 216 217 async_exch_t *exch = async_exchange_begin(sess); 218 219 ipc_call_t answer; 220 aid_t req = async_send_0(exch, INPUT_GET_LAYOUT, &answer); 221 222 char layout_buf[INPUT_LAYOUT_NAME_MAXLEN + 1]; 223 ipc_call_t dreply; 224 aid_t dreq = async_data_read(exch, layout_buf, INPUT_LAYOUT_NAME_MAXLEN, 225 &dreply); 226 227 errno_t dretval; 228 async_wait_for(dreq, &dretval); 229 230 async_exchange_end(exch); 231 232 if (dretval != EOK) { 233 async_forget(req); 234 return dretval; 235 } 236 237 errno_t retval; 238 async_wait_for(req, &retval); 239 240 if (retval != EOK) 241 return retval; 242 243 size_t length = ipc_get_arg2(&dreply); 244 assert(length <= INPUT_LAYOUT_NAME_MAXLEN); 245 layout_buf[length] = '\0'; 246 247 *layout = str_dup(layout_buf); 248 if (*layout == NULL) 249 return ENOMEM; 250 251 return EOK; 252 } 253 254 /** 255 * Changes the keyboard layout 256 * @param sess Active session to the input server 257 * @param layout The name of the layout which should be activated 258 * @return EOK if sucessful or the corresponding error code. 259 */ 260 errno_t input_layout_set(async_sess_t *sess, const char *layout) 261 { 262 errno_t rc; 263 ipc_call_t call; 264 async_exch_t *exch = async_exchange_begin(sess); 265 266 aid_t mid = async_send_0(exch, INPUT_SET_LAYOUT, &call); 267 rc = async_data_write_start(exch, layout, str_size(layout)); 268 269 if (rc == EOK) 270 async_wait_for(mid, &rc); 271 272 async_exchange_end(exch); 273 return rc; 274 } 275 204 276 /** @} 205 277 */ -
uspace/lib/c/include/io/input.h
rd70dc1c4 r166dccf 60 60 extern errno_t input_activate(input_t *); 61 61 62 extern errno_t input_layout_get(async_sess_t *sess, char **layout_name); 63 extern errno_t input_layout_set(async_sess_t *sess, const char *layout_name); 62 64 #endif 63 65 -
uspace/lib/c/include/ipc/input.h
rd70dc1c4 r166dccf 38 38 #include <ipc/common.h> 39 39 40 static size_t const INPUT_LAYOUT_NAME_MAXLEN = 255; 41 40 42 typedef enum { 41 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD 43 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD, 44 INPUT_SET_LAYOUT, 45 INPUT_GET_LAYOUT 42 46 } input_request_t; 43 47 -
uspace/lib/c/include/ipc/services.h
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 50 50 #include <ipc/input.h> 51 51 #include <loc.h> 52 #include <macros.h> 52 53 #include <ns.h> 53 54 #include <stdbool.h> … … 66 67 #include "serial.h" 67 68 68 #define NUM_LAYOUTS 5 69 static layout_ops_t *layout_active = &us_qwerty_ops; 70 71 #define NUM_LAYOUTS 5 69 72 70 73 static layout_ops_t *layout[NUM_LAYOUTS] = { … … 107 110 108 111 static FIBRIL_MUTEX_INITIALIZE(discovery_lock); 112 113 /* changes all kb devices to the given layout */ 114 static void layout_change(layout_ops_t *layout) 115 { 116 list_foreach(kbd_devs, link, kbd_dev_t, kdev) { 117 layout_t *ret = layout_create(layout); 118 if (ret != NULL) { 119 layout_destroy(kdev->active_layout); 120 kdev->active_layout = ret; 121 } 122 } 123 } 124 125 /* similiar like layout_change but takes as an argument the name of the layout */ 126 static errno_t layout_load(const char *layout_name) 127 { 128 /* TODO: change this into a loader for kb layout maps */ 129 for (int i = 0; i < NUM_LAYOUTS; i++) { 130 if (str_cmp(layout[i]->name, layout_name) == 0) { 131 layout_active = layout[i]; 132 layout_change(layout_active); 133 return EOK; 134 } 135 } 136 137 return ENOTSUP; 138 } 139 140 /* Handler for IPC call INPUT_SET_LAYOUT */ 141 static void client_set_layout_srv(ipc_call_t *call) 142 { 143 void *layout_name; 144 errno_t ret = async_data_write_accept(&layout_name, true, 0, 0, 0, 0); 145 if (ret != EOK) { 146 async_answer_0(call, ret); 147 return; 148 } 149 150 errno_t retval = layout_load((char *)layout_name); 151 free(layout_name); 152 async_answer_0(call, retval); 153 } 154 155 /* Handler for IPC call INPUT_GET_LAYOUT */ 156 static void client_get_layout_srv(ipc_call_t *call) 157 { 158 const char *layout_name = layout_active->name; 159 size_t length = str_size(layout_name) + 1; 160 ipc_call_t rec_call; 161 162 size_t max_size; 163 if (!async_data_read_receive(&rec_call, &max_size)) { 164 async_answer_0(&rec_call, EREFUSED); 165 async_answer_0(call, EREFUSED); 166 return; 167 } 168 169 errno_t rc = async_data_read_finalize(&rec_call, layout_name, 170 min(length, max_size)); 171 async_answer_0(call, rc); 172 } 109 173 110 174 static void *client_data_create(void) … … 212 276 switch (key) { 213 277 case KC_F1: 214 layout_destroy(kdev->active_layout); 215 kdev->active_layout = layout_create(layout[0]); 278 layout_change(layout[0]); 216 279 break; 217 280 case KC_F2: 218 layout_destroy(kdev->active_layout); 219 kdev->active_layout = layout_create(layout[1]); 281 layout_change(layout[1]); 220 282 break; 221 283 case KC_F3: 222 layout_destroy(kdev->active_layout); 223 kdev->active_layout = layout_create(layout[2]); 284 layout_change(layout[2]); 224 285 break; 225 286 case KC_F4: 226 layout_destroy(kdev->active_layout); 227 kdev->active_layout = layout_create(layout[3]); 287 layout_change(layout[3]); 228 288 break; 229 289 case KC_F5: 230 layout_destroy(kdev->active_layout); 231 kdev->active_layout = layout_create(layout[4]); 290 layout_change(layout[4]); 232 291 break; 233 292 default: // default: is here to avoid compiler warning about unhandled cases … … 367 426 async_answer_0(&call, EOK); 368 427 break; 428 case INPUT_SET_LAYOUT: 429 client_set_layout_srv(&call); 430 break; 431 case INPUT_GET_LAYOUT: 432 client_get_layout_srv(&call); 433 break; 369 434 default: 370 435 async_answer_0(&call, EINVAL); … … 400 465 kdev->mods = KM_NUM_LOCK; 401 466 kdev->lock_keys = 0; 402 kdev->active_layout = layout_create(layout [0]);467 kdev->active_layout = layout_create(layout_active); 403 468 404 469 return kdev; -
uspace/srv/hid/input/input.h
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 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
rd70dc1c4 r166dccf 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.