@@ -0,0 +1,1967 @@
+# -*- coding: utf-8 -*-%0A# Part of Odoo. See LICENSE file for full copyright and licensing details.%0A%0Aimport evdev%0Aimport logging%0Afrom usb import util%0A%0Afrom odoo import _%0Afrom odoo.addons.hw_drivers.controllers.driver import event_manager, Driver%0A%0A_logger = logging.getLogger(__name__)%0A%0A%0Aclass KeyboardUSBDriver(Driver):%0A    connection_type = 'usb'%0A%0A    def __init__(self, device):%0A        super(KeyboardUSBDriver, self).__init__(device)%0A        self._device_type = 'device'%0A        self._device_connection = 'direct'%0A        self._device_name = self._get_name()%0A%0A    @classmethod%0A    def supported(cls, device):%0A        for cfg in device:%0A            for itf in cfg:%0A                if itf.bInterfaceClass == 3 and itf.bInterfaceProtocol == 1:%0A                    return True%0A        return False%0A%0A    def _get_name(self):%0A        try:%0A            manufacturer = util.get_string(self.dev, 256, self.dev.iManufacturer)%0A            product = util.get_string(self.dev, 256, self.dev.iProduct)%0A            return (%22%25s - %25s%22) %25 (manufacturer, product)%0A        except ValueError as e:%0A            _logger.warning(e)%0A            return _('Unknow keyboard')%0A%0A    def action(self, data):%0A        self.data%5B'value'%5D = ''%0A        event_manager.device_changed(self)%0A%0A    def run(self):%0A        devices = %5Bevdev.InputDevice(path) for path in evdev.list_devices()%5D%0A        for device in devices:%0A            if (self.dev.idVendor == device.info.vendor) and (self.dev.idProduct == device.info.product):%0A                path = device.path%0A        device = evdev.InputDevice(path)%0A%0A        try:%0A            for event in device.read_loop():%0A                if event.type == evdev.ecodes.EV_KEY:%0A                    data = evdev.categorize(event)%0A                    if data.keystate:%0A                        self.data%5B'value'%5D = data.keycode.replace('KEY_','')%0A                        event_manager.device_changed(self)%0A        except Exception as err:%0A            _logger.warning(err)%0A

Move Keyboard driver to Community