Welcome! Log In Create A New Profile

Advanced

Detect sd insertion.

Posted by arasium 
Detect sd insertion.
January 12, 2010 12:56PM
Hello, how can i detect the sd insertion (like in the HBC)?

I've searched some callback functions, but i haven't found anything.
Re: Detect sd insertion.
January 12, 2010 03:31PM
IIRC they exist but aren't documented anywhere. I believe you have to issue a IOS_IoctlvAsync call, specifying your callback function and using IOCTL_SDIO_SENDCMD with cmd=64.



Edited 1 time(s). Last edit at 01/12/2010 07:09PM by tueidj.
Re: Detect sd insertion.
January 12, 2010 04:50PM
That sounds like a pretty lowel level approach! You could also try something like the following:

#include < sdcard/wiisd_io.h >

if(__io_wiisd.startup() && __io_wiisd.isInserted())
printf("YAY!");

See Snes9x GX fileop.cpp for an example.
Re: Detect sd insertion.
January 12, 2010 10:57PM
Tantric, you solution is ok if i need to test the sd. But me i want to be alerted whn the sd in inserted/remove (the goal is to automatically mount/unmount the file system)


tueidj, i will inspec in that way. And what about the usb, is there a similar ios call?
Re: Detect sd insertion.
January 12, 2010 11:51PM
USB is actually simpler, the functions exist in libogc - you just have to tell it what sort of device you're watching for.
Re: Detect sd insertion.
January 13, 2010 01:20AM
Quote
arasium
Tantric, you solution is ok if i need to test the sd. But me i want to be alerted whn the sd in inserted/remove (the goal is to automatically mount/unmount the file system)
Add a bool, a ! version of the if, put it on a thread, and viola!
Re: Detect sd insertion.
January 13, 2010 10:17AM
Yes i can put it on a thred, but it isn't very good. It will consume cpu time. And i'm pretty sure that there is a hardware interupt when a device is pluged. It's that interupt that i want catch.


@tueidj: can you tell me what function i need to use for the usb. i've search it in header files and i've not found it.



Edited 1 time(s). Last edit at 01/13/2010 10:22AM by arasium.
Re: Detect sd insertion.
January 13, 2010 11:28AM
The last time I checked it was called:
s32 USB_DeviceInsertNotifyAsync(const char *devpath,u16 vid,u16 pid,usbcallback cb,void *usrdata);
in usb.c, it doesn't seem to be in the latest usb.h (not sure it ever was).
Re: Detect sd insertion.
January 13, 2010 02:16PM
ok, thank you. It is exactly what i need :) I will do some tests with that
Re: Detect sd insertion.
February 25, 2010 10:25AM
So, i've made some tests on usb sticks. And it seems that we need to know the pid/vid to use the insert notification.

Thank you tueidj
Re: Detect sd insertion.
February 26, 2010 11:06PM
Quote
arasium
Tantric, you solution is ok if i need to test the sd. But me i want to be alerted whn the sd in inserted/remove (the goal is to automatically mount/unmount the file system)


tueidj, i will inspec in that way. And what about the usb, is there a similar ios call?

Uhh what else do you think isInserted() does? It does those low level calls to tell you whether sd/usb is inserted or removed. Just keep track of the current state and gee, when the isInserted() value changes, it was inserted/removed. Seriously, I've had this functionality in Snes9x GX for a year and a half. It really isn't that hard to use, the functions have always been there.



Edited 1 time(s). Last edit at 02/26/2010 11:07PM by Tantric.
Re: Detect sd insertion.
March 01, 2010 04:33PM
Yes i know. But i were searching for an hardware interuption when a device is inserted.

I don't want any thread running behind to detect usb insertion (ie using isInserted) because i don't need this. It will consume cpu time.
Sorry, only registered users may post in this forum.

Click here to login