/*---------------------------------------------------------------------------* Project: HID library File: hid.h Programmers: Henry Cheng Copyright (C) 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. *---------------------------------------------------------------------------*/ #ifndef __HID_H__ #define __HID_H__ #ifdef __cplusplus extern "C" { #endif ////////////////////////////////////////////////////////////////////////////// typedef u32 HIDDeviceHandle ; #define HID_ERROR_OK 0 #define HID_ERROR_NOT_OPEN -1 #define HID_ERROR_ALREADY_OPEN -2 #define HID_ERROR_FIRMWARE_VERSION -3 #define HID_ERROR_FIRMWARE_MALFUNCTION -4 #define HID_ERROR_BUSY -5 #define HID_ERROR_CANCELLED -6 //--- #ifndef HID_ERROR_CODE #define HID_ERROR_CODE s32 #endif #define HID_ERROR_NONE 0 typedef struct { u32 handle; u32 physical_device_inst; u16 vid; u16 pid; u8 interface_index; u8 sub_class; u8 protocol; u16 max_packet_size_rx; u16 max_packet_size_tx; } HIDDevice; typedef struct _HIDClient HIDClient; #define HID_DEVICE_DETACH 0 #define HID_DEVICE_ATTACH 1 typedef int (*HIDAttachCallback)( HIDClient *p_hc, HIDDevice *p_hd, u32 attach ); struct _HIDClient { HIDClient *next; HIDAttachCallback attach_callback; }; #ifndef HID_CALLBACK typedef void (*HIDCallback)( u32 handle, HID_ERROR_CODE error, u8 *p_buffer, u32 bytes_transferred, void *p_user ); #endif ////////////////////////////////////////////////////////////////////////////// // API ////////////////////////////////////////////////////////////////////////////// HID_ERROR_CODE HIDSetup(void); HID_ERROR_CODE HIDTeardown(void); HID_ERROR_CODE HIDAddClient(HIDClient *p_client, HIDAttachCallback attach_callback); HID_ERROR_CODE HIDDelClient(HIDClient *p_client); HID_ERROR_CODE HIDGetDescriptor(u32 handle, u8 descriptor_type, u8 descriptor_index, u16 language_id, u8 *p_buffer, u32 buffer_length, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDSetDescriptor(u32 handle, u8 descriptor_type, u8 descriptor_index, u16 language_id, u8 *p_buffer, u32 buffer_length, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDGetReport(u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDSetReport(u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDGetProtocol(u32 handle, u8 interface_index, u8 *p_protocol, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDSetProtocol(u32 handle, u8 interface_index, u8 protocol, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDGetIdle(u32 handle, u8 interface_index, u8 report_id, u8 *p_idle, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDSetIdle(u32 handle, u8 interface_index, u8 report_id, u8 duration, HIDCallback async_callback, void *p_user); HID_ERROR_CODE HIDRead(u32 handle, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); HID_ERROR_CODE HIDWrite(u32 handle, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); HID_ERROR_CODE HIDResetDevice(u32 handle, HIDCallback async_callback, void *p_user); void HIDDecodeError(HID_ERROR_CODE hec, u32 *p_category, s32 *p_code); ////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus } /* extern "C" */ #endif /* __HID_H__ */ #endif