kopia lustrzana https://github.com/FreeSpacenav/spacenavd
store and make available more information about the devices
rodzic
cf397150a8
commit
b4dc387931
58
src/dev.c
58
src/dev.c
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "dev_serial.h"
|
||||
#include "event.h" /* remove pending events upon device removal */
|
||||
#include "spnavd.h"
|
||||
#include "proto.h"
|
||||
|
||||
#ifdef USE_X11
|
||||
#include "proto_x11.h"
|
||||
|
@ -33,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
static struct device *add_device(void);
|
||||
static struct device *dev_path_in_use(char const * dev_path);
|
||||
static int match_usbdev(const struct usb_dev_info *devinfo);
|
||||
static int usbdevtype(unsigned int vid, unsigned int pid);
|
||||
|
||||
static struct device *dev_list = NULL;
|
||||
|
||||
|
@ -72,6 +74,9 @@ int init_devices(void)
|
|||
|
||||
dev = add_device();
|
||||
strcpy(dev->path, usbdev->devfiles[i]);
|
||||
dev->type = usbdevtype(usbdev->vendorid, usbdev->productid);
|
||||
dev->usbid[0] = usbdev->vendorid;
|
||||
dev->usbid[1] = usbdev->productid;
|
||||
|
||||
if(open_dev_usb(dev) == -1) {
|
||||
remove_device(dev);
|
||||
|
@ -204,28 +209,28 @@ struct device *get_devices(void)
|
|||
|
||||
#define VENDOR_3DCONNEXION 0x256f
|
||||
|
||||
static int devid_list[][2] = {
|
||||
{0x046d, 0xc603}, /* spacemouse plus XT */
|
||||
{0x046d, 0xc605}, /* cadman */
|
||||
{0x046d, 0xc606}, /* spacemouse classic */
|
||||
{0x046d, 0xc621}, /* spaceball 5000 */
|
||||
{0x046d, 0xc623}, /* space traveller */
|
||||
{0x046d, 0xc625}, /* space pilot */
|
||||
{0x046d, 0xc626}, /* space navigator */
|
||||
{0x046d, 0xc627}, /* space explorer */
|
||||
{0x046d, 0xc628}, /* space navigator for notebooks*/
|
||||
{0x046d, 0xc629}, /* space pilot pro*/
|
||||
{0x046d, 0xc62b}, /* space mouse pro*/
|
||||
{0x046d, 0xc640}, /* nulooq */
|
||||
{0x256f, 0xc62e}, /* spacemouse wireless (USB cable) */
|
||||
{0x256f, 0xc62f}, /* spacemouse wireless receiver */
|
||||
{0x256f, 0xc631}, /* spacemouse pro wireless */
|
||||
{0x256f, 0xc632}, /* spacemouse pro wireless receiver */
|
||||
{0x256f, 0xc633}, /* spacemouse enterprise */
|
||||
{0x256f, 0xc635}, /* spacemouse compact */
|
||||
{0x256f, 0xc636}, /* spacemouse module */
|
||||
static int devid_list[][3] = {
|
||||
{0x046d, 0xc603, DEV_PLUSXT}, /* spacemouse plus XT */
|
||||
{0x046d, 0xc605, DEV_CADMAN}, /* cadman */
|
||||
{0x046d, 0xc606, DEV_SMCLASSIC}, /* spacemouse classic */
|
||||
{0x046d, 0xc621, DEV_SB5000}, /* spaceball 5000 */
|
||||
{0x046d, 0xc623, DEV_STRAVEL}, /* space traveller */
|
||||
{0x046d, 0xc625, DEV_SPILOT}, /* space pilot */
|
||||
{0x046d, 0xc626, DEV_SNAV}, /* space navigator */
|
||||
{0x046d, 0xc627, DEV_SEXP}, /* space explorer */
|
||||
{0x046d, 0xc628, DEV_SNAVNB}, /* space navigator for notebooks*/
|
||||
{0x046d, 0xc629, DEV_SPILOTPRO}, /* space pilot pro*/
|
||||
{0x046d, 0xc62b, DEV_SMPRO}, /* space mouse pro*/
|
||||
{0x046d, 0xc640, DEV_NULOOQ}, /* nulooq */
|
||||
{0x256f, 0xc62e, DEV_SMW}, /* spacemouse wireless (USB cable) */
|
||||
{0x256f, 0xc62f, DEV_SMW}, /* spacemouse wireless receiver */
|
||||
{0x256f, 0xc631, DEV_SMPROW}, /* spacemouse pro wireless */
|
||||
{0x256f, 0xc632, DEV_SMPROW}, /* spacemouse pro wireless receiver */
|
||||
{0x256f, 0xc633, DEV_SMENT}, /* spacemouse enterprise */
|
||||
{0x256f, 0xc635, DEV_SMCOMP}, /* spacemouse compact */
|
||||
{0x256f, 0xc636, DEV_SMMOD}, /* spacemouse module */
|
||||
|
||||
{-1, -1}
|
||||
{-1, -1, DEV_UNKNOWN}
|
||||
};
|
||||
|
||||
/* 3Dconnexion devices which we don't want to match, because they are
|
||||
|
@ -294,3 +299,14 @@ static int match_usbdev(const struct usb_dev_info *devinfo)
|
|||
|
||||
return 0; /* no match */
|
||||
}
|
||||
|
||||
static int usbdevtype(unsigned int vid, unsigned int pid)
|
||||
{
|
||||
int i;
|
||||
for(i=0; devid_list[i][0] != -1; i++) {
|
||||
if(devid_list[i][0] == vid && devid_list[i][1] == pid) {
|
||||
return devid_list[i][2];
|
||||
}
|
||||
}
|
||||
return DEV_UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ struct device {
|
|||
void *data;
|
||||
char name[MAX_DEV_NAME];
|
||||
char path[PATH_MAX];
|
||||
int type;
|
||||
unsigned int usbid[2]; /* vendor:product for USB devices */
|
||||
|
||||
int num_axes, num_buttons;
|
||||
int *minval, *maxval; /* input value range (default: -500, 500) */
|
||||
|
|
|
@ -40,6 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "dev.h"
|
||||
#include "event.h"
|
||||
#include "logger.h"
|
||||
#include "proto.h"
|
||||
|
||||
#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
|
||||
(defined(__alpha__) || defined(__alpha)) || \
|
||||
|
@ -505,6 +506,7 @@ static int sball_parsepkt(struct sball *sb, int id, char *data, int len)
|
|||
sb->nbuttons = 12; /* might have guessed 8 before */
|
||||
sb->keymask = 0xfff;
|
||||
strcpy(sb->dev->name, "Spaceball 4000FLX");
|
||||
sb->dev->type = DEV_SB4000;
|
||||
}
|
||||
/* update orientation flag (actually don't bother) */
|
||||
/*
|
||||
|
@ -564,10 +566,12 @@ static int guess_num_buttons(struct device *dev, const char *verstr)
|
|||
/* try to guess based on firmware number */
|
||||
if(sscanf(s + 17, "%d.%d", &major, &minor) == 2 && major == 2) {
|
||||
if(minor == 35 || minor == 62 || minor == 63) {
|
||||
dev->type = DEV_SB3003;
|
||||
strcpy(dev->name, "Spaceball 3003/3003C");
|
||||
return 2; /* spaceball 3003/3003C */
|
||||
}
|
||||
if(minor == 43 || minor == 45) {
|
||||
dev->type = DEV_SB4000;
|
||||
strcpy(dev->name, "Spaceball 4000FLX/5000FLX-A");
|
||||
return 12; /* spaceball 4000flx/5000flx-a */
|
||||
}
|
||||
|
@ -578,6 +582,7 @@ static int guess_num_buttons(struct device *dev, const char *verstr)
|
|||
* sure this happens as soon as possible, before clients have a
|
||||
* chance to connect.
|
||||
*/
|
||||
dev->type = DEV_SB2003;
|
||||
strcpy(dev->name, "Spaceball 1003/2003/2003C");
|
||||
return 8; /* spaceball 1003/2003/2003c */
|
||||
}
|
||||
|
@ -585,16 +590,19 @@ static int guess_num_buttons(struct device *dev, const char *verstr)
|
|||
}
|
||||
|
||||
if(strstr(verstr, "MAGELLAN")) {
|
||||
dev->type = DEV_SM;
|
||||
strcpy(dev->name, "Magellan SpaceMouse");
|
||||
return 9; /* magellan spacemouse */
|
||||
}
|
||||
|
||||
if(strstr(verstr, "SPACEBALL")) {
|
||||
dev->type = DEV_SM5000;
|
||||
strcpy(dev->name, "Spaceball 5000");
|
||||
return 12; /* spaceball 5000 */
|
||||
}
|
||||
|
||||
if(strstr(verstr, "CadMan")) {
|
||||
dev->type = DEV_SMCADMAN;
|
||||
strcpy(dev->name, "CadMan");
|
||||
return 4;
|
||||
}
|
||||
|
|
34
src/proto.h
34
src/proto.h
|
@ -28,8 +28,10 @@ enum {
|
|||
REQ_DEV_NAME = 0x2000, /* get device name: R[0] length R[6] status followed
|
||||
by <length> bytes */
|
||||
REQ_DEV_PATH, /* get device path: same as above */
|
||||
REQ_DEV_NAXES, /* get number of axes: R[0] num axes R[6] status */
|
||||
REQ_DEV_NAXES, /* get number of axes: R[0] num axes R[6] status */
|
||||
REQ_DEV_NBUTTONS, /* get number of buttons: same as above */
|
||||
REQ_DEV_USBID, /* get USB id: R[0] vend R[1] prod R[6] status */
|
||||
REQ_DEV_TYPE, /* get device type: R[0] type enum R[6] status */
|
||||
/* TODO: features like LCD, LEDs ... */
|
||||
|
||||
/* configuration settings */
|
||||
|
@ -62,4 +64,34 @@ enum {
|
|||
REQ_CHANGE_PROTO = 0x5500
|
||||
};
|
||||
|
||||
/* XXX keep in sync with SPNAV_DEV_* in spnav.h (libspnav) */
|
||||
enum {
|
||||
DEV_UNKNOWN,
|
||||
/* serial devices */
|
||||
DEV_SB2003 = 0x100, /* Spaceball 1003/2003/2003C */
|
||||
DEV_SB3003, /* Spaceball 3003/3003C */
|
||||
DEV_SB4000, /* Spaceball 4000FLX/5000FLX */
|
||||
DEV_SM, /* Magellan SpaceMouse */
|
||||
DEV_SM5000, /* Spaceball 5000 (spacemouse protocol) */
|
||||
DEV_SMCADMAN, /* 3Dconnexion CadMan (spacemouse protocol) */
|
||||
/* USB devices */
|
||||
DEV_PLUSXT = 0x200, /* SpaceMouse Plus XT */
|
||||
DEV_CADMAN, /* 3Dconnexion CadMan (USB version) */
|
||||
DEV_SMCLASSIC, /* SpaceMouse Classic */
|
||||
DEV_SB5000, /* Spaceball 5000 (USB version) */
|
||||
DEV_STRAVEL, /* Space Traveller */
|
||||
DEV_SPILOT, /* Space Pilot */
|
||||
DEV_SNAV, /* Space Navigator */
|
||||
DEV_SEXP, /* Space Explorer */
|
||||
DEV_SNAVNB, /* Space Navigator for Notebooks */
|
||||
DEV_SPILOTPRO, /* Space Pilot pro */
|
||||
DEV_SMPRO, /* SpaceMouse Pro */
|
||||
DEV_NULOOQ, /* Nulooq */
|
||||
DEV_SMW, /* SpaceMouse Wireless */
|
||||
DEV_SMPROW, /* SpaceMouse Pro Wireless */
|
||||
DEV_SMENT, /* SpaceMouse Enterprise */
|
||||
DEV_SMCOMP, /* SpaceMouse Compact */
|
||||
DEV_SMMOD /* SpaceMouse Module */
|
||||
};
|
||||
|
||||
#endif /* PROTO_H_ */
|
||||
|
|
|
@ -314,6 +314,25 @@ static int handle_request(struct client *c, struct reqresp *req)
|
|||
}
|
||||
break;
|
||||
|
||||
case REQ_DEV_USBID:
|
||||
if((dev = get_client_device(c)) && dev->usbid[0] && dev->usbid[1]) {
|
||||
req->data[0] = dev->usbid[0];
|
||||
req->data[1] = dev->usbid[1];
|
||||
sendresp(c, req, 0);
|
||||
} else {
|
||||
sendresp(c, req, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case REQ_DEV_TYPE:
|
||||
if((dev = get_client_device(c))) {
|
||||
req->data[0] = dev->type;
|
||||
sendresp(c, req, 0);
|
||||
} else {
|
||||
sendresp(c, req, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case REQ_SCFG_SENS:
|
||||
fval = *(float*)req->data;
|
||||
if(isfinite(fval)) {
|
||||
|
|
Ładowanie…
Reference in New Issue