Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 546 → Rev 547

/shark/trunk/drivers/input/shark/shark_joy.c
16,25 → 16,6
* http://shark.sssup.it
*/
 
/*
* Copyright (C) 2000 Paolo Gai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
 
#define __JOY_DEBUG__
//#define __JOY_DUMP__
 
59,10 → 40,55
extern int joystick_init(void);
extern int joystick_exit(void);
 
/* Functions */
extern int joystick_enable(void);
extern int joystick_disable(void);
extern int joystick_get(int *type, int *number, int *value);
 
extern int input_installed;
 
#define JS_EVENT_BUTTON 0x01 /* button pressed/released */
#define JS_EVENT_AXIS 0x02 /* joystick moved */
#define JS_EVENT_INIT 0x80 /* initial state of device */
 
/* joystick driver currently installed */
static int joystick_installed = FALSE;
static int axis[4], button;
 
/* Called by handler */
void shark_joy_exec(void) {
int type, number, value;
if (joystick_get(&type, &number, &value))
return;
 
switch (type) {
case JS_EVENT_BUTTON:
button = number; /* TODO */
break;
case JS_EVENT_AXIS:
axis[number] = value; /* TODO */
break;
default:
return;
}
#ifdef __JOY_DEBUG__
printk(KERN_DEBUG "shark_joy.c: (%4d,%4d) (%4d,%4d) %4d\n", axis[0], axis[1], axis[2], axis[3], button);
#endif
}
 
/* User Functions */
void joy_enable(void)
{
joystick_enable();
}
 
void joy_disable(void)
{
joystick_disable();
}
 
 
/* Init the Linux Joystick Driver */
int JOY26_init() {
 
96,11 → 122,16
return -1;
}
joy_enable();
joystick_installed = TRUE;
return 0;
}
 
int JOY26_close() {
if (!joystick_installed)
return -1;
 
joy_disable();
joystick_exit();
#ifdef __JOY_DUMP__
joydump_exit();
108,5 → 139,7
analog_exit();
#endif
ns558_exit();
 
joystick_installed = FALSE;
return 0;
}