Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 645585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:31:09+00:00 2026-05-13T21:31:09+00:00

How do I detect a button press on a USB gamepad on OSX 10.5

  • 0

How do I detect a button press on a USB gamepad on OSX 10.5 and higher?

I can’t wrap my head around the ridiculously complex HID Manager (even though apparently it was simplified with 10.5), and the code samples at Apple have thousands of lines of code that would take days to understand and isolate what I need, so I’d appreciate if someone posts a simple, and fully coded solution for this isolated problem.


EDIT: so far all answers are links to source code or semi obscure libraries for all kinds of HID devices, which will require more research time than what I’d like to invest on this. I am starting a bounty to get an actual snippet of code that solves this simple problem (using an external library or not).


EDIT POS BOUNTY: thanks to all for you help; but unfortunately the answer that has been automatically selected by the system is not working for me, can’t figure out why; and the author has not yet replied to my comments. Any insight would be appreciated, but until a fix is found, anyone looking for resources on this topic should take this answer with a pinch of salt.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:31:09+00:00Added an answer on May 13, 2026 at 9:31 pm

    Peter’s suggestion of the DDHidLib framework is exactly what you are looking for. The library is well designed and the sample code that comes with the library is pretty self-explanatory.

    An implementation of an object that gets all the joysticks/gamepads attached to the system and watches for button presses using DDHidLib would look something like this:

    #import <Cocoa/Cocoa.h>
    #import <DDHidLib/DDHidLib.h>
    
    @interface JoyStickWatcher : NSObject
    {
        NSArray* joySticks;
    }
    - (void)startWatchingJoysticks;
    @end
    
    
    @implementation JoyStickWatcher
    - (void)startWatchingJoysticks
    {
        //get an array of all joystick objects
        joySticks = [[DDHidJoystick allJoysticks] retain];
    
        //become the delegate of all available joystick objects
        [joySticks makeObjectsPerformSelector:@selector(setDelegate:) withObject:self];
    }
    
    - (void)dealloc
    {
        [joySticks release];
        [super dealloc];
    }
    
    //these are the DDHidLib joystick delegate methods related to buttons
    
    - (void)ddhidJoystick:(DDHidJoystick *)joystick buttonDown:(unsigned)buttonNumber
    {
        NSLog(@"button number %ld of joystick %p went down",joystick,buttonNumber);
    }
    
    - (void)ddhidJoystick:(DDHidJoystick *)joystick buttonUp:(unsigned)buttonNumber
    {
        NSLog(@"button number %ld of joystick %p went up",joystick,buttonNumber);
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way i can detect for how long a button is press??
How can I detect the right button?? (used to show shared methods) For example,
This is a question on how to detect which button was clicked in the
Is there anyway to detect which mouse button was clicked from inside a QItemSelectionModel?
I am looking for a way to detect if a button was pressed in
I have a webform and i want to detect if F5 button was pressed
How to detect click (including browser's back button) events using javascript?
To detect rotation of the mouse wheel in .NET/WinForms, I can override OnMouseWheel .
I want to detect voice of any buddy(Note: i am not going to press
How can I detect that an app has just returned from background mode? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.