Implement gc invert and full sliders

This commit is contained in:
Raphael Assenat 2015-10-17 23:19:50 -04:00
parent a55ac8069a
commit 9b17716b20
5 changed files with 44 additions and 8 deletions

View File

@ -5,6 +5,7 @@
#include "hiddata.h"
#include "bootloader.h"
#include "gcn64_protocol.h"
#include "version.h"
#define CMDBUF_SIZE 64
@ -96,6 +97,12 @@ static void hiddata_processCommandBuffer(void)
// CMD: RQ, PARAM
g_polling_suspended = cmdbuf[1];
break;
case RQ_GCN64_GET_VERSION:
// CMD: RQ
// Answer: RQ, version string
strcpy((char*)(cmdbuf + 1), g_version);
cmdbuf_len = 1 + strlen(g_version);
break;
}
#ifdef DEBUG

View File

@ -5,6 +5,7 @@
#define RQ_GCN64_SET_CONFIG_PARAM 0x01
#define RQ_GCN64_GET_CONFIG_PARAM 0x02
#define RQ_GCN64_SUSPEND_POLLING 0x03
#define RQ_GCN64_GET_VERSION 0x04
#define RQ_GCN64_RAW_SI_COMMAND 0x80
#define RQ_GCN64_JUMP_TO_BOOTLOADER 0xFF
@ -19,9 +20,9 @@
#define CFG_PARAM_POLL_INTERVAL2 0x12
#define CFG_PARAM_POLL_INTERVAL3 0x13
#define CFG_PARAM_N64_SQUARE 0x20
#define CFG_PARAM_GC_MAIN_SQUARE 0x21
#define CFG_PARAM_GC_CSTICK_SQUARE 0x22
#define CFG_PARAM_N64_SQUARE 0x20 // Not implemented
#define CFG_PARAM_GC_MAIN_SQUARE 0x21 // Not implemented
#define CFG_PARAM_GC_CSTICK_SQUARE 0x22 // Not implemented
#define CFG_PARAM_FULL_SLIDERS 0x23
#define CFG_PARAM_INVERT_TRIG 0x24

View File

@ -4,6 +4,8 @@
#include "gamepads.h"
#include "usbpad.h"
#include "mappings.h"
#include "eeprom.h"
#include "config.h"
#define REPORT_ID 1
#define REPORT_SIZE 15
@ -107,11 +109,26 @@ static void buildReportFromGC(const gc_pad_data *gc_data, unsigned char dstbuf[R
cxval *= 160;
cyval *= -160;
/* Scane 0...255 to 0...16000 */
if (g_eeprom_data.cfg.flags & FLAG_GC_FULL_SLIDERS) {
int16_t lts = (int16_t)ltrig - 127;
int16_t rts = (int16_t)rtrig - 127;
lts *= 126;
ltrig = lts;
rts *= 126;
rtrig = rts;
} else {
/* Scale 0...255 to 0...16000 */
ltrig *= 63;
if (ltrig > 16000) ltrig=16000;
rtrig *= 63;
if (rtrig > 16000) rtrig=16000;
}
if (g_eeprom_data.cfg.flags & FLAG_GC_INVERT_TRIGS) {
ltrig = -ltrig;
rtrig = -rtrig;
}
/* Unsign for HID report */
xval += 16000;

5
version.c Normal file
View File

@ -0,0 +1,5 @@
#include <avr/pgmspace.h>
#include "version.h"
const char *g_version = VERSIONSTR; // From Makefile
const char signature[] PROGMEM = "9c3ea8b8-753f-11e5-a0dc-001bfca3c593";

6
version.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef _version_h__
#define _version_h__
extern const char *g_version;
#endif // _version_h__