input=$1 #mapping code touche clavier et touche reelle #facile à remplir avec l'utilitaire 'showkey' declare -a k=([41]='²' [1]=ECHAP 1 2 3 4 5 6 7 8 9 0 ')' '=' BACK \ [15]=TAB a z e r t y u i o p '^' '$' ENTREE \ [58]=CAPS [30]=q s d f g h j k l m '%' [43]=µ \ [42]=SHIFT_G [86]='<' [44]=w x c v b n ',' ';' ':' '!' SHIFT_D \ [29]=CTRL_G [125]=META_G [56]=ALT ESPACE [100]=ALTGR [126]=META_D [127]=SOURIS_D [98]=CTRL_D \ [102]=DEBUT FLECHE_H PAGE_H FLECHE_G FLECHE_B FIN FLECHE_D PAGE_B INS SUPPR \ [69]=NUM [98]='/_PAVE' [55]='*_PAVE' [71]=7_PAVE 8_PAVE 9_PAVE -_PAVE 4_PAVE 5_PAVE 6_PAVE +_PAVE 1_PAVE 2_PAVE 3_PAVE 0_PAVE ._PAVE [96]=ENTREE_PAVE \ ) #echo ${k[*]} #affichage de la date du premier evt: utc_hexa=`head -c4 $input | hexdump -e '"%08X"'` utc=$((16#${utc_hexa})) echo -n "Date 1er evt : " date -d"@${utc}" echo #pour l'affichage i=0 #détermine le nombre de touches affichées par ligne nombre_par_ligne=10 liste_evt=`hexdump -e '"" 6/4 "%08X " "\n"' $input | colrm 1 38 | colrm 3 13` #Example sur l'appui d'une touche: il y a en fait 3 evts (le dernier, avec que des 0, est un "séparateur" d'événement) #5E9F03FA 00000000 00086015 00000000 00040004 00070006 #5E9F03FA 00000000 00086015 00000000 002E0001 00000001 #5E9F03FA 00000000 00086015 00000000 00000000 00000000 #l'evt de la touche correspond à #--sec--- -------- --µsecs- -------- --TT---- ------EE #sec : l'heure (secondes depuis 1970). Ex 0x5E9F03FA = 1587479546 secondes depuis 1970, soit `date -d@1587479546` renvoie 'mar. avril 21 16:32:26 CEST 2020' #µsec : µsecondes #TT : code de la touche, si TT=00, alors on ignore l'evt #EE : l'état de la touche. On ne retient que les valeurs 00(Appui) 01(Relache) et 02 (Appui long), # ce qui permet d'ignorer l'evt 00040004 00070006 # # avec les colrm, on arrive à une liste de TTEE # for t in $liste_evt ; do touche_code_hexa=${t:0:2} if [ "$touche_code_hexa" != "00" ] ; then touche_code=$((16#$touche_code_hexa)) touche_etat_hexa=${t:2:4} touche_etat="Ignore" if [ $touche_etat_hexa = "01" ] ; then touche_etat="¬" elif [ $touche_etat_hexa = "00" ] ; then touche_etat="↑" elif [ $touche_etat_hexa = "02" ] ; then touche_etat="Appui long" fi if [ "$touche_etat" != "Ignore" ] ; then #on gere le nombre de touches affichées par lignes let "i=i+1" if [ $i -gt $nombre_par_ligne ] ; then i=0 echo '|' fi echo -n '| '${k[$touche_code]} $touche_etat" " fi fi done echo #affichage de la date du dernier evt: last_evt=`tail -c24 $input | hexdump -e '"%08X"'` utc_hexa=${last_evt:0:8} utc=$((16#${utc_hexa})) echo echo -n "Date Der evt : " date -d"@${utc}"