LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Button on Microscope QX3 (https://www.linuxquestions.org/questions/programming-9/button-on-microscope-qx3-921011/)

nicolacdnll 12-29-2011 03:05 AM

Button on Microscope QX3
 
Hi,
I'm working on a Java software for using the microscope QX3 in the primary school and I need a way to figure out when the user press the button on the microscope. I can't get this from V4L2 library, so reading the CPiA(1) - gspca driver[1] I found the var button on the struct qx3:
Code:

struct {
  /* Intel QX3 specific data */
  u8 qx3_detected; /* a QX3 is present */
  u8 toplight;    /* top light lit , R/W */
  u8 bottomlight;  /* bottom light lit, R/W */
  u8 button;      /* snapshot button pressed (R/O) */
  u8 cradled;      /* microscope is in cradle (R/O) */
} qx3;


Could someone kindly tell me if there is a way to read this value?

Thank you for your time.

[1] http://lxr.free-electrons.com/source...a/cpia1.c#L335

firstfire 12-29-2011 11:30 AM

Hi.
At a glance to the cpia1.c, the button pressing event is processed here:
Code:

1758 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1759        /* If the last button state is pressed, release it now! */
1760        if (sd->params.qx3.button) {
1761                /* The camera latch will hold the pressed state until we reset
1762                    the latch, so we do not reset sd->params.qx3.button now, to
1763                    avoid a false keypress being reported the next sd_start */
1764                input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
1765                input_sync(gspca_dev->input_dev);
1766        }
1767 #endif

You can try to catch KEY_CAMERA input event using the evtest utility as described here. Also look at this link, esp. section 5.

nicolacdnll 12-30-2011 02:39 AM

Sorry but I don't understand which /dev/input/eventX I have to use with evtest.

Here some output:
Code:

ll /dev/input/
total 0
drwxr-xr-x  4 root root    400 2011-12-30 08:42 ./
drwxr-xr-x 20 root root  4600 2011-12-30 09:28 ../
drwxr-xr-x  2 root root    100 2011-12-30 08:42 by-id/
drwxr-xr-x  2 root root    160 2011-12-30 08:42 by-path/
crw-r-----  1 root root 13, 64 2011-12-30 08:42 event0
crw-r-----  1 root root 13, 65 2011-12-30 08:42 event1
crw-r-----  1 root root 13, 74 2011-12-30 08:42 event10
crw-r-----  1 root root 13, 75 2011-12-30 08:42 event11
crw-r-----  1 root root 13, 66 2011-12-30 08:42 event2
crw-r-----  1 root root 13, 67 2011-12-30 08:42 event3
crw-r-----  1 root root 13, 68 2011-12-30 08:42 event4
crw-r-----  1 root root 13, 69 2011-12-30 08:42 event5
crw-r-----  1 root root 13, 70 2011-12-30 08:42 event6
crw-r-----  1 root root 13, 71 2011-12-30 08:42 event7
crw-r-----  1 root root 13, 72 2011-12-30 08:42 event8
crw-r-----  1 root root 13, 73 2011-12-30 08:42 event9
crw-r-----  1 root root 13, 63 2011-12-30 08:42 mice
crw-r-----  1 root root 13, 32 2011-12-30 08:42 mouse0
crw-r-----  1 root root 13, 33 2011-12-30 08:42 mouse1
crw-r-----  1 root root 13, 34 2011-12-30 08:42 mouse2

Code:

ll /dev/input/by-id/
total 0
drwxr-xr-x 2 root root 100 2011-12-30 08:42 ./
drwxr-xr-x 4 root root 400 2011-12-30 08:42 ../
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 usb-MLK_Activo_WL_2.4G_Nano-event-mouse -> ../event5
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 usb-MLK_Activo_WL_2.4G_Nano-mouse -> ../mouse0
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 usb-SuYin_Integrated_Webcam_CN1315-S30B-OV01-VD-B20090413-event-if00 -> ../event7

Code:

ll /dev/input/by-path/
total 0
drwxr-xr-x 2 root root 160 2011-12-30 08:42 ./
drwxr-xr-x 4 root root 400 2011-12-30 08:42 ../
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 pci-0000:00:1a.1-usb-0:2:1.0-event-mouse -> ../event5
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 pci-0000:00:1a.1-usb-0:2:1.0-mouse -> ../mouse0
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 pci-0000:00:1d.7-usb-0:2:1.0-event -> ../event7
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 platform-i8042-serio-0-event-kbd -> ../event4
lrwxrwxrwx 1 root root  10 2011-12-30 08:42 platform-i8042-serio-1-event-mouse -> ../event11
lrwxrwxrwx 1 root root  9 2011-12-30 08:42 platform-i8042-serio-1-mouse -> ../mouse2

Code:

dmesg
. . .
[ 2794.408135] usb 6-1: new full speed USB device using uhci_hcd and address 4
[ 2794.617169] gspca: probing 0813:0001
[ 2794.617173] cpia1: cpia CPiA camera detected (vid/pid 0x0813:0x0001)
[ 2794.920228] cpia1: CPIA Version:            1.33 (2.10)
[ 2794.920231] cpia1: CPIA PnP-ID:              0813:0001:0106
[ 2794.920233] cpia1: VP-Version:              1.0 0100
[ 2794.920327] gspca: video1 created

Thanks.

firstfire 12-30-2011 12:00 PM

Hi.

Quote:

Sorry but I don't understand which /dev/input/eventX I have to use with evtest.
I don't know which one to choose either. Try them all or figure out correct one using following command
Code:

$ cat /sys/class/input/event*/device/name  | nl -v0
    0  Lid Switch
    1  Sleep Button
    2  Power Button
    3  AT Translated Set 2 keyboard
    4  Logitech USB Laser Mouse
    5  WebCam
    6  Video Bus
    7  HDA Intel Mic
    8  HDA Intel Headphone
    9  SynPS/2 Synaptics TouchPad

Does (un-)plugging your device changes this list?

If nothing helps, try to compile kernel module yourself and insert printk("<1>..."); where appropriate to see what's happening (messages go to system log).

nicolacdnll 12-30-2011 12:59 PM

I tried to (un)plug but the list doesn't change, I also tried all the /dev/input/eventX but no one is the microscope.

In the meantime I write a mail to the driver's writers and one of theme reply me this:
Quote:

Button events get reported as regular linux input events, so if you've a recent distro where
X automatically detects and configures new input devices (try for example Fedora 15), then the button
should report X keypress events. Unfortunately the button needs to be polled, and currently that is
only done when the camera is streaming. So if I start a stream from the camera, and then run xev
(a small utility which reports X events) and then press the button I get:

Code:

KeyPress event, serial 33, synthetic NO, window 0x2c00001,
  root 0xc4, subw 0x0, time 20841206, (1631,-58), root:(1632,439),
  state 0x0, keycode 220 (keysym 0x1008ff8f, XF86WebCam), same_screen YES,
  XLookupString gives 0 bytes:
  XmbLookupString gives 0 bytes:
  XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x2c00001,
  root 0xc4, subw 0x0, time 20841494, (1631,-58), root:(1632,439),
  state 0x0, keycode 220 (keysym 0x1008ff8f, XF86WebCam), same_screen YES,
  XLookupString gives 0 bytes:
  XFilterEvent returns: False


But on my Ubuntu 11.04 (with 2.6.38-11-generic-pae kernel) the event doesn't detected from the xev program.


All times are GMT -5. The time now is 04:47 AM.