rasProject_01 / weSweetHome
R. 240
process control / RasPi software by weinert-automation
|
USB 1D / 2D scanners mimicking keyboards on Raspberry Pi. More...
#include "weUSBscan.h"
Variables | |
char const | deRawCoDisAltGrph [120] |
Key position number to character, AltGr, German keyboard. More... | |
char const | deRawCoDisNoShift [90] |
Key position number to character, no shift, German keyboard. More... | |
char const | deRawCoDisShifted [90] |
Key position number to character, shifted, German keyboard. More... | |
wchar_t | raw2wcharAltGrph [102] |
Key position number to character, with AltGR. More... | |
wchar_t | raw2wcharNoShift [60] |
Key position number to character, no shift. More... | |
wchar_t | raw2wcharShifted [60] |
Key position number to character, with shift. More... | |
unsigned char | scanKeyAction [32] |
The one keystroke read buffer. More... | |
int | scanKeybLang |
The keyboard language. More... | |
wchar_t | scanResult [162] |
The result of one scan. More... | |
char const | usRawCoDisNoShift [90] |
Key position number to character, no shift, US keyboard. More... | |
char const | usRawCoDisShifted [90] |
Key position number to character, shifted, US keyboard. More... | |
USB 1D / 2D scanners mimicking keyboards on Raspberry Pi.
Revision history
This is a supplementary basic library to handle USB barcode and QR code scanners. By plug'n play such scanner would normally appear as device
. To make this usable for scanner application programs run without sudo apply
before.
char const usRawCoDisNoShift[90] |
Key position number to character, no shift, US keyboard.
This utf-8 or multibyte character array respectively string describes the translation of key number to character for a US keyboard.
It will have to be transfered as wide character array to raw2wcharNoShift.
char const usRawCoDisShifted[90] |
Key position number to character, shifted, US keyboard.
See the explanation at usRawCoDisNoShift.
char const deRawCoDisNoShift[90] |
Key position number to character, no shift, German keyboard.
This utf-8 or multibyte character array respectively string describes the translation of key number to character for a US keyboard.
It will have to be transfered as wide character array to raw2wcharNoShift.
Remarks on non US keyboard emulations by the "USB Wired 2D Barcode Scanner" <MJ-8200> and consorts:
We strongly recommend not to use them and refrain from applications using more than primitive USASCII. As "German keyboard", e.g., the scanner does neither recognise nor send ÇÏÇôǬÇ?Ç?Ç?Ç?. Besides being called German without umlauts [sic!] the scanner is ignorant to some other characters on every German keyboard (which are probably there because of being used in Western Europe). Additionally the scanner when set to German inserts additional strings of characters with no obvious sense or system.
In the end we consider everything beyond factory reset (except low beeper volume) as not functional.
Without the hard bug of inventing characters and string not contained in the QR-code, the so called German keyboard would give us some extra characters — but not umlauts.
char const deRawCoDisShifted[90] |
Key position number to character, shifted, German keyboard.
See the explanation at usRawCoDisNoShift.
char const deRawCoDisAltGrph[120] |
Key position number to character, AltGr, German keyboard.
See the explanation at usRawCoDisNoShift.
wchar_t raw2wcharNoShift[60] |
Key position number to character, no shift.
The length is 60. Valid characters are in the 4..56 key number range; there may be gaps. 0..3 are errors.
wchar_t raw2wcharShifted[60] |
Key position number to character, with shift.
The length is 60. Valid characters are in the 4..56 key number range; there may be gaps. 0..3 are errors.
wchar_t raw2wcharAltGrph[102] |
Key position number to character, with AltGR.
The length is 60. Valid characters are in the 4..56 key number range; there will be many gaps. 0..3 are errors.
int scanKeybLang |
The keyboard language.
The language of the USB keyboard (see scanKeyAction) emulated by the scanner is stored here as: 0=US (default), 10=DE
wchar_t scanResult[162] |
The result of one scan.
The result of consecutive keystrokes (see scanKeyAction) is stored here as array respectively string of wide characters.
unsigned char scanKeyAction[32] |
The one keystroke read buffer.
Keyboard input comes in blocks of 8 bytes each. Hence a length of 8 would be sufficient. Hence, 32 is a reserve for device errors or the driver not recognising the gap between blocks.
The 8 bytes are:
As scanners won't "press" more than one key at a time only bytes [0] and [1] will contain information.
Byte[2] will be a crazy key code for a..z1..90... athwart to any utf or unicode. In the end the semantic of that "code" is a mixture of key value and key position on the keyboard. In the end few scanners get more than an American (and a Chinese?) keybord right. When setting the scanner to German keyboard you may miss one or two of ÇÏ Çô Ǭ Ç? Ç? Ç? Ç?.
On byte [0] one should see only three values: /code 0 : no modifier, no shift 2 : shift, that means a->A 64: altGr