{ "info": { "author": "Ivo Slanina", "author_email": "ivo.slanina@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Framework :: Twisted", "Intended Audience :: Developers", "License :: Freely Distributable", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Topic :: Software Development :: Libraries", "Topic :: System :: Hardware :: Hardware Drivers" ], "description": "# twistedinput\n\n### Reading input devices using [Twisted](http://twistedmatrix.com/trac/) framework\n\nTwisted is Python2 for asynchronous IO operations and event driven programming.\nTwistedinput is library for this framework for interacting input devices, such\nas gamepads, joysticks, mouses and etc in asynchrounous fashion.\n\nAn input event is represented by standar input_event structure defined in\nlinux/input.h header file.\n\nCommunication protocol is intended for handling only those event, which you are\ninterested to.\n\n```pycon\nfrom twistedinput.device import EventDevice\nfrom twistedinput.protocol import EventProtocol\nfrom twistedinput.factory import InputEventFactory\nfrom twistedinput.mapping import GamepadEventMapping\nfrom twisted.internet import reactor\n\nclass MyGamepad(EventProtocol):\n\n def button1(self, event):\n \"\"\"\n handle only button 1\n \"\"\"\n print \"button 1:\", event.value\n\nEventDevice(\n MyGamepad(\n InputEventFactory(),\n GamepadEventMapping()),\n \"/dev/input/event13\").startReading()\nreactor.run()\n```\n\n\n### Event Mapping\n\nAccordint to linux/input.h header file. any input event consists from four\nfields:\n * timestamp\n * type\n * code\n * value\nType and code constanc decribes inputs, which can vary device from device.\nFor example, when I press button 1 on my gamepad, input_event with type EV_KEY\nand code BTN_TRIGGER. But I pressed buttin 1, not trigger.\n\nEvent mapping basicyl allows you to write a driver for your device. Mapping simply\ndefines, that event with type EV_KEY and code BTN_TRIGGER should be handled in\nbutton1 method. For different device you can define different event mappings\nand handle event by methods with logic names.\n\nIf handler method defined in the used mapping doesn't exist in the protocol,\nevent is ignored.\n\n### Handling Event Without Aid of Mapping\n\nIn the EventProtocol constructor eventMapping is optional parameter. If is\nomnited, you have to override eventReceived method and handle event by yourself.\n\n### Event Factory\n\nFactory is simple object which takes bytes representing data stream emmited by\nevent and returns object represnting this event.\nIt also provides information of size of the event.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/buben19/twistedinput", "keywords": "twisted gamepad input joystick mouse", "license": "Unlicence", "maintainer": null, "maintainer_email": null, "name": "twistedinput", "package_url": "https://pypi.org/project/twistedinput/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/twistedinput/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/buben19/twistedinput" }, "release_url": "https://pypi.org/project/twistedinput/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "Reading input devices with Twisted.", "version": "0.0.1" }, "last_serial": 849895, "releases": { "0.0.1": [] }, "urls": [] }