Espruino USB HID GamePad - v0.1a ready ! ( may also be Bluetooth & RN42 ready .. ) #2816
Replies: 36 comments
-
Posted at 2018-09-15 by stephaneAG not posting my file ? :/ --> https://raw.githubusercontent.com/stephaneAG/usbHidDescriptors/master/espruino_hid_gamepad_report.js |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-15 by jijidad Nice! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-15 by stephaneAG ;) what's less nice is the following wip code that's driving me nuts: it seems I can't find the reason why I can't have 'gamepad.btnState' bigger than 256 ?! --> if anyone wanna finish the following ( mostly find a fix ), I'd be glad :)
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-16 by stephaneAG Back again: I updated the code to support the joysticks but still not luck with the troubles expressed above :/ the current api
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-17 by stephaneAG .. and the Puckjs version is below ( I'll have to find a way to update the firmware of my puckjs since I have no ble on my phone & just access it via a dongle on my laptop .. ) -> can someone test it ?
https://raw.githubusercontent.com/stephaneAG/usbHidDescriptors/master/espruino_ble_hid_gamepad.js |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-18 by stephaneAG Hi there ( not many answers here .. ;) ): is anyone used to modding the way the Espruino enumerates over USB ? ( I have to finish reading some code for a TeensyLC & need few infos on the way Espruino handles the USB stack & cie to port the code ). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-24 by stephaneAG back ! So, first, an early version of the Espruino GamePad API ( could be used when using either USB HID, BLE HID, & RN-42 HID .. and soon XInput to act as an Xbox360 controller ;p ): Second, I am currently debugging a test implementation of an Xbox360 controller using Teensy+Espruino ( Thee teensy emulates the controller on the Xbox360 USB port while the Espruino controls the Teensy using Serial ). So, if anyone interested in working on the opportunity to get more advanced USB stuff on the Espruino, these files seems of particular interest:
The 3rd link is particularly interesting on the lines starting from 1544 I'll try some of the STM32 USB stuff as soon as can do & 'll come back for updates on the subject. On a close subject, anyone with a working HID implementation of a PS3 controller ? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-24 by @gfwilliams Is the issue with With the STM32F4 USB I think this is probably of most interest: https://github.com/espruino/Espruino/blob/master/targetlibs/stm32usb/usbd_cdc_hid.c#L79 As the descriptors for HID are there and I guess it's them that might need tweaking? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-25 by stephaneAG Hi there ! Thanks for the hint, but it didn't come from sending ( I do the following ):
It actually came from being tired & not doing the right bitwise operations ;)
For the STM32F stuff, I'll have to digg what you suggested & more ..
Moreover, if I read correctly, the "Xbox 360 Controller Security" is not yet broken ( while said to be reverse engineered on a per console basis ? https://oct0xor.github.io/2017/05/03/xsm3/ ), so connecting to a console instead of a pc will be a harder than expected .. Anyway, as I'll have to port the current code, here's a "roadmap" to be applied to the Espruino/STM32F platform ( attached pdf file )Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-25 by stephaneAG back :) I updated/completed the "roadmap" from Zack zlittell's series of posts on the subject ( http://www.zlittell.com/2015/07/msf-fightstick-teensylc-xinput-controller-8/ ). On the current "deadend" I'm facing regarding the way genuine controllers are recognized, the following posts seems of interest but I have no clues yet on how to trick/bypass this ( and this is mandatory for the controller to be used on an actual console :/ .. )
This being said, I have some RFID code to produce before getting my hands dirty on the STM32 stuff ( nb: I have a discovery board not yet tested I consider trying on instead of messing with one of my Espruino boards ;p ), so I'll come back as usual when I got things done or with more questions ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-30 by stephaneAG quick update & good news on the RN42 topic: I received the neccessary & succefully flashed an hc-05's firmware, then enabled HID gamepad, to finish by quickly testing connection to a laptop & sending gampepad states: it just "worked" ( too bad we currently don't have any way to access a less high-level API to be able to set custom HID descriptors instead of the provided ones .. ) I plan to digg the SPP||HID GPIO toggle pin stuff, why I don't have any LEDs & things on the PCM audio pins later today, additionally to updating the Gamepad.js "draft" API ;) So, a little teaser for now .. ;P Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-03 by @gfwilliams Wow, very cool. So just to get this straight, you took a standard HC-05 module, flashed it with the RN42 HID firmware, and it became a magic configurable USB HID device? Do you have a link to instructions for the flashing process and the firmware? I have a bunch of HC-05 just sitting here from the first KickStarter. I doubt it'd be legal for me to reflash and sell them, but I'm very interested in how easy it'd be for others to update the firmware :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-05 by stephaneAG Hi there ! Indeed :) In short, you'll need:
I'll be doing a quick writeup of my notes on the subject, but you can already follow these:
In the attached archive, you'll find all the necessary ;p nb: for the "Open Adaptive Controller" I'm working on ( currently using Espruino WiFi & flashed HC-05* .. and teensy for xbox360 stuff that I hope to move onto Espruino USB stuff ), I am trying to optimize the usage of the available pins & was wondering what was the best way to put a pin on "high impedance" ( floating ? ) to be able to light either 2 leds: both at same time, only former, only latter *same for me: I guess for the final implementation of the said controller, I'll have to switch to Espruino bluetooth + wifi to be able to achieve fully custom Bluetooth HID reports ( I plan to retry the Puckjs code posted above & maybe soon purchase your latest board ;) ). Of course, I'll be posting the blueprints here ( I am currently finishing those & 'll be moving to the 3d part soon ) ;p last but not least, the debug code I used to interface the freshly flashed HC-05 .. and it worked ;p
Enjoy :DAttachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-06 by stephaneAG this part was missing in my previous message ;)
Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-06 by stephaneAG sorry for multi-posting, but for some reason I can't get the firmware file upload corectly ? :| Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-08 by @allObjects
...is using one and the other time multiplexed: out low, out high, and then some tri-state/floating. I guess you do already so. For tri-state plain input is sufficient. You just leave it auto, do writes H or L, or HLHKLHL..., and for off do a read. That's the smallest foot print. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-09 by @gfwilliams Nice! Thanks for the RN42 links and code!
As @allObjects says, literally just
Honestly, no ideas. ST's USB stack is a mess with Espruino because they kept changing it - the F1 has a different stack to the F4, and while I think the F3 is similar to F4 I believe it's different enough that some decent size changes are required :( Just IMO, but it's not worth it trying to target just because you have an F3 board. Spend £10 on an F4 board of some kind and save yourself weeks of pain :)
You may find that GCC/whatever is padding the elements inside |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-09 by stephaneAG Back ;) @allObjects thanks for the confirmation, I guessed so but wasn't quite sure ;) @gfwilliams I don't know enough yet on the F3 USB stack to even consider being able to see the differences between it & the F1's / F4's so yup, switching boards is 'd be indeed a 'faster & safer' way ( although I could acquire quite a - not that useful afterward- knowledge on their particular implm changes ..)
If I recall coreectly, I noticed some Espruino files you pointed me to use 'stdPeriph' stuff & not HAL ? ( I may be incorrect on this, I'm still getting my head around the stm32f platform ..) On the examples I'm currently trying, I gotta switch from HID to CDC* ( then try the combo ;p ) & implement the xbox360 controller on that. If I manage to do so, adding its functionnality to Espruino builds would then 'just' be some js wrappers for C++ calls ( but this is a part I have yet to discover & cover ;P ) *to try an example doing UART communication with either a laptop or another uC. next on the list is I2C, then SPI ;) Do you have in mind a F4 board that would be a kick ass with many pins ? I plan ( & 'd love ) to use Espruino on a client project but I have to use something reliable ( so not my own mess around the F3 .. ), and since it focuses on an 'Escape Game' room, having plenty of pins is quite handy :D On the "Espruino Open Adaptive gamepad' topic, I was wondering if there's any USB stack on the nRF boards or the MDBT42Q ? My reasons:
Currently, I'm using an Espruino WiFi for the wifi part & the usb HID part, & a teensy for the xbox360controller part
*, ** how to know if padding is allowed by GCC ? do you have a quick way to log the size of a report being sent ? ( I'm windering how much I'd need to mod the HID code I'm using to be able to use one of the available uarts to print debig stuff .. since I don't know gdb yet :/ .. )
ps: I plan to produce 3ds for the 'espruino_OpenAdaptiveController.pdf ' at the end of the week :) I'll be back with updates as soon as can do, as usual :) Big thanks for the hints ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-10 by @allObjects @stephaneAG, ...the K was a low-hanging-fat-finger-of-a-lame-hand accident on the keyboard... it should just read HLHLHL. Thanks for pointing that out. I have though other crazy sequences used, where shorts and longs - SLSLSLS are mixed with R and G and B: see http://forum.espruino.com/comments/14358074/ - lines 237..259 where I create red and green Morse code blinking when no other logging is available... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-10 by @gfwilliams
Not really. However http://www.espruino.com/STM32L496GDISCOVERY has a bunch of pins, is fast, and has loads of RAM.
No, there's no USB at all on the nRF52832. There is on the nRF52840, but apart from a few test builds I have nothing targeting those, and while I had a USB serial test, USB HID gamepad support is miles off.
You could just print |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-12 by stephaneAG @allObjects haha ^^, it seemed so ;P @gfwilliams I just had a look at the beast .. indeed, but so sad that it doesn't offer every pins it provides on connectors :/ For my current needs & considering the price I guess an STM32F4DISCOVERY 'd be a nice fit if fully supported by Espruino :) On the nRF side, I just saw these & they seem quite neat ;) Since I don't know at all the nRF platform, I currently can't be of any help on these :/ For the struct size stuff, I tried the following quick test ( on laptop since I don't know yet how to get logs .. using stg else than leds now ;p ) and the result is the expected 6 ..
I'll try things out later today & report back :) & before I forget, I saw these links on some way to flash the HM-10 for custom HID stuff if I'm correct :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-12 by stephaneAG All right, I checked some things out, but it seems the F4 discovery board has been replaced by the STM32F407VG Also, do you think the following could work ok ( maybe with some tweaks* ? ) https://www.ebay.fr/itm/STM32F407VGT6-ARM-Cortex-M4-32-bit-MCU-Core-Discovery-Development-Board-STM32F4/263106386751 *reading the following's 1st page, is seems that the onboard chip is the same ? https://ucilnica.fri.uni-lj.si/pluginfile.php/21843/mod_resource/content/0/user_manual_stm_discovery.pdf I 'll have to check the diffs between the former & the latter ( don't know yet what 'T6' stands for ), but the 2nd one's pricing sparks my interest .. ;) thanks :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-15 by @gfwilliams I think the STM32F407VG discovery is probably just renamed? The one I linked to earlier (the L4) is something ST actually did some work on the Espruino port for though. I have no idea if the other board will work - you could try it, but you're on your own. For the vars, check out: https://github.com/espruino/Espruino/blob/master/README_BuildProcess.md#info And for the 52840, there are some posts on it already under the Porting to other boards is interesting, but I'm afraid I'm super busy and I just can't afford to spend time helping in the porting process. Also even if you do get a port, I'm afraid I'm not taking the new board files into Espruino at the moment. I currently have over 50 board files which I have to maintain if anything in the build changes, and I just can't manage any more - even as-is it means I'm dissuaded from making changes to the build process that would improve Espruino. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-15 by stephaneAG Hi there ! Thanks for all that :) Good to know for the L4 ( I bet the ST guys find Espruino very neat ;p ) Understood ( for "on my own" on the other board ): so I'll have that kind of fun if trying to do so ;) For the 52840, I just checked the topic you linked to: this is pretty cool ( can't wait to test/help on that subject .. & get fully custom HID over USB/bluetooth :D ) !! For porting to other boards, I bet you're more than busy hence I'll rely on digging myself & the community to sort things out ;) On the build process / build changes / improving Espruino side of things, I wish I had a solution to this but aside from more people full time I have no clues on how to help that ( other than digging & helping myself when I can afford to do so :) ) :/ On the "xbox360 passthrough" side of things, it seems the Teensy 3.6 offers usb host capability, so I'll try that as well as a tacky transistors+diodes setup ( just to see HOW it fails ;) ) I'll give back updates as I go :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-11-18 by gdsports stephaneAG, Still interested in xbox360 passthrough? I added xbox360 USB support to the Teensy 3.6 USB host stack. MSF-XINPUT has been updated by others for the latest Teensyduino. I can try an xbox360 pass through. Controller authentication is unlikely since I do not have a console. Should work on PC though. Is the Espruino adaptive controller different from the xbox360 passthrough project? Or are you running Espruino on the Teensy 3.6? I am confused. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-11-22 by stephaneAG @gdsports Hi there ! -> Kinda-still-very-much-interested indeed :D I was coming here for a quick update & few questions, and your intervention is unexpected & full of hope ^^ If you want some more infos on controller authentication, I can provide you the links I used while digging the subject :) Sorry for the confusion: The "Xbox360 passthrough" project would be a very neat addition to the "Espruino adaptive controller" project, since it could allow using it on ALL consoles ( additionally to a computer whatever the operating system its running, as appearing as standard HID peripheral ). Once of the reasons I'm digging a board other than the standard Espruino ones while keeping stuff on stm32 platform is:
Hence, two ways to achieve the desired goal(s):
The project is also intended as a rough template for other Espruino-based gamepads & cie ;) I successfully achieved HID gamepad on the STM32F407VGT6diymrOE board running only ST's code ( not Espruino ) when connecting to Windows, but for some reason it doesn't appear on Mac OS ( even with the external pull-up resistor trick, and even when pressing the btn prior to connecting the board :/ .. ) I also had success running an Espruino build meant for the STM32F4DISCOVERY on the STM32F407VGT6diymrOE board & connecting to it via Bluetooth using an hc-05, but not via USB :/ I'm currently digging ST's USB Host stuff & it's wayyyy over my head tight now :| ( too bad, gotta have to Digg more & harder :p ) I recently ( yesterday actually ) created a board.py to be able to better match the STM32F407VGT6diymrOE onboard components, but for some reason I can't use 'setUSBHID()' nor the related 'send()' fcn :/ ( I guessed this comes from a flag that isn't set when building - 'USEUSBHID' if I remember correcly, but I didn't intend a custom build yet, as this was one of my questions ;) ) On the same subject, I wonder if there's a way to set some pins as high by default within the board.py file ? ( I now know it's done in CubeMX or ST's main.c via stuff like I received some necessary parts ( TRRS & TRS connectors, USB connectors ) today & since I can't find the footprints of those, I just finished digging how to do custom footprints on Eagle to "port" my Illustrator drawings as soon as I finish reporting the dimensions & pinouts & go further on this part of the project This being said, the following is the board.py file I intend to use for building Espruino from the latest source ( same as the F4discovery but with less stuff / different on it ): I'm still unsure if this 'll work & the exact procedure to produce a clean build but I bet digging the "building" section won't hurt ( should be one of the easier methods since this is a stm32 board .. hoping so ;) )
The attached file ( if upload works ) is the pinout for the board + few handy wip notes ( I didn't take/have the time to do a proper "background-image" for the doc part, but this is incredibly handy as is as well ;P )Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-11-22 by stephaneAG all right, I still hope to find the footprints corresponding to those connectors, but at least now I have something to start with :) ( fingers crossed I won't have any troubles on Eagle side .. ) :)Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-11-24 by gdsports @stephaneAG In pass through mode, buttons and sticks work. Rumble and LEDs TBD. No support for console authentication. Tested on Linux running jstest-gtk and Windows 10 gamepad properties test. Also tested on the Steam/Valve network using the controller settings window. More than one controller may be connected at the same time using a USB hub. All controller output is combined to the XBOX360/Xinput emulator output. This is similar to the Xbox co-pilot feature because more than one controller can used to play one person in a game. Since the pass through is based on the PJRC joystick/gamepad example program, Xbox 360, Xbox One, PS3, and PS4 (?) controllers are supported. PS4 controller is still flaky. Mostly it comes down to remapping buttons from the PS4 to the corresponding buttons on the Xbox360. Hold on to the Xbox 360 console. I do not think I will have time to look at controller auth. Perhaps some one else would like to tackle that part. Same for Espruino and ESP8266. A Teensy 3.6 XBOX360 adaptive controller for Windows, Linux, and Steam games seems useful on its own. I do not know if it works on Mac since I do not have one. Twenty digital inputs all on the same side of the Teensy 3.6 board are set as INPUT with internal pull ups. A switch or button that grounds the input is detected as a button activation. I think assistive tech buttons/switches connect ground when pressed so this should work. The first eleven inputs map to the eleven buttons on the XBOX360 controller. The four more could be mapped to D pad inputs (TBD). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-11-28 by stephaneAG Hi there :) nice work ! For the rumble & LEDs, this could be really cool since we could update onboard stuff to reflect that ;) For the "more than one controller connect" / Xbox co-pilot feature, it's also pretty cool ( I actually didn't know Microsoft offered such functionality ). I didn't took the time to test the PJRC Joystick/gamepad example, only dogged through it among many other files to get an overview of how things were implemented ( I was planning to mod MSF-XINPUT to not auto-release stuff & press stuff received over serial as latest test using a teensy & the xbox360 part of things ) If mapping it all that's needed to get rid of the flakiness of the PS4 controller, I'd be happy to Digg that part when having time to doing so :) On the controller auth part, I honestly am still way too weak to produce it by myself, but I plan to continue digging the USB Host stack on the smt32 as well as figuring out how to handle that kind of event ( I guess the author of MSF-XINPUT may know or have some hints, since this boils down to knowing when a "led event" is received for the first time ( providing visual feedback of connection & on which player number is assigned to which controller ) & passing stuff through a different pipe when receiving some from the host console ) If you say so, I guess I'll then hold on to it for later .. For the usefulness of an adaptive controller ( Teensy or Espruino based ) for Windows/Linux/Steam/Mac, I totally agree, and I guess this will be the first version released ( able to connect over bluetooth or usb as HID since Windows/Linux/Mac need no drivers whatsoever & Steam surely can use HID-compliant devices ) On the way assistive tech devices works, I'll have to investigate too, and was indeed planning for such implementation ( the joystick connected to the sides of the adaptive controller will get 4 lines though, +V, X, Y & Gnd ) Last but not least, I'd be happy to fiddle with your code if you were to drop by some zip file ;) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-04 by stephaneAG Hi there ! I finally took the time to write a "little" helper after digging stuff online & not finding exactly what I was after .. .. "tadaa": https://github.com/stephaneAG/EAGLE-stuff/blob/master/Protographer/README.MD The above, while not yet supporting "pads", was indeed quite useful to quickly draw stuff Eagle side :) The below image shows the footprints created by it ( the one with the pads had the pads added manually ) I'll have to add the needed buttons to the schematic ( as well as battery charging & cie ) & the footprint for an HC-05 & an XS3868 For the uC part, I guess I'll prepare a "breakout" embedding all the necessary & then provide declinations offering different uC pins ( or the pads for directly soldering a uC - I wonder if I'll be precise enough to solder some SMD parts, since I only practiced that while switching memory ICs on ESP8266 :| .. so wayyy not confident on drag soldering a stm32f407VGT6 myself .. ;p ) Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-15 by stephaneAG
Hi there !
I was finally able to find the time to implement a "standard" USB HID GamePad as an Espruino module ( js only for now ) :D
Currently, the triggers are treated as digital buttons, but I'll soon take the time to update the code to support analog triggers ;)
So, YES, Espruino's should now be able to play CoD & GTA ;p .. and make some perfects on guitar hero hardcore ? -> better: make it count & let's do an Espruino-adaptive-controller !!! ;P ( seriously, I'm on it ;) )
=> enjoy :)
basic usage is as simple as Gordon's keyboard & mouse modules:
I plan to:
I also consider writing a little wrapper to make it easier to work with if needed:
Advises are welcome to the above draf of api :)
I also wonder if it'd be somewhat useful to retain the last gamepad state before any further update, as well as the timestamp & the timestamp diff with previous one ? ..
The module should also work to send stuff to an RN42* ( or an HC-05 with its HID firmware ) or an Espruino board based on bluetooth
I'll also try to get 2 gamepads & adding the possibility to pass a number of those to the module before it calls 'E.setUSBHID()' after a little rest ( digging through the USB HID docs can make one's eyes burn .. )
On a near subject ( & sorry if I repeat myself ), I have a wip lib aimed to generate hid report descriptors ( currently just easing the mapping between constants & their values ): it's not much but it 'd have been very helpful to write the above ;/ ( I'll add the constants digged to it as soon as can do ;p )
Every contribution is welcome ;)
https://github.com/stephaneAG/usbHidDescriptors
Last but not least, if anyone has suggestions on the 'hid way' to get output descriptors working on Espruino, it 'd be daaaaaaaamn cool :) ( the goal is to be able to send stuff from host to Espruino - and for the moment, the 'stuff' is not quite defined ^^ )
ps: while at it & if enough time to do so, I have some idea of a feedback mouse ;)
+
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions