1
0
mirror of https://github.com/raphnet/gc_n64_usb-v3 synced 2024-12-21 23:08:53 -05:00

Need one current_pad_type var. per channel

This commit is contained in:
Raphael Assenat 2016-11-27 11:13:50 -05:00
parent 434aec0d4b
commit c2fd3a10ba
3 changed files with 12 additions and 5 deletions

View File

@ -96,6 +96,8 @@ static void hiddata_processCommandBuffer(struct hiddata_ops *ops)
// TODO : Range checking
// cmdbuf[] : RQ, CHN, LEN, data[]
channel = cmdbuf[1];
if (channel >= NUM_CHANNELS)
break;
cmdbuf_len = gcn64_transaction(channel, cmdbuf+3, cmdbuf[2], cmdbuf + 3, CMDBUF_SIZE-3);
cmdbuf[2] = cmdbuf_len;
cmdbuf_len += 3; // Answer: RQ, CHN, LEN, data[]
@ -131,7 +133,10 @@ static void hiddata_processCommandBuffer(struct hiddata_ops *ops)
case RQ_GCN64_GET_CONTROLLER_TYPE:
// CMD : RQ, CHN
// Answer: RQ, CHN, TYPE
cmdbuf[2] = current_pad_type;
channel = cmdbuf[1];
if (channel >= NUM_CHANNELS)
break;
cmdbuf[2] = current_pad_type[channel];
cmdbuf_len = 3;
break;
case RQ_GCN64_SET_VIBRATION:

6
main.c
View File

@ -364,13 +364,13 @@ void hwinit(void)
}
unsigned char current_pad_type = CONTROLLER_IS_ABSENT;
unsigned char current_pad_type[NUM_CHANNELS] = { };
Gamepad *detectPad(unsigned char chn)
{
current_pad_type = gcn64_detectController(chn);
current_pad_type[chn] = gcn64_detectController(chn);
switch (current_pad_type)
switch (current_pad_type[chn])
{
case CONTROLLER_IS_ABSENT:
case CONTROLLER_IS_UNKNOWN:

4
main.h
View File

@ -1,6 +1,8 @@
#ifndef _main_h__
#define _main_h__
extern unsigned char current_pad_type;
#include "config.h"
extern unsigned char current_pad_type[NUM_CHANNELS];
#endif // _main_h__