Adding support for Logitech G29 Wheel
This commit is contained in:
parent
62bda5a58c
commit
6c7c3231a7
|
|
@ -25,6 +25,8 @@ set(devices_source_files
|
||||||
usb/cslelitev3.c
|
usb/cslelitev3.c
|
||||||
usb/simagicp1000.h
|
usb/simagicp1000.h
|
||||||
usb/simagicp1000.c
|
usb/simagicp1000.c
|
||||||
|
usb/wheels/logitechg29.h
|
||||||
|
usb/wheels/logitechg29.c
|
||||||
usb/wheels/cammusc5.h
|
usb/wheels/cammusc5.h
|
||||||
usb/wheels/cammusc5.c
|
usb/wheels/cammusc5.c
|
||||||
usb/wheels/cammusc12.h
|
usb/wheels/cammusc12.h
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <hidapi/hidapi.h>
|
||||||
|
|
||||||
|
#include "logitechg29.h"
|
||||||
|
#include "../../../slog/slog.h"
|
||||||
|
|
||||||
|
const int logitechg29_hidupdate_buf_size = 7;
|
||||||
|
|
||||||
|
int logitechg29_update(USBDevice* usbdevice, int maxrpm, int rpm, int gear, int velocity)
|
||||||
|
{
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
uint8_t leds = 0;
|
||||||
|
|
||||||
|
float percent = 0;
|
||||||
|
if(maxrpm > 0)
|
||||||
|
{
|
||||||
|
percent = (float) rpm / (float) maxrpm;
|
||||||
|
|
||||||
|
if (percent > .84)
|
||||||
|
{
|
||||||
|
leds = 0b11111;
|
||||||
|
}
|
||||||
|
else if (percent > .69)
|
||||||
|
{
|
||||||
|
leds = 0b1111;
|
||||||
|
}
|
||||||
|
else if (percent > .39)
|
||||||
|
{
|
||||||
|
leds = 0b111;
|
||||||
|
}
|
||||||
|
else if (percent > .19)
|
||||||
|
{
|
||||||
|
leds = 0b11;
|
||||||
|
}
|
||||||
|
else if (percent > .4)
|
||||||
|
{
|
||||||
|
leds = 0b1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leds = 0b0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t bytes[7] = {
|
||||||
|
0xF8,
|
||||||
|
0x12,
|
||||||
|
leds,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01
|
||||||
|
};
|
||||||
|
|
||||||
|
slogt("writing bytes x%02xx%02xx%02xx%02xx%02x from rpm %i", bytes[0], bytes[1], bytes[2], bytes[3], bytes[6], rpm);
|
||||||
|
if (usbdevice->handle)
|
||||||
|
{
|
||||||
|
res = hid_write(usbdevice->handle, bytes, logitechg29_hidupdate_buf_size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slogd("no handle");
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int logitechg29_free(USBDevice* usbdevice)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
hid_close(usbdevice->handle);
|
||||||
|
res = hid_exit();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int logitechg29_init(USBDevice* usbdevice)
|
||||||
|
{
|
||||||
|
slogi("initializing Logitech G29 wheel...");
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res = hid_init();
|
||||||
|
usbdevice->handle = hid_open(0x046D, 0xC24F, NULL);
|
||||||
|
|
||||||
|
if (!usbdevice->handle)
|
||||||
|
{
|
||||||
|
sloge("Could not find attached Logitech G29 Wheel");
|
||||||
|
res = hid_exit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
slogd("Found Logitech G29 Wheel...");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef _LOGITECHG29_H
|
||||||
|
#define _LOGITECHG29_H
|
||||||
|
|
||||||
|
#include "../../simdevice.h"
|
||||||
|
|
||||||
|
int logitechg29_update(USBDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity);
|
||||||
|
int logitechg29_init(USBDevice* wheeldevice);
|
||||||
|
int logitechg29_free(USBDevice* wheeldevice);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "usb/wheels/logitechg29.h"
|
||||||
#include "usb/wheels/cammusc5.h"
|
#include "usb/wheels/cammusc5.h"
|
||||||
#include "usb/wheels/cammusc12.h"
|
#include "usb/wheels/cammusc12.h"
|
||||||
#include "usb/wheels/gtneo.h"
|
#include "usb/wheels/gtneo.h"
|
||||||
|
|
@ -21,6 +22,9 @@ int wheeldev_update(USBDevice* usbdevice, SimData* simdata)
|
||||||
case WHEELDEV_CAMMUSC5 :
|
case WHEELDEV_CAMMUSC5 :
|
||||||
cammusc5_update(usbdevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
|
cammusc5_update(usbdevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
|
||||||
break;
|
break;
|
||||||
|
case WHEELDEV_LOGITECHG29 :
|
||||||
|
logitechg29_update(usbdevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
|
||||||
|
break;
|
||||||
case WHEELDEV_CAMMUSC12 :
|
case WHEELDEV_CAMMUSC12 :
|
||||||
if(usbdevice->u.wheeldevice.useLua == true)
|
if(usbdevice->u.wheeldevice.useLua == true)
|
||||||
{
|
{
|
||||||
|
|
@ -57,6 +61,10 @@ int wheeldev_free(USBDevice* usbdevice)
|
||||||
cammusc5_update(usbdevice, 0, 0, 0, 0);
|
cammusc5_update(usbdevice, 0, 0, 0, 0);
|
||||||
cammusc5_free(usbdevice);
|
cammusc5_free(usbdevice);
|
||||||
break;
|
break;
|
||||||
|
case WHEELDEV_LOGITECHG29 :
|
||||||
|
logitechg29_update(usbdevice, 0, 0, 0, 0);
|
||||||
|
logitechg29_free(usbdevice);
|
||||||
|
break;
|
||||||
case WHEELDEV_CAMMUSC12 :
|
case WHEELDEV_CAMMUSC12 :
|
||||||
cammusc12_free(usbdevice);
|
cammusc12_free(usbdevice);
|
||||||
if(wheeldevice->useLua == true)
|
if(wheeldevice->useLua == true)
|
||||||
|
|
@ -82,6 +90,11 @@ int wheeldev_init(USBDevice* usbdevice, DeviceSettings* ds)
|
||||||
slogi("Attempting to initialize cammus C5");
|
slogi("Attempting to initialize cammus C5");
|
||||||
error = cammusc5_init(usbdevice);
|
error = cammusc5_init(usbdevice);
|
||||||
break;
|
break;
|
||||||
|
case SIMDEVSUBTYPE_LOGITECH_G29:
|
||||||
|
wheeldevice->type = WHEELDEV_LOGITECHG29;
|
||||||
|
slogi("Attempting to initialize Logitech G29");
|
||||||
|
error = logitechg29_init(usbdevice);
|
||||||
|
break;
|
||||||
case SIMDEVSUBTYPE_CAMMUSC12:
|
case SIMDEVSUBTYPE_CAMMUSC12:
|
||||||
wheeldevice->type = WHEELDEV_CAMMUSC12;
|
wheeldevice->type = WHEELDEV_CAMMUSC12;
|
||||||
slogi("Attempting to initialize cammus C12");
|
slogi("Attempting to initialize cammus C12");
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ typedef enum
|
||||||
WHEELDEV_CAMMUSC5 = 1,
|
WHEELDEV_CAMMUSC5 = 1,
|
||||||
WHEELDEV_CAMMUSC12 = 2,
|
WHEELDEV_CAMMUSC12 = 2,
|
||||||
WHEELDEV_MOZAR5 = 3,
|
WHEELDEV_MOZAR5 = 3,
|
||||||
WHEELDEV_SIMAGICGTNEO = 4
|
WHEELDEV_SIMAGICGTNEO = 4,
|
||||||
|
WHEELDEV_LOGITECHG29 = 5
|
||||||
}
|
}
|
||||||
WheelType;
|
WheelType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,11 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
|
||||||
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
||||||
devfound = true;
|
devfound = true;
|
||||||
}
|
}
|
||||||
|
if (strcicmp(device_subsubtype, "LogitechG29") == 0)
|
||||||
|
{
|
||||||
|
ds->dev_subsubtype = SIMDEVSUBTYPE_LOGITECH_G29;
|
||||||
|
devfound = true;
|
||||||
|
}
|
||||||
if (strcicmp(device_subsubtype, "MozaR8") == 0)
|
if (strcicmp(device_subsubtype, "MozaR8") == 0)
|
||||||
{
|
{
|
||||||
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ typedef enum
|
||||||
SIMDEVSUBTYPE_CSLELITEV3PEDALS = 4,
|
SIMDEVSUBTYPE_CSLELITEV3PEDALS = 4,
|
||||||
SIMDEVSUBTYPE_SIMAGICP1000PEDALS = 5,
|
SIMDEVSUBTYPE_SIMAGICP1000PEDALS = 5,
|
||||||
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
|
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
|
||||||
SIMDEVSUBTYPE_MOZA_NEW = 7
|
SIMDEVSUBTYPE_MOZA_NEW = 7,
|
||||||
|
SIMDEVSUBTYPE_LOGITECH_G29 = 8
|
||||||
}
|
}
|
||||||
DeviceSubSubType;
|
DeviceSubSubType;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue