LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-29-2011, 03:05 AM   #1
nicolacdnll
LQ Newbie
 
Registered: Dec 2011
Location: Italy
Posts: 3

Rep: Reputation: Disabled
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
 
Old 12-29-2011, 11:30 AM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
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.

Last edited by firstfire; 12-29-2011 at 11:47 AM.
 
Old 12-30-2011, 02:39 AM   #3
nicolacdnll
LQ Newbie
 
Registered: Dec 2011
Location: Italy
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 12-30-2011, 12:00 PM   #4
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
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).
 
Old 12-30-2011, 12:59 PM   #5
nicolacdnll
LQ Newbie
 
Registered: Dec 2011
Location: Italy
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting a microscope to my PC nwarp Linux - Hardware 9 12-12-2009 03:09 AM
Is this microscope a good investment? Dogs General 22 10-30-2009 01:36 PM
I need a microscope to see Firefox Blakes7 Linux - Newbie 22 04-24-2009 10:43 PM
LXer: Damn Small Linux 4.4 RC1 under the microscope LXer Syndicated Linux News 0 05-29-2008 04:51 AM
LXer: Linux-based laptop goes under review microscope LXer Syndicated Linux News 0 12-28-2007 09:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration