Gamepads / IOHID: Analogous values for RT, LT?

Discussion in 'Mac Programming' started by digory, Jan 2, 2013.

  1. digory macrumors newbie

    Jan 2, 2013
    Hi there!

    I'm implementing a class that listens to gamepads using Apple's IOHID API. Currently, the following works: When I plug in a gamepad, the class recognizes it. A, B, X and Y buttons are read as booleans, while joystick values XY and PO are read as doubles. (For the latter, I fetch min and max for the element and scale the integer value so it always stays between -1..+1.)

    So far, so clear. The problem is that the two lower back buttons (RT, LT) always return either minimum or maximum values, i.e. bools, but they really should be analogous, i.e. doubles like XY and PO.

    I've googled a bit and learnt that this is where XInput comes in. There is a switch at the back of my Logitech Gamepad F310 that lets me choose between XInput and DirectInput. Mac OS X does not seem to be able to deal with XInput enabled, so I always leave the switch to DirectInput.

    -> Is it possible to read the analogous values of RT, LT with DirectInput switch enabled?
    -> If not, is it possible to set up a IOHID dictionary that recognizes the device when XInput is enabled?
    -> Is there any other trick I could try?

    Thanks for any replies!
  2. ytk macrumors regular

    Jul 8, 2010
    I can't help you directly with your problem, but you might want to give ControllerMate a try, just to see if it can read the values you're looking for. That would at least tell you there's some way to do it. If ControllerMate can see the gamepad but can't read the data, there's a good chance it's not readable at all.
  3. digory thread starter macrumors newbie

    Jan 2, 2013
    Thanks for your reply. I've just tried ControllerMate. Apparently, it can't access the device either when it's in Xinput mode (although it would show up in System Profiler). When it's in DirectInput mode, it reads LT and RT as boolean values, not analogous values.

    That's very bad! No wonder there's so few games for the Mac if even this simple thing doesn't work...

    Well, there's still a chance: I'm still using OS X 10.6. Maybe Mountain Lion supports Xinput?
  4. ytk macrumors regular

    Jul 8, 2010
    Bummer. I wouldn't hold out much hope for getting this to work, then.

    Just out of curiosity, what device are you using?
  5. digory thread starter macrumors newbie

    Jan 2, 2013
    A Logitech F310.

    This is even worse: DirectInput mode seems to be restricted to 16 elements, thus the up/down/left/right cursor buttons won't work. Unless you press the [mode] button on the device; then these buttons send values for the analogous joystick, while the joystick will stop sending values.

    So that's what the [mode] button is for, after all.

    I need to find a Mac OS X driver for Xinput then. Or write one. ;)
  6. JordanTrana, Jan 16, 2013
    Last edited: Jan 16, 2013

    JordanTrana macrumors newbie

    Jan 16, 2013
    I've been writing a GamePadManager for my company for the last two weeks. I actually own my very own set of two Logitech F310s.

    I got Bad News, the boolean input your getting isn't by fault of Mac's IOHIDManager. Instead it's because the F310 Triggers only FEEL like triggers and are really just buttons disguised as triggers. I've played games with them before (Rayman Origins, GTA4) and I'm pretty sure it's just a button in the trigger. It's possible the F710 from Logitech is better in this regard, alas we do not have that controller and I do not know if it's triggers are legit.

    Try an XBox 360 Controller for Windows. Of all the controllers I've been testing here at the office, it's the only one that has triggers. The Driver for Mac works fantastically. It's also the most sensitive Controller I've tested on top of being the best laid out when it comes to the CookieIDs!

    Further Note on F310:
    the 'Mode' Button is used to swap the Left Analog Stick input with the HatSwitch input from the D-Pad. Your Input being switched between a 0-37000(or some big number like that) and a number between 0 - 315 (with 360 being the 'no buttons pressed' mode for the HatSwitch which is your D-Pad). So when these numbers are switched with the Analog Stick, that's probably why your values are so low. the HatSwitch is returning a Decimal Number between 0-360 to represent the direction your D-Pad is being set too. This can be switched with the Analog Stick. Why they are setting up the GamePad that way? That makes little sense to me.
  7. nealhen macrumors newbie

    Dec 21, 2014
    Well this sucks. I bought f1 2013 in the app store and then went out and bought an F310 to play it with. So now I have no analog input for steering and breaks unless I use the right stick which is annoying. The instruction leaflet that came with the controller does say that the triggers are analog when used with XInput.
  8. Madd the Sane macrumors 6502a

    Madd the Sane

    Nov 8, 2010
    As each game pad has their buttons mapped differently, the best way to handle such is to have a repository of controller mappings.

    SDL2 does have some of this in it.

Share This Page

7 January 2, 2013