mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-21 06:48:52 -05:00
Implement get_controller_type
This commit is contained in:
parent
92aa261e4e
commit
5ff36596bb
@ -6,6 +6,7 @@
|
||||
#include "bootloader.h"
|
||||
#include "gcn64_protocol.h"
|
||||
#include "version.h"
|
||||
#include "main.h"
|
||||
|
||||
// dataHidReport is 40 bytes.
|
||||
#define CMDBUF_SIZE 41
|
||||
@ -106,7 +107,13 @@ static void hiddata_processCommandBuffer(void)
|
||||
break;
|
||||
case RQ_GCN64_GET_SIGNATURE:
|
||||
strcpy_P((char*)(cmdbuf + 1), g_signature);
|
||||
cmdbuf_len = 1 + strlen_P(g_version) + 1;
|
||||
cmdbuf_len = 1 + strlen_P(g_signature) + 1;
|
||||
break;
|
||||
case RQ_GCN64_GET_CONTROLLER_TYPE:
|
||||
// CMD : RQ, CHN
|
||||
// Answer: RQ, CHN, TYPE
|
||||
cmdbuf[2] = current_pad_type;
|
||||
cmdbuf_len = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
|
9
main.c
9
main.c
@ -5,6 +5,7 @@
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include "usart1.h"
|
||||
#include "usb.h"
|
||||
@ -209,13 +210,13 @@ void hwinit(void)
|
||||
|
||||
#define NUM_PAD_TYPES 2
|
||||
|
||||
unsigned char current_pad_type = CONTROLLER_IS_ABSENT;
|
||||
|
||||
Gamepad *detectPad(void)
|
||||
{
|
||||
char type;
|
||||
current_pad_type = gcn64_detectController();
|
||||
|
||||
type = gcn64_detectController();
|
||||
|
||||
switch (type)
|
||||
switch (current_pad_type)
|
||||
{
|
||||
case CONTROLLER_IS_ABSENT:
|
||||
case CONTROLLER_IS_UNKNOWN:
|
||||
|
6
main.h
Normal file
6
main.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _main_h__
|
||||
#define _main_h__
|
||||
|
||||
extern unsigned char current_pad_type;
|
||||
|
||||
#endif // _main_h__
|
@ -7,6 +7,7 @@
|
||||
#define RQ_GCN64_SUSPEND_POLLING 0x03
|
||||
#define RQ_GCN64_GET_VERSION 0x04
|
||||
#define RQ_GCN64_GET_SIGNATURE 0x05
|
||||
#define RQ_GCN64_GET_CONTROLLER_TYPE 0x06
|
||||
#define RQ_GCN64_RAW_SI_COMMAND 0x80
|
||||
#define RQ_GCN64_JUMP_TO_BOOTLOADER 0xFF
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user