@@ -2662,7 +2662,7 @@ _get_input_event()
26622662 if test -n " ${1-} " ; then _max_cycles=" $(( ${1:? } * 4 )) " || return 120; fi
26632663
26642664 while true ; do
2665- _file_size=" $( get_size_of_file " ${TMP_PATH:? } /working-files/input/input-events/0" ) " || return 121
2665+ _file_size=" $( get_size_of_file 2> /dev/null " ${TMP_PATH:? } /working-files/input/input-events/0" ) " || return 121
26662666
26672667 if test " ${_file_size:? } " -ge " ${_expected_file_size:? } " ; then
26682668 _val=" $( hexdump -x -v -s " ${INPUT_EVENT_START_OFFSET:? } " -n " ${_size:? } " -- " ${TMP_PATH:? } /working-files/input/input-events/0" | _prepare_hexdump_output) " || return " ${?} "
@@ -2721,20 +2721,28 @@ _detect_input_event_size()
27212721
27222722_parse_input_event ()
27232723{
2724- printf " %s\n" " ${1?} " | while IFS=' ' read -r _ _ _ _ ev_type32 key_code32 key_action32 _ ev_type64 key_code64 key_action64 _; do
2724+ printf " %s\n" " ${1?} " | while IFS=' ' read -r _ _ _ _ ev_type32 key_code32 key_action32p2 key_action32p1 ev_type64 key_code64 key_action64p2 key_action64p1 _; do
27252725 if test " ${INPUT_EVENT_SIZE:? } " -eq 24; then
2726- event_type=" $( hex_to_dec " $ {ev_type64: ? }" ) " || return 123
2727- key_code=" ${key_code64: ? } "
2728- key_action=" $( hex_to_dec " ${key_action64 : ? }" ) " || return 123
2726+ event_type=" ${ev_type64?} "
2727+ key_code=" ${key_code64?} "
2728+ key_action=" ${key_action64p1?}${key_action64p2 ?} "
27292729 elif test " ${INPUT_EVENT_SIZE:? } " -eq 16; then
2730- event_type=" $( hex_to_dec " $ {ev_type32: ? }" ) " || return 123
2731- key_code=" ${key_code32: ? } "
2732- key_action=" $( hex_to_dec " ${key_action32 : ? }" ) " || return 123
2730+ event_type=" ${ev_type32?} "
2731+ key_code=" ${key_code32?} "
2732+ key_action=" ${key_action32p1?}${key_action32p2 ?} "
27332733 else
27342734 ui_warning " Invalid input event size: ${INPUT_EVENT_SIZE?} "
27352735 return 127
27362736 fi
27372737
2738+ if test -z " ${event_type?} " || test -z " ${key_code?} " || test -z " ${key_action?} " ; then
2739+ ui_warning " Corrupted event data"
2740+ return 122
2741+ fi
2742+
2743+ event_type=" $( hex_to_dec " ${event_type:? } " ) " || return 123
2744+ key_action=" $( hex_to_dec " ${key_action:? } " ) " || return 123
2745+
27382746 if test " ${event_type:? } " -eq 0; then return 115; fi # Event type 0 (EV_SYN) is useless, ignore it earlier and never report it
27392747
27402748 # Only event type 1 (EV_KEY) is supported
@@ -3059,6 +3067,7 @@ choose_inputevent()
30593067 }
30603068
30613069 _last_key_pressed=' '
3070+
30623071 while true ; do
30633072 _get_input_event " ${1-} " || { # It set ${INPUT_EVENT_CURRENT}
30643073 _status=" ${?} "
@@ -3077,9 +3086,9 @@ choose_inputevent()
30773086
30783087 if test -z " ${INPUT_EVENT_SIZE-} " ; then
30793088 INPUT_EVENT_SIZE=" $( _detect_input_event_size " ${INPUT_EVENT_CURRENT?} " ) " || {
3080- ui_warning " Key detection failed (input event) - size check, status code: ${?} "
3089+ _status= " ${?} "
30813090 input_device_listener_stop
3082- return 1
3091+ ui_error " Key detection failed (input event) - size check, status code: ${_status?} "
30833092 }
30843093 if test " ${INPUT_EVENT_SIZE:? } " -ne 24; then INPUT_EVENT_START_OFFSET=" $(( INPUT_EVENT_START_OFFSET - 24 + INPUT_EVENT_SIZE)) " ; fi
30853094 fi
@@ -3093,8 +3102,7 @@ choose_inputevent()
30933102 115) continue ;; # We got an unsupported event type or action (ignored)
30943103 * ) # Event parsing failed (fail)
30953104 input_device_listener_stop
3096- ui_warning " Key detection failed (input event) - parse, status code: ${_status?} "
3097- return 1
3105+ ui_error " Key detection failed (input event) - parse, status code: ${_status?} "
30983106 ;;
30993107 esac
31003108
@@ -3107,27 +3115,25 @@ choose_inputevent()
31073115 ui_debug " Event { Event type: 1, Key code: ${_key?} , Action: $(( _status - 10 )) }"
31083116 fi
31093117
3110- if true ; then
3118+ if : ; then
31113119 if test " ${_status:? } " -eq 11; then
31123120 # Key down
31133121 if test " ${_last_key_pressed?} " = ' ' ; then
3114- _last_key_pressed=" ${_key?} "
3122+ _last_key_pressed=" ${_key?} " # One key pressed (waiting release)
31153123 else
3116- _last_key_pressed=' ' # Two buttons pressed simultaneously (ignored)
3124+ _last_key_pressed=' '
3125+ ui_msg ' Key mismatch, ignored!!!' # Two keys pressed simultaneously (ignored)
31173126 fi
31183127 continue
31193128 else
31203129 # Key up
3121- if test -n " ${_key ?} " && test " ${_key: ? } " = " ${_last_key_pressed?} " ; then
3130+ if test -n " ${_last_key_pressed ?} " && test " ${_key?} " = " ${_last_key_pressed: ? } " ; then
31223131 : # OK
31233132 else
3124- _last_key_pressed=' '
3125- ui_msg ' Key mismatch, ignored!!!' # Key mismatch (ignored)
3133+ _last_key_pressed=' ' # Key mismatch from earlier (ignored)
31263134 continue
31273135 fi
31283136 fi
3129-
3130- _last_key_pressed=' '
31313137 fi
31323138
31333139 _key_desc=" $( _inputevent_keycode_to_key " ${_key?} " ) " || _key_desc=' Unknown'
@@ -3138,6 +3144,7 @@ choose_inputevent()
31383144 ui_error ' Installation forcefully terminated' 143
31393145 ;;
31403146 * )
3147+ _last_key_pressed=' '
31413148 test " ${KEY_TEST_ONLY:? } " -eq 1 || {
31423149 ui_msg " Invalid choice!!! Key: ${_key_desc?} (${_key?} )"
31433150 continue
0 commit comments