Fix HID send report commands for Simagic P1000 Haptic modules

This commit is contained in:
Mon ouïe 2025-04-21 19:16:03 +02:00 committed by Paul Jones
parent 04f01366b1
commit 108d21d30a
1 changed files with 20 additions and 17 deletions

View File

@ -19,7 +19,7 @@ int senddevreport(USBGenericHapticDevice* usbhapticdevice, unsigned char* buf, s
int res = 0; int res = 0;
if (usbhapticdevice->handle) if (usbhapticdevice->handle)
{ {
res = hid_write(usbhapticdevice->handle, buf, SIMAGIC_P1000_BUFSIZE); res = hid_send_feature_report(usbhapticdevice->handle, buf, SIMAGIC_P1000_BUFSIZE);
slogd("sent %i bytes to %s", bufsize, SIMAGICP1000DEVSTRING); slogd("sent %i bytes to %s", bufsize, SIMAGICP1000DEVSTRING);
slogt("sent bytes %02x %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); slogt("sent bytes %02x %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
} }
@ -27,7 +27,7 @@ int senddevreport(USBGenericHapticDevice* usbhapticdevice, unsigned char* buf, s
{ {
slogd("no handle"); slogd("no handle");
} }
return res; return res != bufsize;
} }
int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play) int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play)
@ -44,34 +44,36 @@ int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype,
if (play > 0) if (play > 0)
{ {
bytes[0] = 0xEC; bytes[0] = 241;
bytes[1] = 0xEC;
// we can add config settings for these values // we can add config settings for these values
bytes[2] = 0x01; bytes[3] = 0x01;
bytes[3] = 0x0A; bytes[4] = 0x0A;
bytes[4] = 0xFF; bytes[5] = 0xFF;
switch (effecttype) switch (effecttype)
{ {
case (EFFECT_TYRESLIP): case (EFFECT_TYRESLIP):
bytes[1] = 0x02; bytes[2] = 0x02;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
break; break;
case (EFFECT_TYRELOCK): case (EFFECT_TYRELOCK):
bytes[1] = 0x01; bytes[2] = 0x01;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
break; break;
case (EFFECT_ABSBRAKES): case (EFFECT_ABSBRAKES):
bytes[1] = 0x02; bytes[2] = 0x02;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
bytes[1] = 0x01; bytes[2] = 0x01;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
break; break;
} }
} }
else else
{ {
bytes[1] = 0x01; bytes[0] = 241;
bytes[2] = 0x01;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
bytes[1] = 0x02; bytes[2] = 0x02;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
} }
@ -113,13 +115,14 @@ int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice)
{ {
bytes[x] = 0x00; bytes[x] = 0x00;
} }
bytes[0] = 0xF1; bytes[0] = 241;
bytes[1] = 0x17; bytes[1] = 0xF1;
bytes[2] = 0x00; bytes[2] = 0x17;
bytes[3] = 0x00; bytes[3] = 0x00;
bytes[4] = 0x00; bytes[4] = 0x00;
bytes[5] = 0x01; bytes[5] = 0x00;
bytes[6] = 0x02; bytes[6] = 0x01;
bytes[7] = 0x02;
res = senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE); res = senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
slogd("Initialization returned %i", res); slogd("Initialization returned %i", res);
if(res != 0) if(res != 0)