Go to Post "The devil" isn't in the details... The devil is having a loud house party with lots of other devils and demons in the details. And laughing, and laughing... - pfreivald [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-01-2017, 16:28
Ranai's Avatar
Ranai Ranai is offline
Registered User
AKA: Matthew
FRC #2081 (Icarus)
Team Role: Programmer
 
Join Date: Mar 2016
Rookie Year: 2014
Location: Illinois
Posts: 1
Ranai is an unknown quantity at this point
Simple library for XBox controllers

Hello!
I am a member of Team 2081. At the end of last year's build season, our software mentor had an idea: "Why not make an open source library to handle all of the controller code?" I really liked the idea of writing something that could be used not only by my team, but by other teams who might have use for it.

Over the summer, I did a lot of work with programming in C#, which helped me learn a lot about object-oriented programming. I didn't think much of it at the time but without that extra learning, I probably wouldn't have been able to write this.

So, as this build season was getting started, I decided to take a shot at making a controller library. I had started some of the basic stuff in the off season for a competition, but it wasn't very good so I scraped it. The code itself can be found here.

It's worth noting that this library was made with using a standard XBox 360 controller in mind, so not all controllers will be compatible. I'm planning on adding something for compatibility in the near future, so watch for that if you're interested.

Feel free to use this code if you want, after all I made it not just for my team, but for everyone
Reply With Quote
  #2   Spotlight this post!  
Unread 14-01-2017, 19:10
mlaga97 mlaga97 is offline
Registered User
FRC #1421
 
Join Date: Mar 2015
Location: Picayune, MS
Posts: 3
mlaga97 is an unknown quantity at this point
Re: Simple library for XBox controllers

Looks very nice, and man would it have been nice to have in years past.

Coincidentally, WPILib actually just added an XBoxController class that makes it a lot less painless that is very similar to your code. Maybe they were cheating off of you :-)

https://github.com/wpilibsuite/allwp...oxController.h
Reply With Quote
  #3   Spotlight this post!  
Unread 14-01-2017, 21:18
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 52
calcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nice
Re: Simple library for XBox controllers

My initial implementation of the XboxController class was based on https://github.com/robotdotnet/WPILi...xController.cs. I replaced the base classes with GamepadBase and JoystickBase to deduplicate the implementations of Joystick and XboxController.

I also wrote a button state tracker for Joysticks a few years ago that I submitted this year (https://github.com/wpilibsuite/allwpilib/pull/89). It's intended to be used with SampleRobot since Command-based robots already have the capability to run commands upon button state edges (see the ButtonScheduler commands). It wasn't merged in time for 2017 because we had other concerns to focus on for release. It uses raw button numbers, so using it for an XboxController wouldn't be clean. Perhaps an enum could be used to map the button names (A, B, X, Y) to the raw button number.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:59.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi