Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic usb HID controller driver based on the usb keyboard driver #115

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ OGCOBJ := \
gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
message.o card.o aram.o depackrnc.o decrementer_handler.o \
depackrnc1.o dsp.o si.o tpl.o ipc.o ogc_crt0.o \
console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o usbmouse.o \
console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o usbmouse.o usbcontroller.o \
sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
sdgecko_io.o sdgecko_buf.o gcsd.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \
texconv.o wiilaunch.o
Expand Down
17 changes: 17 additions & 0 deletions gc/ogc/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@
#define USB_ENDPOINT_IN 0x80
#define USB_ENDPOINT_OUT 0x00

#define USB_REPORT_USAGE_PAGE 0x04
#define USB_REPORT_USAGE 0x08
#define USB_REPORT_LOGICAL_MINIMUM 0x14
#define USB_REPORT_USAGE_MINIMUM 0x18
#define USB_REPORT_LOGICAL_MAXIMUM 0x24
#define USB_REPORT_USAGE_MAXIMUM 0x28
#define USB_REPORT_PHYSICAL_MINIMUM 0x34
#define USB_REPORT_PHYSICAL_MAXIMUM 0x44
#define USB_REPORT_UNIT 0x64
#define USB_REPORT_INPUT 0x80
#define USB_REPORT_REPORT_SIZE 0x74
#define USB_REPORT_OUTPUT 0x90
#define USB_REPORT_REPORT_COUNT 0x94
#define USB_REPORT_COLLECTION_START 0xA0
#define USB_REPORT_FEATURE 0xB0
#define USB_REPORT_COLLECTION_END 0xC0

#define USB_OH0_DEVICE_ID 0x00000000 // for completion
#define USB_OH1_DEVICE_ID 0x00200000

Expand Down
83 changes: 83 additions & 0 deletions gc/ogc/usbcontroller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*-------------------------------------------------------------

usbcontroller.h -- Usb controller support

Copyright (C) 2020
Joris Vermeylen [email protected]
DacoTaco

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.

Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source
distribution.

-------------------------------------------------------------*/

#ifndef __USBCONTROLLER_H__
#define __USBCONTROLLER_H__

#if defined(HW_RVL)

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef enum
{
USBCONTROLLER_PRESSED = 0,
USBCONTROLLER_RELEASED,
USBCONTROLLER_DISCONNECTED
} USBController_eventType;

typedef enum
{
UNKNOWN = 0,
NONE,
BUTTON,
HAT,
AXIS
} inputType;

typedef struct
{
USBController_eventType eventType;
inputType inputType;
u16 number;
u16 value;
} USBController_event;

typedef void (*eventcallback) (USBController_event event);

s32 USBController_Initialize(void);
s32 USBController_Deinitialize(void);

s32 USBController_Open(const eventcallback cb);
void USBController_Close(void);

bool USBController_IsConnected(void);
s32 USBController_Scan(void);

s32 USBController_GetDescriptorSize();
s32 USBController_GetDescriptor(void* buffer, u16 size);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __USBCONTROLLER_H__ */

#endif /* Wii mode */
Loading