Browse Source

Implement get_controller_type

pull/5/head
Raphael Assenat 6 years ago
parent
commit
5ff36596bb
4 changed files with 20 additions and 5 deletions
  1. +8
    -1
      hiddata.c
  2. +5
    -4
      main.c
  3. +6
    -0
      main.h
  4. +1
    -0
      requests.h

+ 8
- 1
hiddata.c View File

@ -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;
}


+ 5
- 4
main.c View File

@ -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;
type = gcn64_detectController();
current_pad_type = gcn64_detectController();
switch (type)
switch (current_pad_type)
{
case CONTROLLER_IS_ABSENT:
case CONTROLLER_IS_UNKNOWN:


+ 6
- 0
main.h View File

@ -0,0 +1,6 @@
#ifndef _main_h__
#define _main_h__
extern unsigned char current_pad_type;
#endif // _main_h__

+ 1
- 0
requests.h View File

@ -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…
Cancel
Save