mirror of https://github.com/nirenjan/libx52.git
Replace hard-coded values with #define's
parent
9d3acfd35a
commit
63a2f465d2
|
@ -24,6 +24,7 @@ EXTRA_DIST = \
|
|||
README.md \
|
||||
config.rpath \
|
||||
gettext.h \
|
||||
usb-ids.h \
|
||||
po/README.md
|
||||
|
||||
# Doxygen support
|
||||
|
|
|
@ -13,16 +13,12 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "usb-ids.h"
|
||||
#include "libx52.h"
|
||||
#include "x52_commands.h"
|
||||
#include "x52_common.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#define VENDOR_SAITEK 0x06a3
|
||||
#define X52_PROD_X52PRO 0x0762
|
||||
#define X52_PROD_X52_1 0x0255
|
||||
#define X52_PROD_X52_2 0x075C
|
||||
|
||||
/* Check if the USB device is supported by this library */
|
||||
static int libx52_check_product(uint16_t idVendor, uint16_t idProduct)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include "io_common.h"
|
||||
#include "usb-ids.h"
|
||||
|
||||
static const int32_t x52_axis_max[] = {
|
||||
2047, 2047, 1023, 255, 255, 255, 255, 15, 15
|
||||
|
@ -20,12 +21,12 @@ static const int32_t x52pro_axis_max[] = {
|
|||
void _x52io_set_axis_range(libx52io_context *ctx)
|
||||
{
|
||||
switch (ctx->pid) {
|
||||
case 0x0255:
|
||||
case 0x075c:
|
||||
case X52_PROD_X52_1:
|
||||
case X52_PROD_X52_2:
|
||||
memcpy(ctx->axis_max, x52_axis_max, sizeof(ctx->axis_max));
|
||||
break;
|
||||
|
||||
case 0x0762:
|
||||
case X52_PROD_X52PRO:
|
||||
memcpy(ctx->axis_max, x52pro_axis_max, sizeof(ctx->axis_max));
|
||||
break;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "io_common.h"
|
||||
#include "usb-ids.h"
|
||||
|
||||
int libx52io_init(libx52io_context **ctx)
|
||||
{
|
||||
|
@ -70,13 +71,13 @@ int libx52io_open(libx52io_context *ctx)
|
|||
libx52io_close(ctx);
|
||||
|
||||
/* Enumerate all Saitek HID devices */
|
||||
devs = hid_enumerate(0x06a3, 0);
|
||||
devs = hid_enumerate(VENDOR_SAITEK, 0);
|
||||
cur_dev = devs;
|
||||
while (cur_dev) {
|
||||
switch (cur_dev->product_id) {
|
||||
case 0x0255:
|
||||
case 0x075c:
|
||||
case 0x0762:
|
||||
case X52_PROD_X52_1:
|
||||
case X52_PROD_X52_2:
|
||||
case X52_PROD_X52PRO:
|
||||
ctx->handle = hid_open_path(cur_dev->path);
|
||||
if (ctx->handle == NULL) {
|
||||
rc = LIBX52IO_ERROR_CONN;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include "io_common.h"
|
||||
#include "usb-ids.h"
|
||||
|
||||
static void map_axis(unsigned char *data, int thumb_pos, libx52io_report *report)
|
||||
{
|
||||
|
@ -216,13 +217,14 @@ static int parse_x52pro(unsigned char *data, int length, libx52io_report *report
|
|||
void _x52io_set_report_parser(libx52io_context *ctx)
|
||||
{
|
||||
switch (ctx->pid) {
|
||||
case 0x0255:
|
||||
case 0x075c:
|
||||
case X52_PROD_X52_1:
|
||||
case X52_PROD_X52_2:
|
||||
ctx->parser = parse_x52;
|
||||
break;
|
||||
|
||||
case 0x0762:
|
||||
case X52_PROD_X52PRO:
|
||||
ctx->parser = parse_x52pro;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue