Comments (3)
Hey @oezgan, glad barcode-server is useful.
Did you try just removing the _KP
from the startswith
?
Current:
elif event.keycode.startswith("KEY_KP"):
if len(event.keycode) == 7:
character = event.keycode[-1]
New:
elif event.keycode.startswith("KEY_"):
if len(event.keycode) == 7:
character = event.keycode[-1]
Maybe this works with more than I had anticipated.
I am not that familiar with keyboard keycode bindings and stuff. If this doesn't work, we can just use your code, looks find to me :)
from barcode-server.
Hey @markusressel
I am afraid my changes are not that simple :-)
first of all I moved the elif
s one indent out such that they are part of the outer if...
elif event.keycode == "KEY_SPACE": character = ' ' elif event.keycode.startswith("KEY_KP"): if len(event.keycode) == 7: character = event.keycode[-1] elif event.keycode == "KEY_ASTERISK": character = '*'
and I removed all the KP
s from the keycodes example:
Current:
KEY_KPEQUAL
New:
KEY_EQUAL
this solves the mentioned keycode problem.
I also created a dictionary with the US_EN keyboard mappings
US_EN_UPPER_DICT = { "``": "~", "1":"!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ",": "<", ".": ">", "/": "?", ";": ":", "'": "\"", "\\": "|", "[": "{", "]": "{" }
at the end of the _on_key_event
method I added the following:
if self._shift or self._caps:
character = character.upper()
if character in US_EN_UPPER_DICT.keys():
character = US_EN_UPPER_DICT[character]
this solves the problem that the barcode scanner delivers the $
sign with SHIFT+4
at least my barcode scanner delivers that with this combination. On my research (googling) I found out that almost all barcode readers (1D or 2D) deliver the characters as keyboard keypresses so this seems to make sense.
As I said I am not a coder (anymore) and I do not know much about keycodes and mappings either.
I believe though creating a dictionaries for ASCII Keycodes and then map them directly is the better way to go.
I will try that out if I find the time...
Also I believe a dev.grab()
before the loop will grant exclusive access to the scanner device...
So here is my dilemma:
- Should I modify your server for reading CovPass QR Codes into a DB with the now working hot fix of mine ?
or - Should I modify the keyevent handler and then modify the server into a QR code server for CovPass
:-) I also need time for this of course...
Anyway for now it works for me
from barcode-server.
@oezgan Sorry I forgot to answer this after merging.
Yes, I started this project because I wanted to read simple 2D barcodes, numbers only.
However, there is no reason to not support other types of barcodes as well.
As long as its only keypresses, it should be fairly straight forward to support other inputs.
I have not done any testing on this myself though, and probably wont in the near future, since I currently have no personal use case for this.
About the "grabbing": barcode-server already does this, but I suppose there are cases where it doesn't work as expected.
Not sure about storing scanned items into a DB, barcode-server was meant more as a relay than a database interface.
I don't want the burden of integrating a multitude of different database protocols into a simple barcode-server.
If that is a functionality you need, then I would suggest using another service application or writing one yourself, that receives the barcodes sent by barcode-server (via one of the supported methods) and stores then stores them into a DB and/or handles them otherwise. node-red would probably be an option here (although I don't use or like the project).
from barcode-server.
Related Issues (20)
- MQTT Publish
- HTTP Post
- API: Get list of current devices HOT 1
- More statistics metrics
- Publish Package on PyPI
- Queue barcode event messages per notifier HOT 1
- Queue events for websocket clients between connections
- Installation process failed HOT 2
- API token should be optional
- Using Docker Container on ARM Device HOT 3
- "dead" delay after a scan HOT 1
- 'InputEvent' object has no attribute 'event' HOT 4
- 'InputEvent' object has no attribute 'keystate' HOT 2
- evdev failed to install HOT 1
- Systemd service HOT 2
- Illegal instruction HOT 7
- Support having a scanner connected to tablet over bluetooth HOT 2
- asyncio_mqtt update and retry error HOT 3
- M5Stack Core MP135 Barcode Scanning Station
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from barcode-server.