Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python 2/3 evdev wrapper class for parsing Joypad input events.

License

NotificationsYou must be signed in to change notification settings

python-utilities/xjoypad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

XJoypad is a Python2/3 iterator and wrapper API ofevdev, for reading and parsing joypad and game-controller input events.

Byte size of init.pyOpen IssuesOpen Pull RequestsLatest commits


Table of Contents


Quick Start

Bash Variables

_module_name='xjoypad'_module_https_url="https://github.com/python-utilities/${_module_name}.git"_module_relative_path="lib/modules/${_module_name}"

Bash Submodule Commands

cd"<your-git-project-path>"git checkout mastermkdir -vp"lib/modules"git submodule add\ -b master --name"${_module_name}"\"${_module_https_url}""${_module_relative_path}"

Your ReadMe File

Suggested additions for yourReadMe.md file so everyone has a good time with submodules

Install Python dependenciespip3 install --user evdevClone with the following to avoid incomplete downloadsgit clone --recurse-submodules <url-for-your-project>Update/upgrade submodules viagit submodule update --init --merge --recursive

Utilize XJoypad

As animport

#!/usr/bin/env python3fromlib.modules.xjoypadimportXJoypadif__name__=='__main__':importtimexjoypad=XJoypad()forevent_datainxjoypad:ifevent_data:print("{name} --> {value} --> {normalized_value}".format(**event_data))time.sleep(0.001)

As a baseclass

#!/usr/bin/env python3importtimefromlib.modules.xjoypadimportXJoypadclassXJoypad_Buffer(XJoypad):"""Extends `XJoypad` class with buffer and timeout features"""def__init__(self,device_index=0,amend_settings=None,**kwargs):"""        Use `amend_settings` to modify select `self['sleeps']` settings        """self['sleeps']= {'min':0.001,'max':0.01,'acceleration':0.001,'timeout':120,'current':0.001,        }super(XJoypad_Buffer,self).__init__(device_index=device_index,amend_settings=amend_settings,**kwargs)defnext(self):"""        Throws `GeneratorExit` if timeout is set and reached, otherwise returns `event_data` when available        """while1:_event_data=super(XJoypad_Buffer,self).next()if_event_data:self['sleeps']['slept_start']=Noneself['sleeps']['current']=self['sleeps']['min']return_event_dataifnotself['sleeps'].get('slept_start'):self['sleeps']['slept_start']=time.time()ifself['sleeps']['current']<self['sleeps']['max']:self['sleeps']['current']+=self['sleeps']['acceleration']ifself['sleeps'].get('timeout')andself['sleeps'].get('slept_last'):ifself['sleeps']['slept_last']-self['sleeps']['slept_start']>self['sleeps']['timeout']:self.throw(GeneratorExit)self['sleeps']['slept_last']=time.time()time.sleep(self['sleeps']['current'])if__name__=='__main__':xjoypad=XJoypad_Buffer()forevent_datainxjoypad:print("Event name -> {name} -- {value} -- {normalized_value}".format(**event_data))time.sleep(0.001)

Commit and Push

git add .gitmodulesgit add lib/modules/xjoypad## Add any changed files toogit commit -F-<<'EOF':heavy_plus_sign: Adds `python-utilities/xjoypad#1` submodule# ... anything else noteworthyEOFgit push origin master

🎉 Excellent 🎉 your repository is now ready to begin unitizing code from this project!


Notes

Pull Requests are welcome for fixing bugs and/or adding features.


License

Legal bits of Open Source software

XJoypad ReadMe documenting how things like this could be utilizedCopyright (C) 2019  S0AndS0This program is free software: you can redistribute it and/or modifyit under the terms of the GNU Affero General Public License as publishedby the Free Software Foundation; version 3 of the License.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU Affero General Public License for more details.You should have received a copy of the GNU Affero General Public Licensealong with this program.  If not, see <https://www.gnu.org/licenses/>.

About

Python 2/3 evdev wrapper class for parsing Joypad input events.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp