mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-21 23:08:53 -05:00
Implement "sliders as buttons" mode
In this mode, when the analog values of the L/R triggers exceed a certain threshold, the corresponding L and R digital buttons are triggered.
This commit is contained in:
parent
a9d5df2b8f
commit
a041e8eaf8
15
usbpad.c
15
usbpad.c
@ -98,6 +98,7 @@ static void buildReportFromGC(const gc_pad_data *gc_data, unsigned char dstbuf[U
|
||||
{
|
||||
int16_t xval,yval,cxval,cyval,ltrig,rtrig;
|
||||
uint16_t buttons;
|
||||
uint16_t gcbuttons = gc_data->buttons;
|
||||
|
||||
/* Force official range */
|
||||
xval = minmax(gc_data->x, -100, 100);
|
||||
@ -114,6 +115,17 @@ static void buildReportFromGC(const gc_pad_data *gc_data, unsigned char dstbuf[U
|
||||
cxval *= 160;
|
||||
cyval *= -160;
|
||||
|
||||
if (g_eeprom_data.cfg.flags & FLAG_GC_SLIDERS_AS_BUTTONS) {
|
||||
/* In this mode, the sliders control buttons */
|
||||
if (ltrig > 32)
|
||||
gcbuttons |= GC_BTN_L;
|
||||
if (rtrig > 32)
|
||||
gcbuttons |= GC_BTN_R;
|
||||
|
||||
/* And the sliders analog values are fixed. */
|
||||
ltrig = rtrig = 0;
|
||||
}
|
||||
else {
|
||||
if (g_eeprom_data.cfg.flags & FLAG_GC_FULL_SLIDERS) {
|
||||
int16_t lts = (int16_t)ltrig - 127;
|
||||
int16_t rts = (int16_t)rtrig - 127;
|
||||
@ -134,6 +146,7 @@ static void buildReportFromGC(const gc_pad_data *gc_data, unsigned char dstbuf[U
|
||||
ltrig = -ltrig;
|
||||
rtrig = -rtrig;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unsign for HID report */
|
||||
xval += 16000;
|
||||
@ -159,7 +172,7 @@ static void buildReportFromGC(const gc_pad_data *gc_data, unsigned char dstbuf[U
|
||||
dstbuf[11] = ((uint8_t*)&rtrig)[0];
|
||||
dstbuf[12] = ((uint8_t*)&rtrig)[1];
|
||||
|
||||
buttons = mappings_do(MAPPING_GAMECUBE_DEFAULT, gc_data->buttons);
|
||||
buttons = mappings_do(MAPPING_GAMECUBE_DEFAULT, gcbuttons);
|
||||
btnsToReport(buttons, dstbuf+13);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user