List of connected devices?

thaeez
Unregistered
 
Post: #1
Hi all,

Is there an easy way do get a list of everything conneceted to a computer (i.e. usb/firewire drives/mice/keyboards/controllers/etc.)? Ideally, I'd like to be able to know everything about a machine including installed memory, video card, etc... How does the Apple System Profiler do all this? Thanks in advance,

thaeez
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #2
For USB, mice, keyboards, etc. use HID. Which will not be fun at all.

For the other stuff, no idea if there is any access to that information from the APIs.
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #3
Huh. I used to have some code lying around that actually did that since I needed to figure that out for a project at work. A lot of it was built from sample code that I got from Apple's developer website. Poke around for stuff using IOKit. I'm pretty sure that's what the System Profiler uses.

Edit: On second thought, I'll just clean up what I have and make it available for download on my website.

Edit #2:
And here it is: http://www.malarkeysoftware.com/freecode.html

You could also call system_profiler from the command line with the -xml option and parse the xml output using TinyXML or the like.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #4

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #5
Open a terminal, and type
Quote:system_profiler
and be amazed! Smile

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #6
I think he asked how does system_profiler do it..

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
thaeez
Unregistered
 
Post: #7
Hi all,

Thanks for your replies.

It looks like the sample code that Malarkey provided will work well for the general system information (thank you very much Malarkey - nice job!), but I still don't understand how I can get a list of USB / FireWire devices. It looks like the code at http://www.idevgames.com/forum/showthread.php?t=13336 might be useful, but I've never worked with HID and I don't understand it (usagePage? usage? huh?).

Any further suggestions on how I could get a list of attached devices (and their names)?

Thanks again for all your help...

thaeez
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #8
I don't think the HID stuff (which is mainly for keyboards, gamepads, etc.) will work for getting all USB / Firewire devices. Your best bet is to probably start here:

http://developer.apple.com/reference/Har...-date.html

And look through the sample code and references (assuming you haven't done so already). I'd also search through Apple's mailing list archives at:

http://lists.apple.com/archives/

Good luck!

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #9
HID isnt mainly for keyboards, gamepads, etc, its for Human Interface Devices, and it will list all USB devices. I dont know about firewire though.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
As was said way back at the start, the IOKit will provide access to all devices. HID will only do USB HID (a subset of all USB) devices.

If I were attempting this, though, I'd be doing what Malarkey suggested -- getting System Profiler to output XML and parsing that, rather than dealing with the IOKit.
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #11
unknown Wrote:HID isnt mainly for keyboards, gamepads, etc, its for Human Interface Devices, and it will list all USB devices. I dont know about firewire though.

Well, using the code that I have that's based off of HID Utilities, it doesn't list my camera, iPod, or thumbdrive as a USB device so no, I don't think it will list every USB device attached.

Just to get back on topic, I came across this bit of sample code that sets up callbacks for when USB devices are added or removed:

http://developer.apple.com/samplecode/US...index.html

Might be handy for thaeez in figuring out what devices are currently attached.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
Member
Posts: 78
Joined: 2004.06
Post: #12
[unrelated]
Woha!!!!
Another Mac game dev'er from my town in the middle of nowhere! (figuritavely speaking). That's pretty cool....
[/unrelated]

When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Porting Help: Input Devices gregorypierce 6 3,931 Dec 29, 2002 05:44 AM
Last Post: NCarter