From 9b17716b2028658dc063d09d451701f694c261a9 Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Sat, 17 Oct 2015 23:19:50 -0400 Subject: [PATCH] Implement gc invert and full sliders --- hiddata.c | 7 +++++++ requests.h | 7 ++++--- usbpad.c | 27 ++++++++++++++++++++++----- version.c | 5 +++++ version.h | 6 ++++++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 version.c create mode 100644 version.h diff --git a/hiddata.c b/hiddata.c index d115dc5..5cb540e 100644 --- a/hiddata.c +++ b/hiddata.c @@ -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 diff --git a/requests.h b/requests.h index a5cf59a..18b1bc4 100644 --- a/requests.h +++ b/requests.h @@ -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 diff --git a/usbpad.c b/usbpad.c index 3c64d48..6b6f5a9 100644 --- a/usbpad.c +++ b/usbpad.c @@ -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 */ - ltrig *= 63; - if (ltrig > 16000) ltrig=16000; - rtrig *= 63; - if (rtrig > 16000) rtrig=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; diff --git a/version.c b/version.c new file mode 100644 index 0000000..557b3cb --- /dev/null +++ b/version.c @@ -0,0 +1,5 @@ +#include +#include "version.h" + +const char *g_version = VERSIONSTR; // From Makefile +const char signature[] PROGMEM = "9c3ea8b8-753f-11e5-a0dc-001bfca3c593"; diff --git a/version.h b/version.h new file mode 100644 index 0000000..d60bb4a --- /dev/null +++ b/version.h @@ -0,0 +1,6 @@ +#ifndef _version_h__ +#define _version_h__ + +extern const char *g_version; + +#endif // _version_h__