Changeset 28a5ebd in mainline for uspace/srv/hid/input
- Timestamp:
- 2020-06-18T15:39:50Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce52c333
- Parents:
- 4f663f3e
- Location:
- uspace/srv/hid/input
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/layout.c
r4f663f3e r28a5ebd 69 69 70 70 /** Parse keyboard event. */ 71 wchar_t layout_parse_ev(layout_t *layout, kbd_event_t *ev)71 char32_t layout_parse_ev(layout_t *layout, kbd_event_t *ev) 72 72 { 73 73 return (*layout->ops->parse_ev)(layout, ev); -
uspace/srv/hid/input/layout.h
r4f663f3e r28a5ebd 53 53 errno_t (*create)(layout_t *); 54 54 void (*destroy)(layout_t *); 55 wchar_t (*parse_ev)(layout_t *, kbd_event_t *);55 char32_t (*parse_ev)(layout_t *, kbd_event_t *); 56 56 } layout_ops_t; 57 57 … … 64 64 extern layout_t *layout_create(layout_ops_t *); 65 65 extern void layout_destroy(layout_t *); 66 extern wchar_t layout_parse_ev(layout_t *, kbd_event_t *);66 extern char32_t layout_parse_ev(layout_t *, kbd_event_t *); 67 67 68 68 #endif -
uspace/srv/hid/input/layout/ar.c
r4f663f3e r28a5ebd 44 44 static errno_t ar_create(layout_t *); 45 45 static void ar_destroy(layout_t *); 46 static wchar_t ar_parse_ev(layout_t *, kbd_event_t *ev);46 static char32_t ar_parse_ev(layout_t *, kbd_event_t *ev); 47 47 48 48 layout_ops_t ar_ops = { … … 52 52 }; 53 53 54 static wchar_t map_not_shifted[] = {54 static char32_t map_not_shifted[] = { 55 55 [KC_BACKTICK] = L'ذ', 56 56 … … 110 110 }; 111 111 112 static wchar_t map_shifted[] = {112 static char32_t map_shifted[] = { 113 113 [KC_BACKTICK] = L'ّ', 114 114 … … 168 168 }; 169 169 170 static wchar_t map_neutral[] = {170 static char32_t map_neutral[] = { 171 171 [KC_BACKSPACE] = '\b', 172 172 [KC_TAB] = '\t', … … 181 181 }; 182 182 183 static wchar_t map_numeric[] = {183 static char32_t map_numeric[] = { 184 184 [KC_N7] = '7', 185 185 [KC_N8] = '8', … … 196 196 }; 197 197 198 static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)198 static char32_t translate(unsigned int key, char32_t *map, size_t map_length) 199 199 { 200 200 if (key >= map_length) … … 212 212 } 213 213 214 static wchar_t ar_parse_ev(layout_t *state, kbd_event_t *ev)215 { 216 wchar_t c;214 static char32_t ar_parse_ev(layout_t *state, kbd_event_t *ev) 215 { 216 char32_t c; 217 217 218 218 /* Produce no characters when Ctrl or Alt is pressed. */ … … 220 220 return 0; 221 221 222 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof( wchar_t));222 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char32_t)); 223 223 if (c != 0) 224 224 return c; 225 225 226 226 if ((ev->mods & KM_SHIFT) != 0) 227 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof( wchar_t));227 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char32_t)); 228 228 else 229 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof( wchar_t));229 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char32_t)); 230 230 231 231 if (c != 0) … … 233 233 234 234 if ((ev->mods & KM_NUM_LOCK) != 0) 235 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof( wchar_t));235 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char32_t)); 236 236 else 237 237 c = 0; -
uspace/srv/hid/input/layout/cz.c
r4f663f3e r28a5ebd 45 45 static errno_t cz_create(layout_t *); 46 46 static void cz_destroy(layout_t *); 47 static wchar_t cz_parse_ev(layout_t *, kbd_event_t *ev);47 static char32_t cz_parse_ev(layout_t *, kbd_event_t *ev); 48 48 49 49 enum m_state { … … 63 63 }; 64 64 65 static wchar_t map_lcase[] = {65 static char32_t map_lcase[] = { 66 66 [KC_Q] = 'q', 67 67 [KC_W] = 'w', … … 94 94 }; 95 95 96 static wchar_t map_ucase[] = {96 static char32_t map_ucase[] = { 97 97 [KC_Q] = 'Q', 98 98 [KC_W] = 'W', … … 125 125 }; 126 126 127 static wchar_t map_not_shifted[] = {127 static char32_t map_not_shifted[] = { 128 128 [KC_BACKTICK] = ';', 129 129 … … 141 141 }; 142 142 143 static wchar_t map_shifted[] = {143 static char32_t map_shifted[] = { 144 144 [KC_1] = '1', 145 145 [KC_2] = '2', … … 167 167 }; 168 168 169 static wchar_t map_ns_nocaps[] = {169 static char32_t map_ns_nocaps[] = { 170 170 [KC_2] = L'ě', 171 171 [KC_3] = L'š', … … 182 182 }; 183 183 184 static wchar_t map_ns_caps[] = {184 static char32_t map_ns_caps[] = { 185 185 [KC_2] = L'Ě', 186 186 [KC_3] = L'Š', … … 197 197 }; 198 198 199 static wchar_t map_neutral[] = {199 static char32_t map_neutral[] = { 200 200 [KC_BACKSPACE] = '\b', 201 201 [KC_TAB] = '\t', … … 210 210 }; 211 211 212 static wchar_t map_numeric[] = {212 static char32_t map_numeric[] = { 213 213 [KC_N7] = '7', 214 214 [KC_N8] = '8', … … 225 225 }; 226 226 227 static wchar_t map_hacek_lcase[] = {227 static char32_t map_hacek_lcase[] = { 228 228 [KC_E] = L'ě', 229 229 [KC_R] = L'ř', … … 239 239 }; 240 240 241 static wchar_t map_hacek_ucase[] = {241 static char32_t map_hacek_ucase[] = { 242 242 [KC_E] = L'Ě', 243 243 [KC_R] = L'Ř', … … 253 253 }; 254 254 255 static wchar_t map_carka_lcase[] = {255 static char32_t map_carka_lcase[] = { 256 256 [KC_E] = L'é', 257 257 [KC_U] = L'ú', … … 264 264 }; 265 265 266 static wchar_t map_carka_ucase[] = {266 static char32_t map_carka_ucase[] = { 267 267 [KC_E] = L'É', 268 268 [KC_U] = L'Ú', … … 275 275 }; 276 276 277 static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)277 static char32_t translate(unsigned int key, char32_t *map, size_t map_length) 278 278 { 279 279 if (key >= map_length) … … 282 282 } 283 283 284 static wchar_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev)285 { 286 wchar_t c;284 static char32_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev) 285 { 286 char32_t c; 287 287 288 288 cz_state->mstate = ms_start; … … 293 293 294 294 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 295 c = translate(ev->key, map_hacek_ucase, sizeof(map_hacek_ucase) / sizeof( wchar_t));295 c = translate(ev->key, map_hacek_ucase, sizeof(map_hacek_ucase) / sizeof(char32_t)); 296 296 else 297 c = translate(ev->key, map_hacek_lcase, sizeof(map_hacek_lcase) / sizeof( wchar_t));297 c = translate(ev->key, map_hacek_lcase, sizeof(map_hacek_lcase) / sizeof(char32_t)); 298 298 299 299 return c; 300 300 } 301 301 302 static wchar_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev)303 { 304 wchar_t c;302 static char32_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev) 303 { 304 char32_t c; 305 305 306 306 cz_state->mstate = ms_start; … … 311 311 312 312 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 313 c = translate(ev->key, map_carka_ucase, sizeof(map_carka_ucase) / sizeof( wchar_t));313 c = translate(ev->key, map_carka_ucase, sizeof(map_carka_ucase) / sizeof(char32_t)); 314 314 else 315 c = translate(ev->key, map_carka_lcase, sizeof(map_carka_lcase) / sizeof( wchar_t));315 c = translate(ev->key, map_carka_lcase, sizeof(map_carka_lcase) / sizeof(char32_t)); 316 316 317 317 return c; 318 318 } 319 319 320 static wchar_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev)321 { 322 wchar_t c;320 static char32_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev) 321 { 322 char32_t c; 323 323 324 324 /* Produce no characters when Ctrl or Alt is pressed. */ … … 335 335 } 336 336 337 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof( wchar_t));337 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char32_t)); 338 338 if (c != 0) 339 339 return c; … … 341 341 if ((ev->mods & KM_SHIFT) == 0) { 342 342 if ((ev->mods & KM_CAPS_LOCK) != 0) 343 c = translate(ev->key, map_ns_caps, sizeof(map_ns_caps) / sizeof( wchar_t));343 c = translate(ev->key, map_ns_caps, sizeof(map_ns_caps) / sizeof(char32_t)); 344 344 else 345 c = translate(ev->key, map_ns_nocaps, sizeof(map_ns_nocaps) / sizeof( wchar_t));345 c = translate(ev->key, map_ns_nocaps, sizeof(map_ns_nocaps) / sizeof(char32_t)); 346 346 347 347 if (c != 0) … … 350 350 351 351 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 352 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof( wchar_t));352 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char32_t)); 353 353 else 354 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof( wchar_t));354 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char32_t)); 355 355 356 356 if (c != 0) … … 358 358 359 359 if ((ev->mods & KM_SHIFT) != 0) 360 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof( wchar_t));360 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char32_t)); 361 361 else 362 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof( wchar_t));362 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char32_t)); 363 363 364 364 if (c != 0) … … 366 366 367 367 if ((ev->mods & KM_NUM_LOCK) != 0) 368 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof( wchar_t));368 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char32_t)); 369 369 else 370 370 c = 0; … … 409 409 } 410 410 411 static wchar_t cz_parse_ev(layout_t *state, kbd_event_t *ev)411 static char32_t cz_parse_ev(layout_t *state, kbd_event_t *ev) 412 412 { 413 413 layout_cz_t *cz_state = (layout_cz_t *) state->layout_priv; -
uspace/srv/hid/input/layout/fr_azerty.c
r4f663f3e r28a5ebd 43 43 static errno_t fr_azerty_create (layout_t *); 44 44 static void fr_azerty_destroy (layout_t *); 45 static wchar_t fr_azerty_parse_ev (layout_t *, kbd_event_t *);45 static char32_t fr_azerty_parse_ev (layout_t *, kbd_event_t *); 46 46 47 47 layout_ops_t fr_azerty_ops = { … … 51 51 }; 52 52 53 static wchar_t map_lcase[] = {53 static char32_t map_lcase[] = { 54 54 [KC_Q] = 'a', 55 55 [KC_W] = 'z', … … 82 82 }; 83 83 84 static wchar_t map_ucase[] = {84 static char32_t map_ucase[] = { 85 85 [KC_Q] = 'A', 86 86 [KC_W] = 'Z', … … 117 117 }; 118 118 119 static wchar_t map_not_shifted[] = {119 static char32_t map_not_shifted[] = { 120 120 [KC_BACKTICK] = L'²', 121 121 … … 146 146 }; 147 147 148 static wchar_t map_shifted[] = {148 static char32_t map_shifted[] = { 149 149 [KC_M] = '?', 150 150 [KC_BACKTICK] = '~', … … 176 176 }; 177 177 178 static wchar_t map_neutral[] = {178 static char32_t map_neutral[] = { 179 179 [KC_BACKSPACE] = '\b', 180 180 [KC_TAB] = '\t', … … 189 189 }; 190 190 191 static wchar_t map_numeric[] = {191 static char32_t map_numeric[] = { 192 192 [KC_N7] = '7', 193 193 [KC_N8] = '8', … … 204 204 }; 205 205 206 static wchar_t translate (unsigned int key, wchar_t *map, size_t map_len)206 static char32_t translate (unsigned int key, char32_t *map, size_t map_len) 207 207 { 208 208 if (key >= map_len) … … 221 221 } 222 222 223 static wchar_t fr_azerty_parse_ev (layout_t *s, kbd_event_t *e)223 static char32_t fr_azerty_parse_ev (layout_t *s, kbd_event_t *e) 224 224 { 225 225 if ((e->mods & (KM_CTRL | KM_ALT))) 226 226 return 0; // Produce no characters when Ctrl or Alt is pressed 227 227 228 wchar_t c = translate (e->key, map_neutral, sizeof (map_neutral) / sizeof (wchar_t));228 char32_t c = translate (e->key, map_neutral, sizeof (map_neutral) / sizeof (char32_t)); 229 229 if (c) 230 230 return c; 231 231 232 232 if ((e->mods & KM_SHIFT)) 233 c = translate (e->key, map_shifted, sizeof (map_shifted) / sizeof ( wchar_t));233 c = translate (e->key, map_shifted, sizeof (map_shifted) / sizeof (char32_t)); 234 234 else 235 c = translate (e->key, map_not_shifted, sizeof (map_not_shifted) / sizeof ( wchar_t));235 c = translate (e->key, map_not_shifted, sizeof (map_not_shifted) / sizeof (char32_t)); 236 236 237 237 if (c) … … 239 239 240 240 if (((e->mods & KM_SHIFT)) ^ ((e->mods & KM_CAPS_LOCK))) 241 c = translate (e->key, map_ucase, sizeof (map_ucase) / sizeof ( wchar_t));241 c = translate (e->key, map_ucase, sizeof (map_ucase) / sizeof (char32_t)); 242 242 else 243 c = translate (e->key, map_lcase, sizeof (map_lcase) / sizeof ( wchar_t));243 c = translate (e->key, map_lcase, sizeof (map_lcase) / sizeof (char32_t)); 244 244 245 245 if (c) … … 247 247 248 248 if ((e->mods & KM_NUM_LOCK)) 249 c = translate (e->key, map_numeric, sizeof (map_numeric) / sizeof ( wchar_t));249 c = translate (e->key, map_numeric, sizeof (map_numeric) / sizeof (char32_t)); 250 250 else 251 251 c = 0; -
uspace/srv/hid/input/layout/us_dvorak.c
r4f663f3e r28a5ebd 43 43 static errno_t us_dvorak_create(layout_t *); 44 44 static void us_dvorak_destroy(layout_t *); 45 static wchar_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev);45 static char32_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev); 46 46 47 47 layout_ops_t us_dvorak_ops = { … … 51 51 }; 52 52 53 static wchar_t map_lcase[] = {53 static char32_t map_lcase[] = { 54 54 [KC_R] = 'p', 55 55 [KC_T] = 'y', … … 84 84 }; 85 85 86 static wchar_t map_ucase[] = {86 static char32_t map_ucase[] = { 87 87 [KC_R] = 'P', 88 88 [KC_T] = 'Y', … … 117 117 }; 118 118 119 static wchar_t map_not_shifted[] = {119 static char32_t map_not_shifted[] = { 120 120 [KC_BACKTICK] = '`', 121 121 … … 147 147 }; 148 148 149 static wchar_t map_shifted[] = {149 static char32_t map_shifted[] = { 150 150 [KC_BACKTICK] = '~', 151 151 … … 177 177 }; 178 178 179 static wchar_t map_neutral[] = {179 static char32_t map_neutral[] = { 180 180 [KC_BACKSPACE] = '\b', 181 181 [KC_TAB] = '\t', … … 190 190 }; 191 191 192 static wchar_t map_numeric[] = {192 static char32_t map_numeric[] = { 193 193 [KC_N7] = '7', 194 194 [KC_N8] = '8', … … 205 205 }; 206 206 207 static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)207 static char32_t translate(unsigned int key, char32_t *map, size_t map_length) 208 208 { 209 209 if (key >= map_length) … … 221 221 } 222 222 223 static wchar_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev)224 { 225 wchar_t c;223 static char32_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev) 224 { 225 char32_t c; 226 226 227 227 /* Produce no characters when Ctrl or Alt is pressed. */ … … 229 229 return 0; 230 230 231 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof( wchar_t));231 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char32_t)); 232 232 if (c != 0) 233 233 return c; 234 234 235 235 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 236 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof( wchar_t));236 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char32_t)); 237 237 else 238 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof( wchar_t));238 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char32_t)); 239 239 240 240 if (c != 0) … … 242 242 243 243 if ((ev->mods & KM_SHIFT) != 0) 244 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof( wchar_t));244 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char32_t)); 245 245 else 246 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof( wchar_t));246 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char32_t)); 247 247 248 248 if (c != 0) … … 250 250 251 251 if ((ev->mods & KM_NUM_LOCK) != 0) 252 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof( wchar_t));252 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char32_t)); 253 253 else 254 254 c = 0; -
uspace/srv/hid/input/layout/us_qwerty.c
r4f663f3e r28a5ebd 43 43 static errno_t us_qwerty_create(layout_t *); 44 44 static void us_qwerty_destroy(layout_t *); 45 static wchar_t us_qwerty_parse_ev(layout_t *, kbd_event_t *ev);45 static char32_t us_qwerty_parse_ev(layout_t *, kbd_event_t *ev); 46 46 47 47 layout_ops_t us_qwerty_ops = { … … 51 51 }; 52 52 53 static wchar_t map_lcase[] = {53 static char32_t map_lcase[] = { 54 54 [KC_Q] = 'q', 55 55 [KC_W] = 'w', … … 82 82 }; 83 83 84 static wchar_t map_ucase[] = {84 static char32_t map_ucase[] = { 85 85 [KC_Q] = 'Q', 86 86 [KC_W] = 'W', … … 113 113 }; 114 114 115 static wchar_t map_not_shifted[] = {115 static char32_t map_not_shifted[] = { 116 116 [KC_BACKTICK] = '`', 117 117 … … 142 142 }; 143 143 144 static wchar_t map_shifted[] = {144 static char32_t map_shifted[] = { 145 145 [KC_BACKTICK] = '~', 146 146 … … 171 171 }; 172 172 173 static wchar_t map_neutral[] = {173 static char32_t map_neutral[] = { 174 174 [KC_BACKSPACE] = '\b', 175 175 [KC_TAB] = '\t', … … 184 184 }; 185 185 186 static wchar_t map_numeric[] = {186 static char32_t map_numeric[] = { 187 187 [KC_N7] = '7', 188 188 [KC_N8] = '8', … … 199 199 }; 200 200 201 static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)201 static char32_t translate(unsigned int key, char32_t *map, size_t map_length) 202 202 { 203 203 if (key >= map_length) … … 215 215 } 216 216 217 static wchar_t us_qwerty_parse_ev(layout_t *state, kbd_event_t *ev)218 { 219 wchar_t c;217 static char32_t us_qwerty_parse_ev(layout_t *state, kbd_event_t *ev) 218 { 219 char32_t c; 220 220 221 221 /* Produce no characters when Ctrl or Alt is pressed. */ … … 223 223 return 0; 224 224 225 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof( wchar_t));225 c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char32_t)); 226 226 if (c != 0) 227 227 return c; 228 228 229 229 if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) 230 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof( wchar_t));230 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char32_t)); 231 231 else 232 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof( wchar_t));232 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char32_t)); 233 233 234 234 if (c != 0) … … 236 236 237 237 if ((ev->mods & KM_SHIFT) != 0) 238 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof( wchar_t));238 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char32_t)); 239 239 else 240 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof( wchar_t));240 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char32_t)); 241 241 242 242 if (c != 0) … … 244 244 245 245 if ((ev->mods & KM_NUM_LOCK) != 0) 246 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof( wchar_t));246 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char32_t)); 247 247 else 248 248 c = 0;
Note:
See TracChangeset
for help on using the changeset viewer.