Not only turn vibration on when magnitude is above X, but also off when below!
This commit is contained in:
parent
8a3d47d692
commit
b7d56c2168
22
usbpad.c
22
usbpad.c
|
@ -1,5 +1,5 @@
|
||||||
/* gc_n64_usb : Gamecube or N64 controller to USB firmware
|
/* gc_n64_usb : Gamecube or N64 controller to USB firmware
|
||||||
Copyright (C) 2007-2013 Raphael Assenat <raph@raphnet.net>
|
Copyright (C) 2007-2016 Raphael Assenat <raph@raphnet.net>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
static volatile unsigned char gamepad_vibrate = 0; // output
|
static volatile unsigned char gamepad_vibrate = 0; // output
|
||||||
static unsigned char vibration_on = 0, force_vibrate = 0;
|
static unsigned char vibration_on = 0, force_vibrate = 0;
|
||||||
static unsigned char constant_force = 0;
|
static unsigned char constant_force = 0;
|
||||||
static unsigned char magnitude = 0;
|
static unsigned char periodic_magnitude = 0;
|
||||||
|
|
||||||
static unsigned char _FFB_effect_index;
|
static unsigned char _FFB_effect_index;
|
||||||
#define LOOP_MAX 0xFFFF
|
#define LOOP_MAX 0xFFFF
|
||||||
|
@ -238,9 +238,10 @@ char usbpad_mustVibrate(void)
|
||||||
} else {
|
} else {
|
||||||
if (constant_force > 0x7f) {
|
if (constant_force > 0x7f) {
|
||||||
gamepad_vibrate = 1;
|
gamepad_vibrate = 1;
|
||||||
}
|
} else if (periodic_magnitude > 0x7f) {
|
||||||
if (magnitude > 0x7f) {
|
|
||||||
gamepad_vibrate = 1;
|
gamepad_vibrate = 1;
|
||||||
|
} else {
|
||||||
|
gamepad_vibrate = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,23 +342,25 @@ uint8_t usbpad_hid_set_report(const struct usb_request *rq, const uint8_t *data,
|
||||||
break;
|
break;
|
||||||
case REPORT_DISABLE_ACTUATORS:
|
case REPORT_DISABLE_ACTUATORS:
|
||||||
printf_P(PSTR("disable actuators\r\n"));
|
printf_P(PSTR("disable actuators\r\n"));
|
||||||
|
periodic_magnitude = 0;
|
||||||
|
constant_force = 0;
|
||||||
|
vibration_on = 0;
|
||||||
break;
|
break;
|
||||||
case REPORT_PID_POOL:
|
case REPORT_PID_POOL:
|
||||||
printf_P(PSTR("pid pool\r\n"));
|
printf_P(PSTR("pid pool\r\n"));
|
||||||
break;
|
break;
|
||||||
case REPORT_SET_EFFECT:
|
case REPORT_SET_EFFECT:
|
||||||
_FFB_effect_index = data[1];
|
_FFB_effect_index = data[1];
|
||||||
printf_P(PSTR("set effect %d\n"), data[1]);
|
printf_P(PSTR("set effect %d\r\n"), data[1]);
|
||||||
break;
|
break;
|
||||||
case REPORT_SET_PERIODIC:
|
case REPORT_SET_PERIODIC:
|
||||||
magnitude = data[2];
|
periodic_magnitude = data[2];
|
||||||
printf_P(PSTR("periodic mag: %d"), data[2]);
|
printf_P(PSTR("periodic mag: %d"), data[2]);
|
||||||
break;
|
break;
|
||||||
case REPORT_SET_CONSTANT_FORCE:
|
case REPORT_SET_CONSTANT_FORCE:
|
||||||
if (data[1] == 1) {
|
if (data[1] == 1) {
|
||||||
constant_force = data[2];
|
constant_force = data[2];
|
||||||
//decideVibration();
|
printf_P(PSTR("Constant force %d\r\n"), data[2]);
|
||||||
printf_P(PSTR("Constant force"));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REPORT_EFFECT_OPERATION:
|
case REPORT_EFFECT_OPERATION:
|
||||||
|
@ -381,19 +384,16 @@ uint8_t usbpad_hid_set_report(const struct usb_request *rq, const uint8_t *data,
|
||||||
case EFFECT_OP_START:
|
case EFFECT_OP_START:
|
||||||
printf_P(PSTR("Start\r\n"));
|
printf_P(PSTR("Start\r\n"));
|
||||||
vibration_on = 1;
|
vibration_on = 1;
|
||||||
// decideVibration();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFFECT_OP_START_SOLO:
|
case EFFECT_OP_START_SOLO:
|
||||||
printf_P(PSTR("Start solo\r\n"));
|
printf_P(PSTR("Start solo\r\n"));
|
||||||
vibration_on = 1;
|
vibration_on = 1;
|
||||||
// decideVibration();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFFECT_OP_STOP:
|
case EFFECT_OP_STOP:
|
||||||
printf_P(PSTR("Stop\r\n"));
|
printf_P(PSTR("Stop\r\n"));
|
||||||
vibration_on = 0;
|
vibration_on = 0;
|
||||||
// decideVibration();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue