/*---------------------------------------------------------------------------* Project: HID lib open and close module for KBD demo File: hid_open_close.c Copyright (C)1998-2007 Nintendo All Rights Reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: hid_open_close.c,v $ Revision 1.2 2007/10/18 18:44:29 henrch - added copyrigth header and history - added comments regarding memory usage - use OSGetMEMArenaLo $NoKeywords: $ *---------------------------------------------------------------------------*/ #include #include #define printf OSReport ////////////////////////////////////////////////////////////////////////////// volatile int __done; ////////////////////////////////////////////////////////////////////////////// static void hid_setup_handler(HIDError he, u32 user) { #pragma unused(he) *(int*)user = 1; } ////////////////////////////////////////////////////////////////////////////// void hid_open_async(void); void hid_open_async(void) { // This demo does not have allocator and nothing is using the arena so we // will just use the base of MEM2 address for the HID lib. USE AN ALLOCATOR // FOR YOUR GMAE!!! void *p_hid_mem = OSGetMEM2ArenaLo(); __done = 0; printf("calling HIDOpenAsync()\n"); HIDOpenAsync(p_hid_mem, hid_setup_handler, (u32)&__done); printf("wait for callback\n"); // This should be in some initialization loop, perhaps when you fade in a // screen and yo have to use a keyboard or other HID device for instance. while (__done == 0) ; printf("opened HID lib\n"); } ////////////////////////////////////////////////////////////////////////////// void hid_close_async(void); void hid_close_async(void) { __done = 0; printf("calling HIDCloseAsync()\n"); HIDCloseAsync(hid_setup_handler, (u32)&__done); printf("wait for callback\n"); // This should be in some clean up loop, perhaps when you fade out a // screen and you no longer need to use a keyboard or other HID device // for instance. while (__done == 0) ; // If you allocated memory for the HID lib it can be freed after the HID // lib is closed. printf("closed HID lib\n"); }