#widget-collapsarch-2-top span.collapsing.archives{border:0;padding:0;margin:0;cursor:pointer}#widget-collapsarch-2-top li.widget_collapspage h2 span.sym{float:right;padding:0 .5em}#widget-collapsarch-2-top li.collapsing.archives a.self{font-weight:bold}#widget-collapsarch-2-top:before{content:''}#widget-collapsarch-2-top li.collapsing.archives:before{content:''}#widget-collapsarch-2-top li.collapsing.archives{list-style-type:none}#widget-collapsarch-2-top li.collapsing.archives{padding:0 0 0 1em;text-indent:-1em}#widget-collapsarch-2-top li.collapsing.archives.item:before{content:'\00BB \00A0'!important}#widget-collapsarch-2-top li.collapsing.archives .sym{cursor:pointer;font-size:1.2em;font-family:Arial,Helvetica,sans-serif;padding-right:5px}#widget-collapsarch-4-top span.collapsing.archives{border:0;padding:0;margin:0;cursor:pointer}#widget-collapsarch-4-top li.widget_collapspage h2 span.sym{float:right;padding:0 .5em}#widget-collapsarch-4-top li.collapsing.archives a.self{font-weight:bold}#widget-collapsarch-4-top:before{content:''}#widget-collapsarch-4-top li.collapsing.archives:before{content:''}#widget-collapsarch-4-top li.collapsing.archives{list-style-type:none}#widget-collapsarch-4-top li.collapsing.archives{padding:0 0 0 1em;text-indent:-1em}#widget-collapsarch-4-top li.collapsing.archives.item:before{content:'\00BB \00A0'!important}#widget-collapsarch-4-top li.collapsing.archives .sym{cursor:pointer;font-size:1.2em;font-family:Arial,Helvetica,sans-serif;padding-right:5px}

      <kbd id='25a89b9610'></kbd><address id='25a89b9610'><style id='25a89b9610'></style></address><button id='25a89b9610'></button>

          QWERTY keyboard made of barcodes

          Reading Time: 4 minutes

          Played briefly with barcodes yesterday –
          There was a usb barcode scanner lying around MITERS which Michael handed me, you plug it in and it behaves like a keyboard.

          See video, which demonstrates scanning what I was hoping would be a backspace (but is actually reading as Ctrl-H), and then scanning a normal barcode on a box lying around.

          (also hosted here: https://photos.app.goo.gl/GKBDrtjNtJhHXu448)

          Anyway, so of course we have the terrible idea of a barcode keyboard, which given that I need to urgently work toward my quals exam at the end of January, seemed like a perfect thing to waste time on (short brainless self-contained project). Of course after the first step I made it more convoluted and worked on it for several hours… but anyway.

          I present: The barcode keyboard! ?

          Video of it in action here, starring expert scanner Mike:

          (also hosted here: https://photos.app.goo.gl/Cv4DfEJTbat5KwGT6).

          And the source files:

          The barcodes were generated using a website: https://barcode.tec-it.com/en/Code128? (Note that can only create five at a time).

          That’s it! I should’ve stopped there! But…

          Backspace

          Well I noticed that my backspace barcode key doesn’t work :’( Despite checking “evaluate escape expression” on the barcode generator.

          After some debugging (detailed below) I realized that my computer thinks I’m presseing “Ctrl-H” (^H) which is what used to be backspace presumably on some ancient terminal system.

          Page 17 (shown on left side of screenshot) lists the codes: https://www.tec-it.com/download/PDF/Barcode_Reference_EN.pdf

          So, getting a backspace working is for future work.

          Sunglasses

          Of course, along the way as I was looking at ASCII tables, I realized there are some extended ASCII codes that look kinda like I might be able to piece together some of the emoji (? unicode art ish?) online. Specifically, I wanted to be able to scan a barcode and get out

          ( ?_?)
          ( ?_?)>?■-■
          (?■_■)

          Source: https://gist.github.com/cheeaun/3720871#file-putonglasses-txt-L2

          So the ASCII equivalents aren’t a perfect match, but the closest I got was:

          ( ·_·)
          ( ·_·)>┌■-■
          ( ┌■-■)

          After looking up the ASCII codes, I entered into the barcode generator
          (mentioned above) the keycode

          And I stuck the outputs into a word editor to get

           

          But when I went to scan it, I only got out

          Sad :’(

          So, getting special things is left for future steps. But it’s neat to know that I can do weird things like Ctrl-H just from scanning a barcode.

          The rest of the blog post will mostly be notes from my debugging process.

          Debug

          To get closer to what the barcode scanner was “actually” outputting and to compare it to the difference from me pressing the key, I looked at

          Xev and Xinput

          Example output

          The “q” key:

          Wow. Much confusion —

          What are all these numbers?

          More on keycodes:
          https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

          “Q” is 81 there because it is ASCII 81 (in decimal). But why is it 24 in xinput, and 71 in xev??

          E.g. backspace key
          In xinput list,

          In xev,

          But also these ways??

          The last is the issue – gets interpreted as Ctrl-H.

          Looking around I didn’t see much to help me.
          https://unix.stackexchange.com/questions/49650/how-to-get-keycodes-for-xmodmap

          Specifically, https://unix.stackexchange.com/a/49651

          There are a lot of players between your keyboard and the process that finally handles the keyboard event. Among the major pieces of the landscape are the fact that the X system has its own keyboard-handling layer, and X associates different “keycodes” with keys than your Linux base system does. The showkey command is showing you the keycodes in Linux-base-system lingo. For xmodmap you need the X keycodes, which are what xev is displaying. So long as you’re planning to work in X and do your key rebinding with xmodmap, then, ignore showkeys and just listen to what xev says.

          Of course, being able to scan a barcode and hit “ctrl-h” makes one wonder… can you make malicious barcodes? Turns out someone on the intenret has looked into this: http://www.irongeek.com/xss-sql-injection-fuzzing-barcode-generator.php

          Future

          • Get another barcode scanner, dual wielding! Play Doom or something with barcode scanners XD
          • Get backspace working. The second barcode scanner, hopefully from different manufacturer, can help tell me if it’s something weird about this particular scanner such that it’s outputting Crl-H instead of backspace.
          • Get sunglasses emoji barcode working
          • Understand more about the barcode systems