daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Feb 17th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/ python
  2.  
  3. from evdev import InputDevice, ecodes, list_devices
  4. from select import select
  5.  
  6. keys = {
  7.     # Scancode: ASCIICode
  8.     0: None, 1: u'ESC', 2: u'1', 3: u'2', 4: u'3', 5: u'4', 6: u'5', 7: u'6', 8: u'7', 9: u'8',
  9.     10: u'9', 11: u'0', 12: u'-', 13: u'=', 14: u'BKSP', 15: u'TAB', 16: u'Q', 17: u'W', 18: u'E', 19: u'R',
  10.     20: u'T', 21: u'Y', 22: u'U', 23: u'I', 24: u'O', 25: u'P', 26: u'[', 27: u']', 28: u'CRLF', 29: u'LCTRL',
  11.     30: u'A', 31: u'S', 32: u'D', 33: u'F', 34: u'G', 35: u'H', 36: u'J', 37: u'K', 38: u'L', 39: u';',
  12.     40: u'"', 41: u'`', 42: u'LSHFT', 43: u'\\', 44: u'Z', 45: u'X', 46: u'C', 47: u'V', 48: u'B', 49: u'N',
  13.     50: u'M', 51: u',', 52: u'.', 53: u'/', 54: u'RSHFT', 56: u'LALT', 100: u'RALT'
  14. }
  15. dev = InputDevice("/dev/input/event3")
  16.  
  17. barcode = ""
  18. while True:
  19.     r,w,x = select([dev], [], [])
  20.  
  21.     for event in dev.read():
  22.         if event.type == 1 and event.value == 1:
  23.              barcode += (keys[event.code])
  24.     if (len (barcode)) > 13:
  25.      break;
  26.  
  27. with open('outputbarcode.txt', 'a+') as myfile:
  28.      myfile.write(barcode)
  29.  
  30.  
  31. print (barcode)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top