Game pad and joystick support
Dave Higton (1515) 3404 posts |
If you have a USB joystick, plug it in and try it. I tried a couple of graphics tablets earlier this year (not the same thing as joysticks, I know). To my surprise, they both worked after a fashion. The area of screen they worked over was wrong in both cases, so I suspect that either the HID descriptors were wrong, or they were being misinterpreted. The GM-1300 I was playing with was horrifically non-linear. The range in each axis was only part of an 8-bit range, and the mechanical centre point produced codes that were way different from halfway between the two extremes. Thus calibration is an issue; you have to do at least a 3 point calibration (centre and both extremes) for each axis. Awful. |
SeñorNueces (1438) 160 posts |
I have tried with my PSX pad, which uses a very common USB interface (Bus 002 Device 005: ID 11ff:3341, according tu GNU/Linux lsusb) but it doesn’t seem to do anything anywhere: I tried several native games (Twinworld, Zool, Doom, Chuckie Egg) and some ADFFS games, and it’s not detected anywhere. |
Richard Walker (2090) 416 posts |
It won’t work as is. A USB Joystick or gamepad should appear as a USB HID. What is missing is converting this into the various Joystick_ SWIs so that games will recognise it. Apparently the HID utility will do this, but I have been unsuccessful in my attempt to buy it. I quite fancy trying to resolve this myself. I am a programmer but my RISC OS programming experience is minimal. I guess I need to write a module, and I would prefer C over ARM assembly language. Where to get started? The DDE? Where do I find suitable samples of modules in C? Best practice guides etc? |
Richard Walker (2090) 416 posts |
Here is info about HID http://www.xat.nl/en/riscos/sw/usb/hid/ |
Jeffrey Lee (213) 6046 posts |
Both the DDE and GCC support writing modules in C, and both come with simple skeleton examples of C modules. If you want non-trivial examples of C modules, I can think of the following two examples:
Disclaimer: I’m sure other examples exist, these are just two that I’m familiar with, because I happened to work on them ;-) Also worth noting is that whatever compiler you use, the method of writing a module is pretty much the same. You’ll have a configuration file (BCMSupport: cmhg.BCMSupportHdr, vnc_serv: cmhg.header) which defines the content of the module binary header (module name, SWI chunk, SWI names, etc.) along with any other entry points to the module from external code (e.g. vector handlers). This file gets sent through a tool (DDE: CMHG, GCC: cmunge) to create the header object file and a C header file containing relevant definitions/prototypes for use by the C code. The external entry points are listed in the file so that the tool can generate “veneers” which will set up the C environment before jumping into the relevant C function. So when you e.g. claim a vector you need to make sure you pass the OS the address of the veneer routine, not the C function. cmunge started as a free clone of CMHG, so the input and output of both tools are pretty similar. |
Rick Murray (539) 13406 posts |
If you have the DDE, here’s an annotated explanation of writing a module in C: http://www.heyrick.co.uk/blog/index.php?diary=20150323 |
Richard Walker (2090) 416 posts |
Thanks Jeffrey and Rick. I think I should explore more! I did a quick Google search before I posted, but Rick’s blog entry didn’t appear. That’s just the sort of intro I wanted. I’m erring towards the DDE, although I do have some questions on that. It seems a no-brainer to buy NutPi rather than the standalone DDE. But are they the same? Are there any release versions/dates? I have also noticed comments here on zero page issues. Should any of that worry me? Didn’t know what CMHG/cmunge was all about, but your explanation makes sense! I used RISC OS (and the Beeb) for many years as a user and dabbled with BASIC, but to my shame, nothing much else programming wise. The day job involves all sorts of Microsoft development tech, so I just need to get used to StromgEd/Zap rather than Visual Studio! |
Rick Murray (539) 13406 posts |
Hmm. I wonder how Google categorises my blog, given that it simply does not seem to appear in the first ~5 pages?
The NutPi DDE is supposed to only work on the Pi (akin to much of the rest of the NutPi stuff). When I say “supposed to”, I think NutPi appears to be compatible with the Pi and Pi2. It may or may not work with a Pi3. I think the NutPi version of the DDE is release 25. If software does dumb things (reading from uninitialised pointer, for instance), with the “low vector” version of RISC OS things will work, as the memory exists and something is there (it’ll just read whatever is there). A brilliant example of this – have you ever come across the infamous “oflaoflaofla” error? Well, that’s what happens when you try to use &0 as an error block. ;-)
Mmm, basically the two perform the same job. That is to present a veneer between RISC OS and the C code. For RISC OS it presents a “module” interface that RISC OS can understand (SWI decoding table, servicecall table, module header, etc). When an entry point is taken, the code generated by CMHG will bash the RISC OS API into something that makes sense to the C runtime. And vice versa on the way out. |
Sprow (202) 1113 posts |
If you’re a new user learning about terms such as CMHG and similar RISC OS specifics, you might benefit from the box set of manuals available from ROOL. The only reason I mention that is your DDE developer number gets you a 20% discount, whereas a NutPi wouldn’t, so it’s not quite such a no brainer. By my maths
I don’t know where you live so if you’re in EU/UK there’s about £8 of VAT to add. Postage would be the same for both so isn’t important in my comparison and books are zero rated. |
Colin Ferris (399) 1748 posts |
Most of the Books seem to available as PDF’s so that may be an option. I think I have asked before – could sound – espeak be added to the !PDF reader? Or do any Windows PDF readers – read out loud? |
Rick Murray (539) 13406 posts |
…plus proper DDE owners qualify for discounts on future updates. |
Richard Walker (2090) 416 posts |
Hmm, maybe I was too quick to judge! Having looked over their web pages again, I feel no more informed. The NutPi availability announcement was some time ago, but it specifocally points out that it is cheaper than the DDE itself. The last DDE announcement mentions useful-sounding fixes and enhancements, and suggests that reduced/zero price upgrades from previous versions are possible. Going back through the news on this site, NutPi was updated in May 2015 (and that included the DDE as it was at that time). It seems the DDE itself was updated in October 2015 (DDE26). I have a feeling that the NutPi version of the DDE is therefore one step behind. And a new purchase of NutPi wouldn’t qualify for a free DDE upgrade to the latest? Or even a £25 update to the next version? (whenever that may be!) Regarding documentation, the DDE info mentions that it includes comprehensive documentation. But it doesn’t specifically state that the PDF RISC OS PRMs are included. Are they? Actually, I am ashamed to admit that when I bought RISC OS 4 for my Risc PC, I took up the cheap option to bundle the PRMs on CD. I thought it might bump me into action – clearly it didn’t work. So I do actually have the PRMs somewhere! |
Rick Murray (539) 13406 posts |
In my experience, text-to-speech is only really useful in Google translate – if you have a complicated looking thing in French (or pretty much anything in Japanese), you can tap the speaker icon to hear it read out to you.
Sort of, but probably not in the general sense.
You may find that some ass-brained stupidity has rather stomped upon the desire to make e-books be able to be read aloud. http://www.theregister.co.uk/2002/12/10/im_no_hacker_sklyarov_tells/ Apparently the DMCA (thou shalt NOT) trumps existing sale doctrine (ability to make an archival copy, fair use by copying content to a book-speaker device for blind people, etc). Perhaps in recognition of this, Adobe Reader now has a “Read aloud” mode. It sounds absolutely awful, like something from the eighties. I’ve just made a short video so you can hear it: https://www.youtube.com/watch?v=x8UZOnySwhI But… wait… hang on… you want to read the PRM out loud? Hooooeee, that’ll be interesting.
…Documents.Manuals: ABC, Assembler user guide, C/C++ user guide, DDE user guide, PRM1/2/3/4/5A, Style Guide, Toolbox guide.
For a |
Jon Abbott (1421) 2601 posts |
I had a look at !HID…apart from it being the most unuser friendly app I’ve ever seen to configure, it doesn’t look like it does translate HID Joysticks to the RISCOS Joystick interface. The description for the Joystick function says it translates it to Mouse movement. Unrelated, I also tried to configure keyboard remapping on it via its learn function, but it ignored all the keys I pressed except for a few it appeared to already know about. Regarding Joysticks in general, on my list of things to do is implement translation from the Acorn Joystick module to the legacy Joystick interfaces such as RTFM and The Serial Port, allowing you to play just about any legacy game on ARMv5/v7, regardless of the Joystick interface it supported. I just need RISCOS to support HID Joysticks first, so if someone is planning on looking at this I’d be interested. The list of games that now run on the Pi is quite long and I’m certain quite a few of them suport Joystick. |
Rick Murray (539) 13406 posts |
I played around with a crappy old USB joystick one evening – https://www.riscosopen.org/forum/forums/5/topics/3377 The code is pretty simple. If you can extract the HID data to make sure it’s a joystick (I couldn’t be bothered to figure out how to do that), it would likely be pretty simple to put together a little module to notice this device and either fake mouse movement or the joystick API. There’s a description of how it works, the protocol etc, on my blog – http://www.heyrick.co.uk/blog/index.php?diary=20150608 – about two thirds of the way down. |
Richard Walker (2090) 416 posts |
Rick, I did see that earlier. When I had a brief look, I thought it was all fairly understandable, so trying to turn it into a module with some support for the various Joystick APIs seemed like a good ‘first project’s. I dunno, maybe I am aiming too high? We’ll see. As the weather turns, I should be able to spend some time on it. |
Anthony Vaughan Bartram (2454) 455 posts |
Hi Richard, I’d be happy to add Joystick support to existing & future AMCOG titles. Xeroid would be good fun to play on a Joystick. Dave – I have a dirt cheap Wacom Bamboo tablet, which worked perfectly first time. I used it to design some of the graphics for my games. |
David Feugey (2125) 2687 posts |
Can we find it on eBay/Amazon? |
Dave Higton (1515) 3404 posts |
Some questions for joystick/gamepad experts: Should the mechanical gate of a stick be square or circular? If it’s circular (e.g. the GM-1300’s sticks have circular mechanical gates), should it be the incircle or circumcircle of the logical gate? |
Dave Higton (1515) 3404 posts |
No opinions? Or am I speaking a language no-one understands? |
Chris Evans (457) 1614 posts |
Square. |
Jeffrey Lee (213) 6046 posts |
I’m not a gamepad/joystick expert, and didn’t fully understand what you were asking, so I ignored the question :-) However from experience I can say that the thumbsticks on most gamepads have circular mechanical gates. Out of the big three, only Nintendo seem to stray from the norm, favouring octagonal gates for some of their controllers (So the cardinal directions and diagonals are easy to find, I assume). I’m not really sure if there’s any standard way of mapping the mechanical input to logical input. If the logical inputs are scaled to be within a -1..1 range then I’d assume that the input would be mapped such that full deflection in any direction ideally results in a unit length vector, but it’s possible there’s some non-uniform mapping going on as well. For joysticks I’d expect the situation to be different – joysticks are mainly used to mimic the flight stick of an aircraft where you’re controlling entirely independent control surfaces, so having motion in one direction restrict the range of motion in another doesn’t make sense. So I’d expect square mechanical gates there. |
Clive Semmens (2335) 3130 posts |
- interdependent + independent I suspect? |
Jeffrey Lee (213) 6046 posts |
Yes! Post corrected. |
Anthony Vaughan Bartram (2454) 455 posts |
“Can we find it on eBay/Amazon?” Hi David, Moving the pen just above the table allows the cursor to move with contact acting like a left click. |