Really direct input

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
kapooran
Posts: 6
Joined: Sat Sep 06, 2008 3:19 pm

Really direct input

Post by kapooran »

Hello,
I have a very different usage of the space mouse which requires direct interface to a microcontroller/DSP. Is there a possibility to get hooks into the internals of the device without using the USB (I mean not at the driver but even at hardware level).

Upon dissection of one of the space navigators I own, I found a 8 pin connector that carries some signals between a USB board and the "real" 3D mouse of which two are +5V and GND. Are the other 6 analog voltages corresponding to the motion on the mouse in some way? If so what is this relationship? Is there any other way?

Can someone help me with these signals?

I apologize for multiple posting of this message on different forums.

Thanks,
ngomes
Moderator
Moderator
Posts: 3344
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi kapooran,

It appears that you want to use the optical sensor separately. 3Dconnexion is a manufacturer of computer peripherals and does not publicly provide details of the inner workings of 3D mice.
Nuno Gomes
GPD
Posts: 5
Joined: Fri Feb 06, 2009 7:32 pm
Location: greece

use of spacenav for embedded...

Post by GPD »

I investigate the same subject. It is not necessary to find out how the controller works electronically, nor is it too hard to figure it out if you open one. (I guess it does not feed analogue signals through a ... USB for obvious reasons, but has 6 DOF A/Ds feeding a CoTS serial device).

(theoretically you could use a polling A/D for all six axes, instead of 6, since, regardless of how you scan -parallel or serial, you feed a serial device. Anyway, how it works is only a speculation and it doesn't really matter for using it in automation.)

Instead, treat it like a HID device under linux and use an embedded linux device to do the control you want to do. Small AVR's along with custom boards plus your time cost MUCH more than the 50€ buying you an Atmel NGW100 with a full blown 32bit Linux and cross development capabilities for most linux distros.

You may find http://www.frogmouth.net/hid-doco/x286.html
and http://www.aaue.dk/~janoc/index.php?n=P ... torSupport
useful.

So far I tested that spacenavig.c (found in the latter link and explained in the first) can be compiled for AVR32, which is an embedded controller suitable for automation projects.

It merely requires a gcc spacenavig.c -o spacenavig to test it...
(same for avr32 using avr32-linux-gcc instead).

What for do you plan to use it for? Might be able to give a hand if interesting.

All the best.
GPD

p.s. it would be nice to control a few six dof devices I have in mind, and not necessarily difficult :) Anyone interested, keep me posted. Done such things before with ... slightly more expensive gear (barely more expensive :) )

p.s.2 the code is this:

Code: Select all

#include <linux>
#include <sys>
#include <sys>
#include <fcntl>

#include <stdio>
#include <math>
#include <stdlib>
#include <stdint>

/* this macro is used to tell if "bit" is set in "array"
 * it selects a byte from the array, and does a boolean AND
 * operation with a byte that only has the relevant bit set.
 * eg. to check for the 12th bit, we do (array[1] & 1<<4)
 */
#define test_bit(bit, array)    (array[bit/8] & (1<<(bit%8)))

int main(int argc, char **argv)
{
    int i = 0;
    char *fname = NULL;
    struct input_id ID;

    int fd;

    // find the SpaceNavigator or similar device
    fname = (char *)malloc(1000 * sizeof(char));
    while (i <32> 0)
        {
            ioctl(fd, EVIOCGID, &ID);

            if (ID.vendor == 0x046d && 
                    (ID.product == 0xc626 || 
                     ID.product == 0xc623 ||
                     ID.product == 0xc603))
            {
                printf("Using device: %s\n", fname);
                break;
            }
        }
    }
    
    
    // detect supported features
    if (fd > 0)
    {
        int axes[6] = {0,0,0,0,0,0};
        int buttons[2] = {0, 0};

        struct input_event ev;
        uint8_t evtype_bitmask[EV_MAX/8 + 1];
        int ev_type;

        ioctl(fd, EVIOCGBIT(0, sizeof(evtype_bitmask)), evtype_bitmask);

        printf("Supported event types:\n");
        for (ev_type = 0; ev_type <EV_MAX>= sizeof(struct input_event))
            {
                switch (ev.type)
                {
                    case EV_KEY:
                        printf("Key %d pressed %d.\n", ev.code, ev.value);
                        buttons[ev.code] = ev.value;
                        break;

                    case EV_REL:
                        if (ev.code == 0)
                            printf("%d %g\n", ev.code, ev.value);
                        axes[ev.code] = ev.value;
                        break;

                    default:
                        break;
                }
            }
            printf("%d %d %d %d %d %d\n", axes[0], axes[1], axes[2], axes[3], axes[4], axes[5]);
        }
    }
    else
    {
        fputs("Unable to open sensor!\n", stderr);
        return(-1);
    }

    close(fd);
}

Post Reply