Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 547 → Rev 548

/shark/trunk/drivers/input/include/drivers/shark_joy26.h
21,6 → 21,21
#ifndef __SHARK_JOY26_H__
#define __SHARK_JOY26_H__
 
/* Flag Codes */
#define BTN1_BIT 0x01
#define BTN2_BIT 0x02
#define BTN3_BIT 0x04
#define BTN4_BIT 0x08
 
#define isButton1(b) (b & BTN1_BIT)
#define isButton2(b) (b & BTN2_BIT)
#define isButton3(b) (b & BTN3_BIT)
#define isButton4(b) (b & BTN4_BIT)
#define isButton(b, n) (b & (1<<n))
 
void joy_getstatus(int *axe0, int *axe1, int *axe2, int *axe3, int *button);
void joy_setstatus(int axe0, int axe1, int axe2, int axe3, int button);
 
void joy_enable(void);
void joy_disable(void);
 
/shark/trunk/drivers/input/shark/shark_mouse.c
151,10 → 151,14
 
void mouse_getpos(int *x,int *y,int *z, unsigned long *buttons)
{
*x = mouse_x;
*y = mouse_y;
*z = mouse_z;
*buttons = mouse_buttons;
if (x)
*x = mouse_x;
if (y)
*y = mouse_y;
if (z)
*z = mouse_z;
if (buttons)
*buttons = mouse_buttons;
}
 
void mouse_setpos(int x,int y, int z)
180,10 → 184,14
 
void mouse_getlimit(int *xmin, int *ymin, int *xmax, int *ymax)
{
*xmin = mouse_xmin_tick / mouse_threshold;
*ymin = mouse_ymin_tick / mouse_threshold;
*xmax = mouse_xmax_tick / mouse_threshold;
*ymax = mouse_ymax_tick / mouse_threshold;
if (xmin)
*xmin = mouse_xmin_tick / mouse_threshold;
if (ymin)
*ymin = mouse_ymin_tick / mouse_threshold;
if (xmax)
*xmax = mouse_xmax_tick / mouse_threshold;
if (ymax)
*ymax = mouse_ymax_tick / mouse_threshold;
}
 
int mouse_setlimit(int xmin, int ymin, int xmax, int ymax)
/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();
/shark/trunk/drivers/input/handler/joystick.c
42,8 → 42,8
static struct input_handler joystick_handler;
 
struct joydev {
int exist;
int open;
/*int exist;
int open;*/
int minor;
char name[16];
struct js_corr corr[ABS_MAX];
75,7 → 75,7
*/
static unsigned jtail, jhead;
 
static int tmp_axe[4], axe[4];
//static int tmp_axe[4], axe[4];
 
/*
* Get data from the joystick
96,39 → 96,6
return 0;
}
 
int joystick_enable()
{
struct list_head *node;
 
list_for_each(node,&joystick_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
struct joydev *joydev = handle->private;
 
joydev->open = 1;
 
input_open_device(handle);
}
 
return 0;
}
 
int joystick_disable()
{
struct list_head *node;
 
list_for_each(node,&joystick_handler.h_list) {
struct input_handle *handle = to_handle_h(node);
struct joydev *joydev = handle->private;
 
joydev->open = 0;
 
input_close_device(handle);
}
 
return 0;
}
 
static int joystick_correct(int value, struct js_corr *corr)
{
switch (corr->type) {
151,6 → 118,8
 
static void joystick_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
{
struct joydev *joydev = handle->private;
 
//printk(KERN_DEBUG "joystick.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value);
 
switch (type) {
162,7 → 131,7
#endif
if (jtail != jhead) {
jbuffer[jhead].type = JS_EVENT_BUTTON;
jbuffer[jhead].number = code - BTN_MISC; /* TODO */
jbuffer[jhead].number = joydev->keymap[code - BTN_MISC];
jbuffer[jhead].value = value;
jhead = (jhead+1) & JOY_BUFFERMASK;
} else
174,15 → 143,13
#ifdef DEBUG_JOY
printk(KERN_DEBUG "joystick.c: Event ABS. Code: %d, Value: %d\n", code, value);
#endif
tmp_axe[code] = value;
if (tmp_axe[code] == axe[code])
return;
axe[code] = tmp_axe[code];
 
if (jtail != jhead) {
jbuffer[jhead].type = JS_EVENT_AXIS;
jbuffer[jhead].number = code; /* TODO */
jbuffer[jhead].value = value;
jbuffer[jhead].number = joydev->absmap[code];
jbuffer[jhead].value = joystick_correct(value, joydev->corr + jbuffer[jhead].number);
if (jbuffer[jhead].value == joydev->abs[jbuffer[jhead].number])
return;
joydev->abs[jbuffer[jhead].number] = jbuffer[jhead].value;
jhead = (jhead+1) & JOY_BUFFERMASK;
} else
return;
231,7 → 198,6
handle->private = joydev;
joydev->minor = minor;
joydev->exist = 1;
sprintf26(joydev->name, "js%d", minor);
 
for (i = 0; i < ABS_MAX; i++)
275,7 → 241,7
 
joydev_table[minor] = joydev;
//input_open_device(handle);
input_open_device(handle);
 
#ifdef DEBUG_JOY
printk(KERN_DEBUG "joystick.c: Connected device: \"%s\", %s\n", dev->name, dev->phys);