Article View: es.comp.os.linux.programacion
Article #12876Re: Detectar si hay un mouse serie conectado a un PC
From: Antonio Villalon
Date: Wed, 02 May 2001 17:35
Date: Wed, 02 May 2001 17:35
43 lines
2635 bytes
2635 bytes
Holas,
Santiago Romero <sromero@servicom2000.com> wrote:
: Enas!
: Por unos motivos que no viene al caso (por no alargarme :)
: necesito encontrar una manera de detectar (en C, perl,
: bash o lo que sea) si hay un mouse serie conectado al ttyS0.
Una forma un poco cutre:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#define MOUSE "/dev/tty00"
main(){
int fd=open(MOUSE,O_RDONLY);
if(fd>0) while(read(fd,NULL,1)>=1);
printf("Raton movido\n");
close(fd);
}
Funciona aparentemente bien, imagino que tendras que modificar el tty00 por
tu raton en Linux, pero es cutre porque detecta datos entrando por el puerto,
ya sea un raton, un modem, o una cafetera :)
Si quieres saber si es realmente un raton no creo que te sirva de mucho; si
solo quieres ver si hay algo conectado, quizas si.
Lo unico que hace es leer del puerto, se puede hacer en shellscript con un
'cat </dev/tty00' algo apanyado.
Saludos,
Toni
--
#############################################################################
# Toni Villalon <toni@aiind.upv.es> #
# TELNET andercheran.aiind.upv.es 2895 for PGP Public Key #
#############################################################################
# "The bad reputation Unix has gotten is totally undeserved, laid on by #
# people who don't understand, who have not gotten in there and tried #
# anything." #
# Jim Joyce #
############# This .signature is written in 100% recycled bytes #############
Technical Details
Message-ID:
<9cpghm$vtb$1@polaris.cc.upv.es>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!fr.clara.net!heighliner.fr.clara.net!isdnet!news.rediris.es!news.uv.es!news.upv.es!not-for-mailReferences:
<7c3pc9.vd1.ln@127.0.0.1>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit
X-Google-Thread: f86c8,3fd50c75d0339df5
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-05-04 00:48:19 PST
Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!fr.clara.net!heighliner.fr.clara.net!isdnet!news.rediris.es!news.uv.es!news.upv.es!not-for-mail
From: Antonio Villalon <toni@andercheran.aiind.upv.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Detectar si hay un mouse serie conectado a un PC
Date: 2 May 2001 17:35:50 GMT
Organization: U.P.V.
Lines: 43
Message-ID: <9cpghm$vtb$1@polaris.cc.upv.es>
References: <7c3pc9.vd1.ln@127.0.0.1>
NNTP-Posting-Host: andercheran.aiind.upv.es
X-Trace: polaris.cc.upv.es 988824950 32683 158.42.22.41 (2 May 2001 17:35:50 GMT)
X-Complaints-To: newsmaster@upv.es
NNTP-Posting-Date: 2 May 2001 17:35:50 GMT
User-Agent: tin/1.4.3-20000502 ("Marian") (UNIX) (Linux/2.2.19 (i586))