Add support to parse a configuration file, /etc/wsmoused.conf by default.
This file lets users tune the behavior of the daemon in a easy way, without having to mess with command line options (nor in rc.conf). It will also simplify future integration of new functionality within the program as multiple "modes" of operator are recognized. The new wsmoused.conf(5) manpage contains all related details. Some error message cleanup and minor manpage fixes too. Ok'ed by christos.
This commit is contained in:
parent
1d6960703b
commit
68e2c80483
@ -1,9 +1,13 @@
|
|||||||
# $NetBSD: Makefile,v 1.1 2002/06/26 23:13:06 christos Exp $
|
# $NetBSD: Makefile,v 1.2 2003/03/04 14:33:55 jmmv Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
PROG= wsmoused
|
PROG= wsmoused
|
||||||
SRCS= wsmoused.c events.c selection.c
|
SRCS= wsmoused.c config.c config_yacc.y config_lex.l events.c selection.c
|
||||||
|
|
||||||
MAN= wsmoused.8
|
MAN= wsmoused.conf.5 wsmoused.8
|
||||||
|
|
||||||
|
CPPFLAGS+= -I.
|
||||||
|
|
||||||
|
YHEADER= yes
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
251
usr.sbin/wsmoused/config.c
Normal file
251
usr.sbin/wsmoused/config.c
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
/* $NetBSD: config.c,v 1.1 2003/03/04 14:33:55 jmmv Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Julio Merino.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. The name authors may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||||
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
__RCSID("$NetBSD: config.c,v 1.1 2003/03/04 14:33:55 jmmv Exp $");
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <dev/wscons/wsconsio.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "pathnames.h"
|
||||||
|
#include "wsmoused.h"
|
||||||
|
|
||||||
|
static struct block *Global = NULL;
|
||||||
|
|
||||||
|
/* Prototypes for config_yacc.y (only used here) */
|
||||||
|
struct block *config_parse(FILE *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new, empty property. Returns a pointer to it.
|
||||||
|
*/
|
||||||
|
struct prop *
|
||||||
|
prop_new(void)
|
||||||
|
{
|
||||||
|
struct prop *p;
|
||||||
|
|
||||||
|
p = (struct prop *) calloc(1, sizeof(struct prop));
|
||||||
|
if (p == NULL)
|
||||||
|
err(EXIT_FAILURE, "calloc");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Frees a property created with prop_new. All data stored in the property
|
||||||
|
* is also destroyed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
prop_free(struct prop *p)
|
||||||
|
{
|
||||||
|
free(p->p_name);
|
||||||
|
free(p->p_value);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new, empty block, with the specified type (see BLOCK_* macros).
|
||||||
|
* Returns a pointer to it.
|
||||||
|
*/
|
||||||
|
struct block *
|
||||||
|
block_new(int type)
|
||||||
|
{
|
||||||
|
struct block *b;
|
||||||
|
|
||||||
|
b = (struct block *) calloc(1, sizeof(struct block));
|
||||||
|
if (b == NULL)
|
||||||
|
err(EXIT_FAILURE, "calloc");
|
||||||
|
b->b_type = type;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Frees a block created with block_new. All data contained inside the block
|
||||||
|
* is also destroyed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
block_free(struct block *b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (b->b_name != NULL)
|
||||||
|
free(b->b_name);
|
||||||
|
|
||||||
|
for (i = 0; i < b->b_prop_count; i++)
|
||||||
|
prop_free(b->b_prop[i]);
|
||||||
|
for (i = 0; i < b->b_child_count; i++)
|
||||||
|
block_free(b->b_child[i]);
|
||||||
|
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a property to a block.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
block_add_prop(struct block *b, struct prop *p)
|
||||||
|
{
|
||||||
|
if (p == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (b->b_prop_count >= MAX_PROPS)
|
||||||
|
errx(EXIT_FAILURE, "too many properties for current block");
|
||||||
|
else {
|
||||||
|
b->b_prop[b->b_prop_count] = p;
|
||||||
|
b->b_prop_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a child (block) to a block.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
block_add_child(struct block *b, struct block *c)
|
||||||
|
{
|
||||||
|
if (c == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (b->b_child_count >= MAX_BLOCKS)
|
||||||
|
errx(EXIT_FAILURE, "too many childs for current block");
|
||||||
|
else {
|
||||||
|
c->b_parent = b;
|
||||||
|
b->b_child[b->b_child_count] = c;
|
||||||
|
b->b_child_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the value of a property in the specified block (or in its parents).
|
||||||
|
* If not found, return the value given in def.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
block_get_propval(struct block *b, char *pname, char *def)
|
||||||
|
{
|
||||||
|
int pc;
|
||||||
|
|
||||||
|
if (b == NULL)
|
||||||
|
return def;
|
||||||
|
|
||||||
|
while (b != NULL) {
|
||||||
|
for (pc = 0; pc < b->b_prop_count; pc++)
|
||||||
|
if (strcmp(b->b_prop[pc]->p_name, pname) == 0)
|
||||||
|
return b->b_prop[pc]->p_value;
|
||||||
|
b = b->b_parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the value of a property in the specified block converting it to an
|
||||||
|
* integer, if possible. If the property cannot be found in the given
|
||||||
|
* block, all its parents are tried. If after all not found (or conversion
|
||||||
|
* not possible), return the value given in def.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
block_get_propval_int(struct block *b, char *pname, int def)
|
||||||
|
{
|
||||||
|
int pc, ret;
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
if (b == NULL)
|
||||||
|
return def;
|
||||||
|
|
||||||
|
while (b != NULL) {
|
||||||
|
for (pc = 0; pc < b->b_prop_count; pc++)
|
||||||
|
if (strcmp(b->b_prop[pc]->p_name, pname) == 0) {
|
||||||
|
ret = (int) strtol(b->b_prop[pc]->p_value,
|
||||||
|
&ptr, 10);
|
||||||
|
if (b->b_prop[pc]->p_value == ptr) {
|
||||||
|
warnx("expected integer in `%s' "
|
||||||
|
"property", pname);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
b = b->b_parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a mode block (childs of the global scope), which matches the specified
|
||||||
|
* name.
|
||||||
|
*/
|
||||||
|
struct block *
|
||||||
|
config_get_mode(char *modename)
|
||||||
|
{
|
||||||
|
struct block *b = Global;
|
||||||
|
int bc;
|
||||||
|
|
||||||
|
if (b != NULL)
|
||||||
|
for (bc = 0; bc < b->b_child_count; bc++)
|
||||||
|
if (strcmp(b->b_child[bc]->b_name, modename) == 0)
|
||||||
|
return b->b_child[bc];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the configuration file.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
config_read(char *conffile, int opt)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
f = fopen(conffile, "r");
|
||||||
|
if (f != NULL) {
|
||||||
|
Global = config_parse(f);
|
||||||
|
if (Global == NULL)
|
||||||
|
errx(EXIT_FAILURE, "%s contains fatal errors",
|
||||||
|
conffile);
|
||||||
|
} else if (errno != ENOENT || opt) {
|
||||||
|
err(EXIT_FAILURE, "cannot open %s", conffile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy all the configuration data.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
config_free(void)
|
||||||
|
{
|
||||||
|
block_free(Global);
|
||||||
|
}
|
77
usr.sbin/wsmoused/config_lex.l
Normal file
77
usr.sbin/wsmoused/config_lex.l
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* $NetBSD: config_lex.l,v 1.1 2003/03/04 14:33:55 jmmv Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Julio Merino.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. The name authors may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||||
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
%{
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
__RCSID("$NetBSD: config_lex.l,v 1.1 2003/03/04 14:33:55 jmmv Exp $");
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <dev/wscons/wsconsio.h>
|
||||||
|
|
||||||
|
#include "wsmoused.h"
|
||||||
|
#include "config_yacc.h"
|
||||||
|
|
||||||
|
extern int yyline;
|
||||||
|
|
||||||
|
extern int yyerror(const char *fmt, ...);
|
||||||
|
int yylex(void);
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%option noyywrap
|
||||||
|
|
||||||
|
STRING [\$A-Za-z\.\/_\-0-9]*
|
||||||
|
MODE_PROPS device|fifo|lefthanded|nodaemon|slowdown_x|slowdown_y|ttystat|xconsole
|
||||||
|
EVENT_PROPS button|do
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
#.*$ /* Eat up comments */
|
||||||
|
[ \t]+ /* Eat up whitespace */
|
||||||
|
\n { yyline++; }
|
||||||
|
|
||||||
|
= { return TK_EQUAL; }
|
||||||
|
; { return TK_EOL; }
|
||||||
|
"{" { return TK_LBRACE; }
|
||||||
|
"}" { return TK_RBRACE; }
|
||||||
|
event { return TK_EVENT; }
|
||||||
|
mode { return TK_MODE; }
|
||||||
|
{EVENT_PROPS} { yylval.string = strdup(yytext); return TK_EVENTPROP; }
|
||||||
|
{MODE_PROPS} { yylval.string = strdup(yytext); return TK_MODEPROP; }
|
||||||
|
{STRING} { yylval.string = strdup(yytext); return TK_STRING; }
|
||||||
|
|
||||||
|
. { yyerror("illegal token `%s'", yytext); }
|
180
usr.sbin/wsmoused/config_yacc.y
Normal file
180
usr.sbin/wsmoused/config_yacc.y
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
/* $NetBSD: config_yacc.y,v 1.1 2003/03/04 14:33:55 jmmv Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Julio Merino.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. The name authors may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||||
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
%{
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
__RCSID("$NetBSD: config_yacc.y,v 1.1 2003/03/04 14:33:55 jmmv Exp $");
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <dev/wscons/wsconsio.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "wsmoused.h"
|
||||||
|
|
||||||
|
int yylex(void);
|
||||||
|
int yyparse(void);
|
||||||
|
int yyerror(const char *, ...);
|
||||||
|
void yyrestart(FILE *);
|
||||||
|
struct block *config_parse(FILE *);
|
||||||
|
|
||||||
|
int yyline;
|
||||||
|
static struct block *Conf;
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%token TK_EOL
|
||||||
|
%token TK_EQUAL TK_LBRACE TK_RBRACE
|
||||||
|
%token TK_STRING TK_EVENT TK_EVENTPROP TK_MODE TK_MODEPROP
|
||||||
|
%type <string> TK_STRING TK_EVENTPROP TK_MODEPROP
|
||||||
|
%type <prop> eventprop modeprop
|
||||||
|
%type <block> main outermode mode outerevent event
|
||||||
|
%union {
|
||||||
|
char *string;
|
||||||
|
struct prop *prop;
|
||||||
|
struct block *block;
|
||||||
|
}
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
Config :
|
||||||
|
main { Conf = $1;
|
||||||
|
Conf->b_name = strdup("global"); }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Matches the whole configuration file and constructs a block defining it.
|
||||||
|
Can contain mode properties (common to all modes) and mode definitions. */
|
||||||
|
main :
|
||||||
|
modeprop { struct block *b = block_new(BLOCK_GLOBAL);
|
||||||
|
block_add_prop(b, $1);
|
||||||
|
$$ = b; }
|
||||||
|
| main modeprop { block_add_prop($1, $2); }
|
||||||
|
| outermode { struct block *b = block_new(BLOCK_GLOBAL);
|
||||||
|
block_add_child(b, $1);
|
||||||
|
$$ = b; }
|
||||||
|
| main outermode { block_add_child($1, $2); }
|
||||||
|
| error TK_EOL { yyerrok; }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Defines the aspect of a mode definition. Returns the block given by the
|
||||||
|
mode definition itself. */
|
||||||
|
outermode :
|
||||||
|
TK_MODE TK_STRING TK_LBRACE mode TK_RBRACE
|
||||||
|
{ $4->b_name = strdup($2);
|
||||||
|
$$ = $4; }
|
||||||
|
| TK_MODE TK_STRING TK_LBRACE TK_RBRACE
|
||||||
|
{ $$ = block_new(BLOCK_MODE);
|
||||||
|
$$->b_name = strdup($2); }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Matches a mode and returns a block defining it. Can contain properties
|
||||||
|
and event definitions. */
|
||||||
|
mode :
|
||||||
|
modeprop { struct block *b = block_new(BLOCK_MODE);
|
||||||
|
block_add_prop(b, $1);
|
||||||
|
$$ = b; }
|
||||||
|
| mode modeprop { block_add_prop($1, $2); }
|
||||||
|
| outerevent { struct block *b = block_new(BLOCK_MODE);
|
||||||
|
block_add_child(b, $1);
|
||||||
|
$$ = b; }
|
||||||
|
| mode outerevent { block_add_child($1, $2); }
|
||||||
|
| error TK_EOL { yyerrok; }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Defines the aspect of an event definition. Returns the block given by the
|
||||||
|
event definition itself. */
|
||||||
|
outerevent :
|
||||||
|
TK_EVENT TK_LBRACE event TK_RBRACE
|
||||||
|
{ $$ = $3; }
|
||||||
|
TK_EVENT TK_LBRACE TK_RBRACE
|
||||||
|
{ $$ = block_new(BLOCK_EVENT); }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Matches an event and returns a block defining it. Contains properties. */
|
||||||
|
event :
|
||||||
|
eventprop { struct block *b = block_new(BLOCK_EVENT);
|
||||||
|
block_add_prop(b, $1);
|
||||||
|
$$ = b; }
|
||||||
|
| event eventprop { block_add_prop($1, $2); }
|
||||||
|
| error TK_EOL { yyerrok; }
|
||||||
|
| error { yyerrok; }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Matches a mode property and returns a prop defining it. */
|
||||||
|
modeprop :
|
||||||
|
TK_MODEPROP TK_EQUAL TK_STRING TK_EOL
|
||||||
|
{ struct prop *p = prop_new();
|
||||||
|
p->p_name = strdup($1);
|
||||||
|
p->p_value = strdup($3);
|
||||||
|
$$ = p; }
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Matches an event property and returns a prop defining it. */
|
||||||
|
eventprop :
|
||||||
|
TK_EVENTPROP TK_EQUAL TK_STRING TK_EOL
|
||||||
|
{ struct prop *p = prop_new();
|
||||||
|
p->p_name = strdup($1);
|
||||||
|
p->p_value = strdup($3);
|
||||||
|
$$ = p; }
|
||||||
|
;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int
|
||||||
|
yyerror(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
fprintf(stderr, "%s: ", getprogname());
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, " in line %d\n", yyline);
|
||||||
|
va_end(ap);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct block *
|
||||||
|
config_parse(FILE *f)
|
||||||
|
{
|
||||||
|
Conf = NULL;
|
||||||
|
yyrestart(f);
|
||||||
|
yyline = 1;
|
||||||
|
yyparse();
|
||||||
|
|
||||||
|
return Conf;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: pathnames.h,v 1.2 2002/06/27 15:07:52 christos Exp $ */
|
/* $NetBSD: pathnames.h,v 1.3 2003/03/04 14:33:55 jmmv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||||
@ -36,5 +36,6 @@
|
|||||||
#define _PATH_PID "/var/run/wsmoused.pid"
|
#define _PATH_PID "/var/run/wsmoused.pid"
|
||||||
#define _PATH_TTYPREFIX "/dev/ttyE"
|
#define _PATH_TTYPREFIX "/dev/ttyE"
|
||||||
#define _PATH_TTYSTAT "/dev/ttyEstat"
|
#define _PATH_TTYSTAT "/dev/ttyEstat"
|
||||||
|
#define _PATH_CONF "/etc/wsmoused.conf"
|
||||||
|
|
||||||
#endif /* _WSMOUSED_PATHNAMES_H */
|
#endif /* _WSMOUSED_PATHNAMES_H */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.\" $NetBSD: wsmoused.8,v 1.8 2003/01/19 21:25:43 atatat Exp $
|
.\" $NetBSD: wsmoused.8,v 1.9 2003/03/04 14:33:55 jmmv Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
|
.\" Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||||
@ -26,8 +26,8 @@
|
|||||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"/
|
.\"
|
||||||
.Dd June 26, 2002
|
.Dd March 4, 2003
|
||||||
.Dt WSMOUSED 8
|
.Dt WSMOUSED 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -36,81 +36,55 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl d Ar device
|
.Op Fl d Ar device
|
||||||
.Op Fl f Ar fifo
|
.Op Fl f Ar conf_file
|
||||||
.Op Fl ln
|
.Op Fl n
|
||||||
.Op Fl X Ar number
|
|
||||||
.Op Fl x Ar number
|
|
||||||
.Op Fl y Ar number
|
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
daemon provides mouse support in console, allowing copying and pasting
|
daemon provides mouse support in console, allowing copying and pasting
|
||||||
text. The left mouse button is used to select text when held and you
|
text.
|
||||||
|
The left mouse button is used to select text when held and you
|
||||||
use the right button to paste it in the active console.
|
use the right button to paste it in the active console.
|
||||||
.Pp
|
.Pp
|
||||||
Supported options are as follows:
|
Supported options are as follows:
|
||||||
.Bl -tag -width XXXnumberX
|
.Bl -tag -width XXXnumberX
|
||||||
.It Fl d Ar device
|
.It Fl d Ar device
|
||||||
specifies which driver to use as the mouse device. It defaults to
|
specifies the device file to be used as the
|
||||||
|
.Xr wsmouse 4
|
||||||
|
device.
|
||||||
|
Defaults to
|
||||||
.Pa /dev/wsmouse .
|
.Pa /dev/wsmouse .
|
||||||
.It Fl f Ar fifo
|
.It Fl f Ar conf_file
|
||||||
is used to specify an optional fifo where to redirect all mouse events
|
specifies the configuration file to be used.
|
||||||
(even if they have been processed). By default, no fifo is used.
|
Defaults to
|
||||||
.It Fl l
|
.Pa /etc/wsmoused.conf .
|
||||||
swaps mouse buttons, specially useful for left handed users.
|
|
||||||
.It Fl n
|
.It Fl n
|
||||||
do not fork in the background (for debugging purposes).
|
do not fork in the background (for debugging purposes).
|
||||||
.It Fl X Ar number
|
|
||||||
tells
|
|
||||||
.Nm
|
|
||||||
which virtual console holds the X server (if any). The argument
|
|
||||||
specifies the console number (the same found in
|
|
||||||
.Pa /dev/ttyE? ,
|
|
||||||
where the ? appears).
|
|
||||||
.Nm
|
|
||||||
will stop processing events when entering this console and will
|
|
||||||
continue its job when you return to any other terminal.
|
|
||||||
.It Fl x Ar number
|
|
||||||
x slowdown. This positive integer specifies how many events in the x
|
|
||||||
direction should be ignored before changing the current column. It
|
|
||||||
defaults to 0.
|
|
||||||
.It Fl y Ar number
|
|
||||||
y slowdown. This positive integer specifies how many events in the y
|
|
||||||
direction should be ignored before changing the current row. It
|
|
||||||
defaults to 3.
|
|
||||||
.El
|
.El
|
||||||
|
.Pp
|
||||||
|
Many other details can be tuned.
|
||||||
|
See
|
||||||
|
.Xr wsmoused.conf 5
|
||||||
|
for more information.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width /dev/wsdisplayXXX -compact
|
.Bl -tag -width /dev/wsmoused.conf -compact
|
||||||
.It Pa /dev/ttyE[0-n]
|
.It Pa /dev/ttyE[0-n]
|
||||||
tty devices
|
tty devices
|
||||||
.It Pa /dev/ttyEstat
|
.It Pa /dev/ttyEstat
|
||||||
wsdisplay status notification device
|
wsdisplay status notification device
|
||||||
.It Pa /dev/wsmouse0
|
.It Pa /dev/wsmouse[0-n]
|
||||||
mouse control device
|
mouse control device
|
||||||
|
.It Pa /etc/wsmoused.conf
|
||||||
|
default configuration file
|
||||||
.El
|
.El
|
||||||
.Sh EXAMPLES
|
|
||||||
The following are just a few examples of
|
|
||||||
.Nm
|
|
||||||
and its functionality.
|
|
||||||
.Pp
|
|
||||||
.Dl wsmoused -X 4
|
|
||||||
.Pp
|
|
||||||
Starts the mouse dameon, telling it that ttyE4 holds a X server.
|
|
||||||
.Pp
|
|
||||||
.Dl wsmoused -d /dev/wsmouse1 -f /tmp/mousefifo
|
|
||||||
.Pp
|
|
||||||
Uses
|
|
||||||
.Pa /dev/wsmouse1
|
|
||||||
device as the mouse and
|
|
||||||
.Pa /tmp/mousefifo
|
|
||||||
as the fifo where all mouse data is redirected.
|
|
||||||
.Sh SECURITY CONSIDERATIONS
|
.Sh SECURITY CONSIDERATIONS
|
||||||
Be ABSOLUTELY sure that
|
Be ABSOLUTELY sure that
|
||||||
.Pa /dev/ttyE*
|
.Pa /dev/ttyE*
|
||||||
devices have restrictive permissions as the mouse uses some functions
|
devices have restrictive permissions as the mouse uses some functions
|
||||||
that could allow terminal snooping if improperly set.
|
that could allow terminal snooping if improperly set.
|
||||||
.Sh NOTES
|
.Sh NOTES
|
||||||
The mouse cursor is only visible for a short time. It will disappear
|
The mouse cursor is only visible for a short time.
|
||||||
|
It will disappear
|
||||||
when you stop moving it to avoid console corruption if there is any
|
when you stop moving it to avoid console corruption if there is any
|
||||||
output while it is visible.
|
output while it is visible.
|
||||||
.Pp
|
.Pp
|
||||||
@ -119,7 +93,8 @@ is needed in your kernel configuration file in
|
|||||||
order to get mouse console support.
|
order to get mouse console support.
|
||||||
.Pp
|
.Pp
|
||||||
When you return from the X screen to another terminal there is a small
|
When you return from the X screen to another terminal there is a small
|
||||||
time delay until the mouse works again. The delay is needed to allow X
|
time delay until the mouse works again.
|
||||||
|
The delay is needed to allow X
|
||||||
to close the mouse device properly.
|
to close the mouse device properly.
|
||||||
.Pp
|
.Pp
|
||||||
It's needed that you change the getty program which runs in the first
|
It's needed that you change the getty program which runs in the first
|
||||||
@ -139,9 +114,16 @@ to make this change.
|
|||||||
.Xr wsmouse 4 ,
|
.Xr wsmouse 4 ,
|
||||||
.Xr ttys 5 ,
|
.Xr ttys 5 ,
|
||||||
.Xr wscons.conf 5 ,
|
.Xr wscons.conf 5 ,
|
||||||
|
.Xr wsmoused.conf 5 ,
|
||||||
.Xr moused 8
|
.Xr moused 8
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
command first appeared in
|
command first appeared in
|
||||||
.Nx 2.0 .
|
.Nx 2.0 .
|
||||||
|
.Sh AUTHORS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
command was developed by
|
||||||
|
.An Julio Merino
|
||||||
|
.Aq jmmv@NetBSD.org .
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $ */
|
/* $NetBSD: wsmoused.c,v 1.7 2003/03/04 14:33:55 jmmv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
@ -32,7 +32,7 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $");
|
__RCSID("$NetBSD: wsmoused.c,v 1.7 2003/03/04 14:33:55 jmmv Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -63,7 +63,6 @@ __RCSID("$NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $");
|
|||||||
|
|
||||||
static struct mouse mouse;
|
static struct mouse mouse;
|
||||||
int XConsole = -1;
|
int XConsole = -1;
|
||||||
int NoDaemon = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show program usage information
|
* Show program usage information
|
||||||
@ -72,8 +71,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"Usage: %s [-d device] [-f fifo] [-ln] [-X number] [-x number] "
|
"Usage: %s [-d device] [-f config_file] [-n]\n",
|
||||||
"[-y number]\n",
|
|
||||||
getprogname());
|
getprogname());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -85,6 +83,7 @@ static void
|
|||||||
signal_terminate(int sig)
|
signal_terminate(int sig)
|
||||||
{
|
{
|
||||||
mouse_cursor_hide(&mouse);
|
mouse_cursor_hide(&mouse);
|
||||||
|
config_free();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +103,7 @@ mouse_open_device(struct mouse *m, int secs)
|
|||||||
m->fd = open(m->device_name,
|
m->fd = open(m->device_name,
|
||||||
O_RDONLY | O_NONBLOCK, 0);
|
O_RDONLY | O_NONBLOCK, 0);
|
||||||
if (m->fd == -1) {
|
if (m->fd == -1) {
|
||||||
err(EXIT_FAILURE, "cannot open '%s'",
|
err(EXIT_FAILURE, "cannot open %s", m->device_name);
|
||||||
m->device_name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +116,7 @@ open_files(void)
|
|||||||
/* Open wsdisplay status device */
|
/* Open wsdisplay status device */
|
||||||
mouse.stat_fd = open(_PATH_TTYSTAT, O_RDONLY | O_NONBLOCK, 0);
|
mouse.stat_fd = open(_PATH_TTYSTAT, O_RDONLY | O_NONBLOCK, 0);
|
||||||
if (mouse.stat_fd == -1)
|
if (mouse.stat_fd == -1)
|
||||||
err(EXIT_FAILURE, "Cannot open `%s'", _PATH_TTYSTAT);
|
err(EXIT_FAILURE, "cannot open %s", mouse.tstat_name);
|
||||||
|
|
||||||
mouse.fd = -1;
|
mouse.fd = -1;
|
||||||
mouse_open_device(&mouse, 0);
|
mouse_open_device(&mouse, 0);
|
||||||
@ -127,7 +125,7 @@ open_files(void)
|
|||||||
if (mouse.fifo_name != NULL) {
|
if (mouse.fifo_name != NULL) {
|
||||||
mouse.fifo_fd = open(mouse.fifo_name, O_RDWR | O_NONBLOCK, 0);
|
mouse.fifo_fd = open(mouse.fifo_name, O_RDWR | O_NONBLOCK, 0);
|
||||||
if (mouse.fifo_fd == -1)
|
if (mouse.fifo_fd == -1)
|
||||||
err(EXIT_FAILURE, "Cannot open `%s'", mouse.fifo_name);
|
err(EXIT_FAILURE, "cannot open %s", mouse.fifo_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +195,7 @@ mouse_init(void)
|
|||||||
|
|
||||||
/* Get terminal size */
|
/* Get terminal size */
|
||||||
if (ioctl(0, TIOCGWINSZ, &ws) < 0)
|
if (ioctl(0, TIOCGWINSZ, &ws) < 0)
|
||||||
err(EXIT_FAILURE, "Cannot get terminal size");
|
err(EXIT_FAILURE, "cannot get terminal size");
|
||||||
|
|
||||||
/* Open current tty */
|
/* Open current tty */
|
||||||
ioctl(mouse.stat_fd, WSDISPLAYIO_GETACTIVESCREEN, &i);
|
ioctl(mouse.stat_fd, WSDISPLAYIO_GETACTIVESCREEN, &i);
|
||||||
@ -264,7 +262,7 @@ mouse_open_tty(struct mouse *m, int ttyno)
|
|||||||
(void)snprintf(buf, sizeof(buf), _PATH_TTYPREFIX "%d", ttyno);
|
(void)snprintf(buf, sizeof(buf), _PATH_TTYPREFIX "%d", ttyno);
|
||||||
m->tty_fd = open(buf, O_RDONLY | O_NONBLOCK);
|
m->tty_fd = open(buf, O_RDONLY | O_NONBLOCK);
|
||||||
if (m->tty_fd < 0)
|
if (m->tty_fd < 0)
|
||||||
errx(EXIT_FAILURE, "Cannot open `%s'", buf);
|
errx(EXIT_FAILURE, "cannot open %s", buf);
|
||||||
m->disabled = 0;
|
m->disabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,49 +297,28 @@ char_invert(struct mouse *m, size_t row, size_t col)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt;
|
int opt, nodaemon = -1;
|
||||||
|
int needconf = 0;
|
||||||
|
char *conffile;
|
||||||
|
struct block *mode;
|
||||||
|
|
||||||
setprogname(argv[0]);
|
setprogname(argv[0]);
|
||||||
|
|
||||||
/* Setup mouse default data */
|
|
||||||
memset(&mouse, 0, sizeof(struct mouse));
|
memset(&mouse, 0, sizeof(struct mouse));
|
||||||
mouse.fifo_fd = -1;
|
conffile = _PATH_CONF;
|
||||||
mouse.device_name = _PATH_DEFAULT_MOUSE;
|
|
||||||
mouse.fifo_name = NULL;
|
|
||||||
|
|
||||||
/* Defaults that can be overriden by options. If you change
|
|
||||||
* these, update wsmoused.8 accordingly. */
|
|
||||||
mouse.slowdown_x = 0;
|
|
||||||
mouse.slowdown_y = 3;
|
|
||||||
|
|
||||||
/* Right handed by default */
|
|
||||||
mouse.but_select = 0;
|
|
||||||
mouse.but_paste = 2;
|
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse command line options */
|
||||||
while ((opt = getopt(argc, argv, "d:f:lny:X:x:")) != -1) {
|
while ((opt = getopt(argc, argv, "d:f:n")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd': /* Mouse device name */
|
case 'd': /* Mouse device name */
|
||||||
mouse.device_name = strdup(optarg);
|
mouse.device_name = optarg;
|
||||||
break;
|
break;
|
||||||
case 'f': /* FIFO file name */
|
case 'f': /* Configuration file name */
|
||||||
mouse.fifo_name = strdup(optarg);
|
needconf = 1;
|
||||||
break;
|
conffile = optarg;
|
||||||
case 'l': /* Left handed */
|
|
||||||
mouse.but_select = 2;
|
|
||||||
mouse.but_paste = 0;
|
|
||||||
break;
|
break;
|
||||||
case 'n': /* No daemon */
|
case 'n': /* No daemon */
|
||||||
NoDaemon = 1;
|
nodaemon = 1;
|
||||||
break;
|
|
||||||
case 'X': /* X console number */
|
|
||||||
XConsole = atoi(optarg);
|
|
||||||
break;
|
|
||||||
case 'x': /* x slowdown */
|
|
||||||
mouse.slowdown_x = atoi(optarg);
|
|
||||||
break;
|
|
||||||
case 'y': /* y slowdown */
|
|
||||||
mouse.slowdown_y = atoi(optarg);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
@ -349,6 +326,31 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read the configuration file and get our mode configuration */
|
||||||
|
config_read(conffile, needconf);
|
||||||
|
mode = config_get_mode("sel");
|
||||||
|
|
||||||
|
/* Set values according to the configuration file */
|
||||||
|
if (mouse.device_name == NULL)
|
||||||
|
mouse.device_name = block_get_propval(mode, "device",
|
||||||
|
_PATH_DEFAULT_MOUSE);
|
||||||
|
|
||||||
|
if (nodaemon == -1)
|
||||||
|
nodaemon = block_get_propval_int(mode, "nodaemon", 0);
|
||||||
|
|
||||||
|
mouse.slowdown_x = block_get_propval_int(mode, "slowdown_x", 0);
|
||||||
|
mouse.slowdown_y = block_get_propval_int(mode, "slowdown_y", 3);
|
||||||
|
mouse.tstat_name = block_get_propval(mode, "ttystat", _PATH_TTYSTAT);
|
||||||
|
XConsole = block_get_propval_int(mode, "xconsole", -1);
|
||||||
|
|
||||||
|
if (block_get_propval_int(mode, "lefthanded", 0)) {
|
||||||
|
mouse.but_select = 2;
|
||||||
|
mouse.but_paste = 0;
|
||||||
|
} else {
|
||||||
|
mouse.but_select = 0;
|
||||||
|
mouse.but_paste = 2;
|
||||||
|
}
|
||||||
|
|
||||||
open_files();
|
open_files();
|
||||||
mouse_init();
|
mouse_init();
|
||||||
mouse_sel_init();
|
mouse_sel_init();
|
||||||
@ -359,8 +361,10 @@ main(int argc, char **argv)
|
|||||||
(void)signal(SIGQUIT, signal_terminate);
|
(void)signal(SIGQUIT, signal_terminate);
|
||||||
(void)signal(SIGTERM, signal_terminate);
|
(void)signal(SIGTERM, signal_terminate);
|
||||||
|
|
||||||
if (!NoDaemon) daemon(0, 0);
|
if (!nodaemon)
|
||||||
|
daemon(0, 0);
|
||||||
event_loop();
|
event_loop();
|
||||||
|
|
||||||
|
/* NOTREACHED */
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
157
usr.sbin/wsmoused/wsmoused.conf.5
Normal file
157
usr.sbin/wsmoused/wsmoused.conf.5
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
.\" $NetBSD: wsmoused.conf.5,v 1.1 2003/03/04 14:33:55 jmmv Exp $
|
||||||
|
.\"
|
||||||
|
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
.\" by Julio Merino.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
.\" contributors may be used to endorse or promote products derived
|
||||||
|
.\" from this software without specific prior written permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd March 4, 2003
|
||||||
|
.Dt WSMOUSED.CONF 5
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm wsmoused.conf
|
||||||
|
.Nd mouse daemon configuration
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
file configures all the features provided by the
|
||||||
|
.Xr wsmoused 8
|
||||||
|
daemon.
|
||||||
|
It is composed by a series of
|
||||||
|
.Em blocks ,
|
||||||
|
each of which defines a group of
|
||||||
|
.Em properties .
|
||||||
|
The file format is free-form: new line markers are ignored as well as
|
||||||
|
indentation.
|
||||||
|
Comments start with the
|
||||||
|
.Sq #
|
||||||
|
sign and extend until the end of line.
|
||||||
|
.Pp
|
||||||
|
A
|
||||||
|
.Em property
|
||||||
|
is like a variable assignment.
|
||||||
|
It has a name, which goes to the left of the equal sign, and a value,
|
||||||
|
which goes to the right.
|
||||||
|
The assignment ends with a semicolon.
|
||||||
|
It looks like:
|
||||||
|
.Dl name = value;
|
||||||
|
.Pp
|
||||||
|
There is no difference between string or integer values when defining them.
|
||||||
|
Booleans are specified as integers, where
|
||||||
|
.Sq 0
|
||||||
|
means false and
|
||||||
|
.Sq 1
|
||||||
|
stands for true.
|
||||||
|
Even though, the program cares about this and will emit a warning if you
|
||||||
|
have done an incorrect assignment.
|
||||||
|
Note that it will not accept unrecognized names.
|
||||||
|
.Pp
|
||||||
|
A
|
||||||
|
.Em mode
|
||||||
|
is a type of block that defines how the program behaves when run in a
|
||||||
|
specific mode.
|
||||||
|
A mode inherits properties defined in the global scope.
|
||||||
|
It has the following syntax:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
mode mode_name {
|
||||||
|
property1 = value1;
|
||||||
|
...
|
||||||
|
propertyN = valueN;
|
||||||
|
}
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
In order to run
|
||||||
|
.Xr wsmoused 8
|
||||||
|
in a specific mode, it must be defined in the configuration file, even
|
||||||
|
if empty.
|
||||||
|
Actually, there is only one recognized mode, the
|
||||||
|
.Ql sel
|
||||||
|
mode.
|
||||||
|
.Ss Properties common to all modes
|
||||||
|
The following properties can be defined in the global scope, thus
|
||||||
|
affecting all modes, or inside the mode definition, to override global
|
||||||
|
values.
|
||||||
|
.Bl -tag -width indent
|
||||||
|
.It device = pathname;
|
||||||
|
The
|
||||||
|
.Xr wsmouse 4
|
||||||
|
device name to use.
|
||||||
|
Defaults to
|
||||||
|
.Pa /dev/wsmouse .
|
||||||
|
.It nodaemon = boolean;
|
||||||
|
Set to 1 to not fork in the background.
|
||||||
|
.El
|
||||||
|
.Ss Properties specific to the sel mode
|
||||||
|
The following properties are only useful when running in the
|
||||||
|
.Em sel
|
||||||
|
mode:
|
||||||
|
.Bl -tag -width indent
|
||||||
|
.It fifo = pathname;
|
||||||
|
Specify an optional fifo where to redirect all mouse events, no matter
|
||||||
|
if they have been processed.
|
||||||
|
By default, no fifo is used.
|
||||||
|
.It lefthanded = boolean;
|
||||||
|
Set to 1 to swap mouse buttons, specially useful for left handed users.
|
||||||
|
.It slowdown_x = integer;
|
||||||
|
X axis slowdown.
|
||||||
|
This positive integer specifies how many events in
|
||||||
|
the vertical direction should be ignored before changing the current
|
||||||
|
column.
|
||||||
|
It defaults to 0.
|
||||||
|
.It slowdown_y = integer;
|
||||||
|
Y axis slowdown.
|
||||||
|
This positive integer specifies how many events in
|
||||||
|
the horizontal direction should be ignored before changing the current row.
|
||||||
|
It defaults to 3.
|
||||||
|
.It ttystat = pathname;
|
||||||
|
.Xr wsdisplay 4 Ns 's
|
||||||
|
notification device.
|
||||||
|
Defaults to
|
||||||
|
.Pa /dev/ttyEstat .
|
||||||
|
You will not want to change this.
|
||||||
|
.It xconsole = integer;
|
||||||
|
Virtual console number which holds the X server (if any).
|
||||||
|
The argument specifies the console number (the same found in
|
||||||
|
.Pa /dev/ttyE? ) .
|
||||||
|
Unset by default.
|
||||||
|
.El
|
||||||
|
.Sh FILES
|
||||||
|
.Bl -tag -width /usr/share/examples/wsmoused/ -compact
|
||||||
|
.It Pa /etc/wsmoused.conf
|
||||||
|
Default configuration file.
|
||||||
|
.It Pa /usr/share/examples/wsmoused/
|
||||||
|
Location of sample files.
|
||||||
|
.El
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr wsdisplay 4 ,
|
||||||
|
.Xr wsmouse 4 ,
|
||||||
|
.Xr wsmoused 8
|
||||||
|
.Sh HISTORY
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
configuration file first appeared in
|
||||||
|
.Nx 2.0 .
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: wsmoused.h,v 1.2 2002/12/25 19:13:53 jmmv Exp $ */
|
/* $NetBSD: wsmoused.h,v 1.3 2003/03/04 14:33:55 jmmv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||||
@ -40,6 +40,7 @@ struct mouse {
|
|||||||
int fifo_fd;
|
int fifo_fd;
|
||||||
char *device_name;
|
char *device_name;
|
||||||
char *fifo_name;
|
char *fifo_name;
|
||||||
|
char *tstat_name;
|
||||||
|
|
||||||
/* Screen coordinates */
|
/* Screen coordinates */
|
||||||
size_t row, col;
|
size_t row, col;
|
||||||
@ -58,12 +59,46 @@ struct mouse {
|
|||||||
int but_paste;
|
int but_paste;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct prop {
|
||||||
|
char *p_name;
|
||||||
|
char *p_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAX_EVENTS 10
|
||||||
|
#define MAX_BLOCKS 10
|
||||||
|
#define MAX_PROPS 100
|
||||||
|
#define BLOCK_GLOBAL 1
|
||||||
|
#define BLOCK_MODE 2
|
||||||
|
#define BLOCK_EVENT 3
|
||||||
|
struct block {
|
||||||
|
char *b_name;
|
||||||
|
int b_type;
|
||||||
|
int b_prop_count;
|
||||||
|
int b_child_count;
|
||||||
|
struct prop *b_prop[MAX_BLOCKS];
|
||||||
|
struct block *b_child[MAX_BLOCKS];
|
||||||
|
struct block *b_parent;
|
||||||
|
};
|
||||||
|
|
||||||
/* Prototypes for wsmoused.c */
|
/* Prototypes for wsmoused.c */
|
||||||
void char_invert(struct mouse *, size_t, size_t);
|
void char_invert(struct mouse *, size_t, size_t);
|
||||||
void mouse_cursor_show(struct mouse *);
|
void mouse_cursor_show(struct mouse *);
|
||||||
void mouse_cursor_hide(struct mouse *);
|
void mouse_cursor_hide(struct mouse *);
|
||||||
void mouse_open_tty(struct mouse *, int);
|
void mouse_open_tty(struct mouse *, int);
|
||||||
|
|
||||||
|
/* Prototypes for config.c */
|
||||||
|
struct prop *prop_new(void);
|
||||||
|
void prop_free(struct prop *);
|
||||||
|
struct block *block_new(int);
|
||||||
|
void block_free(struct block *);
|
||||||
|
void block_add_prop(struct block *, struct prop *);
|
||||||
|
void block_add_child(struct block *, struct block *);
|
||||||
|
char *block_get_propval(struct block *, char *, char *);
|
||||||
|
int block_get_propval_int(struct block *, char *, int);
|
||||||
|
struct block *config_get_mode(char *);
|
||||||
|
void config_read(char *, int);
|
||||||
|
void config_free(void);
|
||||||
|
|
||||||
/* Prototypes for event.c */
|
/* Prototypes for event.c */
|
||||||
void mouse_motion_event(struct mouse *, struct wscons_event *);
|
void mouse_motion_event(struct mouse *, struct wscons_event *);
|
||||||
void mouse_button_event(struct mouse *, struct wscons_event *);
|
void mouse_button_event(struct mouse *, struct wscons_event *);
|
||||||
|
Loading…
Reference in New Issue
Block a user