From 3757250833bfb95a5e392137527c0e51f01d250b Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Fri, 6 Nov 2015 23:27:30 -0500 Subject: [PATCH] Force rumble through command --- Makefile.inc | 2 +- changelog.txt | 3 +++ hiddata.c | 6 ++++++ requests.h | 1 + usbpad.c | 11 ++++++++++- usbpad.h | 1 + 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index 9315d50..d290389 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -1,2 +1,2 @@ OBJS=main.o usb.o usbpad.o mappings.o gcn64_protocol.o n64.o gamecube.o usart1.o bootloader.o eeprom.o config.o hiddata.o usbstrings.o intervaltimer.o version.o gcn64txrx.o gamepads.o -VERSIONSTR=\"3.0.0\" +VERSIONSTR=\"3.1.0\" diff --git a/changelog.txt b/changelog.txt index 4648c5b..2ec5a76 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +- October 5, 2015 : Version 3.1.0 + - Add a test rumble command (for GUI tool, or for simple rumble control) + - October 2, 2015 : Version 3.0.0 Initial release: - Gamecube and N64 controller support diff --git a/hiddata.c b/hiddata.c index b7283ad..6839c8b 100644 --- a/hiddata.c +++ b/hiddata.c @@ -115,6 +115,12 @@ static void hiddata_processCommandBuffer(void) cmdbuf[2] = current_pad_type; cmdbuf_len = 3; break; + case RQ_GCN64_SET_VIBRATION: + // CMD : RQ, CHN, Vibrate + // Answer: RQ, CHN, Vibrate + usbpad_forceVibrate(cmdbuf[2]); + cmdbuf_len = 3; + break; } #ifdef DEBUG diff --git a/requests.h b/requests.h index 86b99cc..2d084d2 100644 --- a/requests.h +++ b/requests.h @@ -8,6 +8,7 @@ #define RQ_GCN64_GET_VERSION 0x04 #define RQ_GCN64_GET_SIGNATURE 0x05 #define RQ_GCN64_GET_CONTROLLER_TYPE 0x06 +#define RQ_GCN64_SET_VIBRATION 0x07 #define RQ_GCN64_RAW_SI_COMMAND 0x80 #define RQ_GCN64_JUMP_TO_BOOTLOADER 0xFF diff --git a/usbpad.c b/usbpad.c index 5b7a61f..06ce096 100644 --- a/usbpad.c +++ b/usbpad.c @@ -36,7 +36,7 @@ static volatile unsigned char gamepad_vibrate = 0; // output -static unsigned char vibration_on = 0; +static unsigned char vibration_on = 0, force_vibrate = 0; static unsigned char constant_force = 0; static unsigned char magnitude = 0; @@ -209,8 +209,17 @@ void usbpad_update(const gamepad_data *pad_data) } } +void usbpad_forceVibrate(char force) +{ + force_vibrate = force; +} + char usbpad_mustVibrate(void) { + if (force_vibrate) { + return 1; + } + if (!vibration_on) { gamepad_vibrate = 0; } else { diff --git a/usbpad.h b/usbpad.h index d6d6bf5..c4f061f 100644 --- a/usbpad.h +++ b/usbpad.h @@ -9,6 +9,7 @@ unsigned char *usbpad_getReportBuffer(void); void usbpad_update(const gamepad_data *pad_data); char usbpad_mustVibrate(void); +void usbpad_forceVibrate(char force); uint8_t usbpad_hid_set_report(const struct usb_request *rq, const uint8_t *data, uint16_t len); uint16_t usbpad_hid_get_report(struct usb_request *rq, const uint8_t **dat);