Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 547 → Rev 548

/shark/trunk/drivers/input/shark/shark_joy.c
16,7 → 16,7
* http://shark.sssup.it
*/
 
#define __JOY_DEBUG__
//#define __JOY_DEBUG__
//#define __JOY_DUMP__
 
#include <kernel/kern.h>
41,8 → 41,6
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;
53,39 → 51,80
 
/* joystick driver currently installed */
static int joystick_installed = FALSE;
static int joystick_enabled = FALSE;
 
static int axis[4], button;
 
/* Called by handler */
void shark_joy_exec(void) {
int type, number, value;
 
if (joystick_enabled == FALSE)
return;
 
if (joystick_get(&type, &number, &value))
return;
 
switch (type) {
switch (type) { /* TODO */
case JS_EVENT_BUTTON:
button = number; /* TODO */
if (value)
button |= 1 << number;
else
button &= ~(1 << number);
break;
case JS_EVENT_AXIS:
axis[number] = value; /* TODO */
axis[number] = value;
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);
printk(KERN_DEBUG "shark_joy.c: (%4d,%4d) (%4d,%4d) %4x\n", axis[0], axis[1], axis[2], axis[3], button);
#endif
}
 
/* User Functions */
void joy_getstatus(int *axe0, int *axe1, int *axe2, int *axe3, int *buttons)
{
if (axe0)
*axe0 = axis[0];
if (axe1)
*axe1 = axis[1];
if (axe2)
*axe2 = axis[2];
if (axe3)
*axe3 = axis[3];
if (buttons)
*buttons = button;
}
 
void joy_setstatus(int axe0, int axe1, int axe2, int axe3, int buttons)
{
if ((axe0 > -32767) && (axe0 < 32767))
axis[0] = axe0;
if ((axe1 > -32767) && (axe1 < 32767))
axis[1] = axe1;
if ((axe2 > -32767) && (axe2 < 32767))
axis[2] = axe2;
if ((axe3 > -32767) && (axe3 < 32767))
axis[3] = axe3;
button = buttons;
}
 
void joy_enable(void)
{
joystick_enable();
joystick_enabled = TRUE;
#ifdef __JOY_DEBUG__
printk("shark_joy.c: Joystick Enabled.\n");
#endif
}
 
void joy_disable(void)
{
joystick_disable();
joystick_enabled = FALSE;
#ifdef __JOY_DEBUG__
printk("shark_joy.c: Joystick Disabled.\n");
#endif
}
 
 
121,9 → 160,10
printk(KERN_ERR "Joystick_Handler_Init return: %d\n", ret);
return -1;
}
joy_enable();
 
joystick_installed = TRUE;
joystick_enabled = TRUE;
 
return 0;
}
 
131,7 → 171,7
if (!joystick_installed)
return -1;
 
joy_disable();
joystick_enabled = FALSE;
joystick_exit();
#ifdef __JOY_DUMP__
joydump_exit();