Use of analog gamepads with lowlevel.library
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    Hello all, MorphOS supports analog gamepads, presumably USB ones, via lowlevel.library, so I'd like to support this (preferably including rumble support too) on my emulator (AmiArcadia) when it detects that it is running under MorphOS.
    But there does not seem to be any tutorials or examples on how this is done. I have lowlevel_ext.h and could have a stab at doing it by guesswork, but since I don't actually have MorphOS to test with, I'd rather base it on example code that has already been tested and is known to work. I've had a look in the MorphOS SDK, on MorphOS Files, and on Aminet, but haven't found anything relevant.
  • »12.04.10 - 03:04
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1516 from 2003/2/24
    From: Finland
    SDL supports analog sticks. Presumably it even works although I havent tried it for ages but you can check source for implementation. Rumble is not supported.
    1 + 1 = 3 with very large values of 1
  • »12.04.10 - 06:20
    Profile
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    Baiscally, all you have to do is:
    ReadJoyPort(unit) to get the usual digital positions
    ReadJoyPort(unit + JP_ANALOGUE_PORT_MAGIC) to get the new analogic positions.

    And, of course, check for JP_TYPE_ANALOGUE to know if the feature is really supported (although usually nobody checks for JP_TYPE stuff:).
  • »12.04.10 - 10:35
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 780 from 2007/10/23
    From: Gelsenkirchen,...
    Ask Geit <geit at gmx.de>, he made the first Amiga rumble game 8-)
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17", MorphOS 3.18
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.18
  • »12.04.10 - 11:43
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    OK, I've implemented this now, thanks all for your help.
  • »12.04.10 - 14:49
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    sorry to reopen this topic, but for a project i need to read the 2 analog axes of my gamepad.
    Is this possible?
    from the example Analog joysticks via lowlevel.library.c an from the SDL
    only one stick is read.
    there is a workaround for use the second one also?

    maybe some mask or offset to read the second stick?


    [edited my engrish explaination]

    [ Edited by raistlin77it on 2010/8/4 21:38 ]
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »04.08.10 - 18:22
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    Now that I have a MorphOS machine to test on, I can see that this feature doesn't work at all.
    AFAICT there is no error on my side, so this must be yet another MOS bug... :-(
  • »08.03.12 - 13:04
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    no it's not a bug infact i've found the solution like 2 years ago :D

    from the programmer POV :

    first you have to enable the "analog hack" from poseidon
    second read this aros example : http://en.wikibooks.org/wiki/Aros/Developer/Docs/Libraries/LowLevel
    it works flawlessy on morphos too

    From the user POV:
    remember to enable the "analog hack" option on poseidon

    [ Edited by raistlin77it 08.03.2012 - 13:03 ]
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »08.03.12 - 13:53
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Jupp3
    Posts: 1193 from 2003/2/24
    From: Helsinki, Finland
    I've asked about support for >2 axis for a long time. Usually the answer has been "Well, are there any games that would require it anyway?" (and the answer is "No, because they wouldn't work too well without")

    Of course this isn't quite true, as MAME has several games that benefit from them (including one of my favourites, thunderblade)

    If I'll ever finish my helicopter game (or the library it depends on), that will definitely be one :-P
  • »08.03.12 - 16:42
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    @Minuous

    Can you verify your analog stick is working at all with Poseidon ?

    Open the USB prefs -> Devices -> your joypad -> Settings -> Action
    You should see some "axis" listed under "Usage items". They are your analog stick(s).

    Then check [x] Track incoming events
    And you should see some axis activity when you move the analog stick.


    @Jupp

    If wanted, you could easily use JP_ANALOGUE_PORT_MAGIC on two lowlevel units. Then you map the second analog stick of your joypad to the axis of lowlevel unit 0 and voila...
    Your game can now read the two analog sticks of one single joypad :-)

    Edit : raistlin explained the same thing while I was editing. Damn :)

    [ Edited by Henes 08.03.2012 - 20:36 ]
  • »08.03.12 - 20:30
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 186 from 2003/10/23
    To use the second analog joy, you must assign it like a second joystick (for example left joy as joy in port 0 and the other in port 1 ) and enable the analog hack on this "second" joy

    From my testings (i have only 2 joy) the trhustmaster dual power 3 isn't usable in dual analog,but the logiteck dual yes.

    i don't know how mame works internally, but if support 2 different joystick for one player, maybe can be configured like previously explained

    here a little program to veryfy if the dual analog work:) if work, u can move the 2 squares with the 2 analogs (it needs sdl)

    http://www.mediafire.com/?nj6aizmpz5fnuwa

    [ Edited by raistlin77it 08.03.2012 - 19:45 ]
    I'm nerdy in the extreme
    And whiter than sour cream

    White&Nerdy 2006 Al Yankovic
  • »08.03.12 - 20:32
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    >Then check [x] Track incoming events and you should see some axis activity when you move the analog stick.

    Yes, that works.
    I also tried with AmiArcadia. The gamepad axes, buttons, etc. works fine in AmiArcadia; the only problem is the lack of force feedback. The gamepad is a "Gameware USB Rumble Control".
    Also tried Boulderdash, which apparently has rumble support, gamepad works to play the game but there are never rumbles.
    I have changed port 1 from "USB port" to "Analogue Hack" as suggested. Rumble Port is set to port 1 (BTW does this mean that 2 gamepads cannot rumble simultaneously?).
  • »09.03.12 - 08:46
    Profile Visit Website
  • MorphOS Developer
    geit
    Posts: 1032 from 2004/9/23
    If you open usb settings, there is an "open now" button in the top right of the section "HID output control window" marked section.

    It opens a window with sliders for the two rumble engines inside the controllers and you can test if they work.

    Anyway, it is possible, that they are not, as there is (if I remember right what Platon told me) no real standard for that. Just some "most devices work like that".

    So if it fails, then probably your device works different. Real Playstation2 controllers are no guarantee too, as the used adapter manages the HID stuff.

    Geit
  • »09.03.12 - 11:20
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Minuous
    Posts: 161 from 2010/2/13
    >If you open usb settings, there is an "open now" button in the top right of the section "HID output control window" marked section. It opens a window with sliders for the two rumble engines inside the controllers and you can test if they work.

    Sometimes clicking that button does nothing. Other times it will open the window you described. The leftmost two sliders do nothing, the third one has a large rumble effect, and the fourth one has a small rumble effect.
    For some reason it still doesn't work in AmiArcadia though. The call I'm using to turn rumble on is:

    SetJoyPortAttrs(joy, SJA_RumbleSetFastMotor, 255, TAG_DONE);

    where joy is the appropriate unit, but it is having no effect. Maybe it is trying to use one of the ineffective rumblers? Is there a way to specify eg. the 3rd rumbler? Is there any example source code that I can study?

    I've also noticed that ReadJoyPort() ignores buttons 8-12 on the gamepad, even though they work fine in Preferences.

    [ Edited by Minuous 11.03.2012 - 11:53 ]
  • »10.03.12 - 16:08
    Profile Visit Website