* standart -> standard
* Hopefully fixed most of the coding style violations * ps2_trackpoint.h had the wrong header guard git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28425 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
617fdc096a
commit
5bb8f08567
|
@ -9,7 +9,7 @@ KernelAddon ps2 :
|
||||||
ps2_dev.c
|
ps2_dev.c
|
||||||
ps2_keyboard.c
|
ps2_keyboard.c
|
||||||
ps2_module.c
|
ps2_module.c
|
||||||
ps2_standart_mouse.c
|
ps2_standard_mouse.c
|
||||||
ps2_synaptics.c
|
ps2_synaptics.c
|
||||||
ps2_trackpoint.c
|
ps2_trackpoint.c
|
||||||
ps2_service.c
|
ps2_service.c
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
# define INFO(x...)
|
# define INFO(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef union
|
typedef union {
|
||||||
{
|
|
||||||
float value;
|
float value;
|
||||||
/* FIXME: Assumes 32 bit int. */
|
/* FIXME: Assumes 32 bit int. */
|
||||||
unsigned int word;
|
unsigned int word;
|
||||||
|
@ -41,23 +40,23 @@ floorf(float x)
|
||||||
uint32 i;
|
uint32 i;
|
||||||
GET_FLOAT_WORD(i0,x);
|
GET_FLOAT_WORD(i0,x);
|
||||||
j0 = ((i0>>23)&0xff)-0x7f;
|
j0 = ((i0>>23)&0xff)-0x7f;
|
||||||
if(j0<23) {
|
if (j0<23) {
|
||||||
if(j0<0) { /* raise inexact if x != 0 */
|
if (j0<0) { /* raise inexact if x != 0 */
|
||||||
if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
|
if (huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
|
||||||
if(i0>=0) {i0=0;}
|
if (i0>=0) {i0=0;}
|
||||||
else if((i0&0x7fffffff)!=0)
|
else if ((i0&0x7fffffff)!=0)
|
||||||
{ i0=0xbf800000;}
|
{ i0=0xbf800000;}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = (0x007fffff)>>j0;
|
i = (0x007fffff)>>j0;
|
||||||
if((i0&i)==0) return x; /* x is integral */
|
if ((i0&i)==0) return x; /* x is integral */
|
||||||
if(huge+x>(float)0.0) { /* raise inexact flag */
|
if (huge+x>(float)0.0) { /* raise inexact flag */
|
||||||
if(i0<0) i0 += (0x00800000)>>j0;
|
if (i0<0) i0 += (0x00800000)>>j0;
|
||||||
i0 &= (~i);
|
i0 &= (~i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(j0==0x80) return x+x; /* inf or NaN */
|
if (j0==0x80) return x+x; /* inf or NaN */
|
||||||
else return x; /* x is integral */
|
else return x; /* x is integral */
|
||||||
}
|
}
|
||||||
SET_FLOAT_WORD(x,i0);
|
SET_FLOAT_WORD(x,i0);
|
||||||
|
@ -73,22 +72,22 @@ ceilf(float x)
|
||||||
|
|
||||||
GET_FLOAT_WORD(i0,x);
|
GET_FLOAT_WORD(i0,x);
|
||||||
j0 = ((i0>>23)&0xff)-0x7f;
|
j0 = ((i0>>23)&0xff)-0x7f;
|
||||||
if(j0<23) {
|
if (j0<23) {
|
||||||
if(j0<0) { /* raise inexact if x != 0 */
|
if (j0<0) { /* raise inexact if x != 0 */
|
||||||
if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
|
if (huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */
|
||||||
if(i0<0) {i0=0x80000000;}
|
if (i0<0) {i0=0x80000000;}
|
||||||
else if(i0!=0) { i0=0x3f800000;}
|
else if (i0!=0) { i0=0x3f800000;}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = (0x007fffff)>>j0;
|
i = (0x007fffff)>>j0;
|
||||||
if((i0&i)==0) return x; /* x is integral */
|
if ((i0&i)==0) return x; /* x is integral */
|
||||||
if(huge+x>(float)0.0) { /* raise inexact flag */
|
if (huge+x>(float)0.0) { /* raise inexact flag */
|
||||||
if(i0>0) i0 += (0x00800000)>>j0;
|
if (i0>0) i0 += (0x00800000)>>j0;
|
||||||
i0 &= (~i);
|
i0 &= (~i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(j0==0x80) return x+x; /* inf or NaN */
|
if (j0==0x80) return x+x; /* inf or NaN */
|
||||||
else return x; /* x is integral */
|
else return x; /* x is integral */
|
||||||
}
|
}
|
||||||
SET_FLOAT_WORD(x,i0);
|
SET_FLOAT_WORD(x,i0);
|
||||||
|
@ -108,25 +107,25 @@ sqrtf(float x)
|
||||||
GET_FLOAT_WORD(ix,x);
|
GET_FLOAT_WORD(ix,x);
|
||||||
|
|
||||||
/* take care of Inf and NaN */
|
/* take care of Inf and NaN */
|
||||||
if((ix&0x7f800000)==0x7f800000) {
|
if ((ix&0x7f800000)==0x7f800000) {
|
||||||
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
|
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
|
||||||
sqrt(-inf)=sNaN */
|
sqrt(-inf)=sNaN */
|
||||||
}
|
}
|
||||||
/* take care of zero */
|
/* take care of zero */
|
||||||
if(ix<=0) {
|
if (ix<=0) {
|
||||||
if((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */
|
if ((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */
|
||||||
else if(ix<0)
|
else if (ix<0)
|
||||||
return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
|
return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
|
||||||
}
|
}
|
||||||
/* normalize x */
|
/* normalize x */
|
||||||
m = (ix>>23);
|
m = (ix>>23);
|
||||||
if(m==0) { /* subnormal x */
|
if (m==0) { /* subnormal x */
|
||||||
for(i=0;(ix&0x00800000)==0;i++) ix<<=1;
|
for(i=0;(ix&0x00800000)==0;i++) ix<<=1;
|
||||||
m -= i-1;
|
m -= i-1;
|
||||||
}
|
}
|
||||||
m -= 127; /* unbias exponent */
|
m -= 127; /* unbias exponent */
|
||||||
ix = (ix&0x007fffff)|0x00800000;
|
ix = (ix&0x007fffff)|0x00800000;
|
||||||
if(m&1) /* odd m, double x to make it even */
|
if (m&1) /* odd m, double x to make it even */
|
||||||
ix += ix;
|
ix += ix;
|
||||||
m >>= 1; /* m = [m/2] */
|
m >>= 1; /* m = [m/2] */
|
||||||
|
|
||||||
|
@ -137,7 +136,7 @@ sqrtf(float x)
|
||||||
|
|
||||||
while(r!=0) {
|
while(r!=0) {
|
||||||
t = s+r;
|
t = s+r;
|
||||||
if(t<=ix) {
|
if (t<=ix) {
|
||||||
s = t+r;
|
s = t+r;
|
||||||
ix -= t;
|
ix -= t;
|
||||||
q += r;
|
q += r;
|
||||||
|
@ -147,7 +146,7 @@ sqrtf(float x)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use floating add to find out rounding direction */
|
/* use floating add to find out rounding direction */
|
||||||
if(ix!=0) {
|
if (ix!=0) {
|
||||||
z = one-tiny; /* trigger inexact flag */
|
z = one-tiny; /* trigger inexact flag */
|
||||||
if (z>=one) {
|
if (z>=one) {
|
||||||
z = one+tiny;
|
z = one+tiny;
|
||||||
|
@ -165,8 +164,9 @@ sqrtf(float x)
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
make_small(float value){
|
make_small(float value)
|
||||||
if(value > 0)
|
{
|
||||||
|
if (value > 0)
|
||||||
return floorf(value);
|
return floorf(value);
|
||||||
else
|
else
|
||||||
return ceilf(value);
|
return ceilf(value);
|
||||||
|
@ -181,15 +181,14 @@ get_raw_movement(movement_maker *move, uint32 posX, uint32 posY)
|
||||||
float meanX = 0, meanY = 0;
|
float meanX = 0, meanY = 0;
|
||||||
|
|
||||||
// calculate mean
|
// calculate mean
|
||||||
for(i = 0; i < move->n_points; i++){
|
for (i = 0; i < move->n_points; i++) {
|
||||||
meanXOld+= move->historyX[i];
|
meanXOld+= move->historyX[i];
|
||||||
meanYOld+= move->historyY[i];
|
meanYOld+= move->historyY[i];
|
||||||
}
|
}
|
||||||
if(move->n_points == 0){
|
if (move->n_points == 0) {
|
||||||
meanXOld = posX;
|
meanXOld = posX;
|
||||||
meanYOld = posY;
|
meanYOld = posY;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
meanXOld = meanXOld / move->n_points;
|
meanXOld = meanXOld / move->n_points;
|
||||||
meanYOld = meanYOld / move->n_points;
|
meanYOld = meanYOld / move->n_points;
|
||||||
}
|
}
|
||||||
|
@ -198,14 +197,14 @@ get_raw_movement(movement_maker *move, uint32 posX, uint32 posY)
|
||||||
meanY = (meanYOld + posY) / 2;
|
meanY = (meanYOld + posY) / 2;
|
||||||
|
|
||||||
// fill history
|
// fill history
|
||||||
for(i = 0; i < HISTORY_SIZE - 1; i++){
|
for (i = 0; i < HISTORY_SIZE - 1; i++) {
|
||||||
move->historyX[i] = move->historyX[i + 1];
|
move->historyX[i] = move->historyX[i + 1];
|
||||||
move->historyY[i] = move->historyY[i + 1];
|
move->historyY[i] = move->historyY[i + 1];
|
||||||
}
|
}
|
||||||
move->historyX[HISTORY_SIZE - 1] = meanX;
|
move->historyX[HISTORY_SIZE - 1] = meanX;
|
||||||
move->historyY[HISTORY_SIZE - 1] = meanY;
|
move->historyY[HISTORY_SIZE - 1] = meanY;
|
||||||
|
|
||||||
if(move->n_points < HISTORY_SIZE){
|
if (move->n_points < HISTORY_SIZE) {
|
||||||
move->n_points++;
|
move->n_points++;
|
||||||
move->xDelta = 0;
|
move->xDelta = 0;
|
||||||
move->yDelta = 0;
|
move->yDelta = 0;
|
||||||
|
@ -266,9 +265,9 @@ get_scrolling(movement_maker *move, uint32 posX, uint32 posY)
|
||||||
void
|
void
|
||||||
start_new_movment(movement_maker *move)
|
start_new_movment(movement_maker *move)
|
||||||
{
|
{
|
||||||
if(move->scrolling_xStep <= 0)
|
if (move->scrolling_xStep <= 0)
|
||||||
move->scrolling_xStep = 1;
|
move->scrolling_xStep = 1;
|
||||||
if(move->scrolling_yStep <= 0)
|
if (move->scrolling_yStep <= 0)
|
||||||
move->scrolling_yStep = 1;
|
move->scrolling_yStep = 1;
|
||||||
|
|
||||||
move->n_points = 0;
|
move->n_points = 0;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "ps2_dev.h"
|
#include "ps2_dev.h"
|
||||||
#include "ps2_service.h"
|
#include "ps2_service.h"
|
||||||
|
|
||||||
#include "ps2_standart_mouse.h"
|
#include "ps2_standard_mouse.h"
|
||||||
#include "ps2_synaptics.h"
|
#include "ps2_synaptics.h"
|
||||||
#include "ps2_trackpoint.h"
|
#include "ps2_trackpoint.h"
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@
|
||||||
|
|
||||||
|
|
||||||
ps2_dev ps2_device[PS2_DEVICE_COUNT] = {
|
ps2_dev ps2_device[PS2_DEVICE_COUNT] = {
|
||||||
{ .name = "input/mouse/ps2/0", .active = false, .idx = 0, .result_sem = -1, .command = standart_command_timeout },
|
{ .name = "input/mouse/ps2/0", .active = false, .idx = 0, .result_sem = -1, .command = standard_command_timeout },
|
||||||
{ .name = "input/mouse/ps2/1", .active = false, .idx = 1, .result_sem = -1, .command = standart_command_timeout },
|
{ .name = "input/mouse/ps2/1", .active = false, .idx = 1, .result_sem = -1, .command = standard_command_timeout },
|
||||||
{ .name = "input/mouse/ps2/2", .active = false, .idx = 2, .result_sem = -1, .command = standart_command_timeout },
|
{ .name = "input/mouse/ps2/2", .active = false, .idx = 2, .result_sem = -1, .command = standard_command_timeout },
|
||||||
{ .name = "input/mouse/ps2/3", .active = false, .idx = 3, .result_sem = -1, .command = standart_command_timeout },
|
{ .name = "input/mouse/ps2/3", .active = false, .idx = 3, .result_sem = -1, .command = standard_command_timeout },
|
||||||
{ .name = "input/mouse/ps2/synaptics_passthrough", .active = false, .result_sem = -1, .command = passthrough_command},
|
{ .name = "input/mouse/ps2/synaptics_passthrough", .active = false, .result_sem = -1, .command = passthrough_command},
|
||||||
{ .name = "input/keyboard/at/0", .active = false, .result_sem = -1, .flags = PS2_FLAG_KEYB, .command = standart_command_timeout }
|
{ .name = "input/keyboard/at/0", .active = false, .result_sem = -1, .flags = PS2_FLAG_KEYB, .command = standard_command_timeout }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,29 +67,29 @@ ps2_dev_detect_pointing(ps2_dev *dev, device_hooks **hooks)
|
||||||
// the probe function has to set the dev name and the dev packet size
|
// the probe function has to set the dev name and the dev packet size
|
||||||
|
|
||||||
status = probe_trackpoint(dev);
|
status = probe_trackpoint(dev);
|
||||||
if (status == B_OK){
|
if (status == B_OK) {
|
||||||
*hooks = &gStandartMouseDeviceHooks;
|
*hooks = &gStandardMouseDeviceHooks;
|
||||||
goto dev_found;
|
goto dev_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = probe_synaptics(dev);
|
status = probe_synaptics(dev);
|
||||||
if (status == B_OK){
|
if (status == B_OK) {
|
||||||
*hooks = &gSynapticsDeviceHooks;
|
*hooks = &gSynapticsDeviceHooks;
|
||||||
goto dev_found;
|
goto dev_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = probe_standart_mouse(dev);
|
status = probe_standard_mouse(dev);
|
||||||
if (status == B_OK){
|
if (status == B_OK) {
|
||||||
*hooks = &gStandartMouseDeviceHooks;
|
*hooks = &gStandardMouseDeviceHooks;
|
||||||
goto dev_found;
|
goto dev_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
dev_found:
|
dev_found:
|
||||||
if(dev == &(ps2_device[PS2_DEVICE_SYN_PASSTHROUGH])){
|
if (dev == &(ps2_device[PS2_DEVICE_SYN_PASSTHROUGH]))
|
||||||
synaptics_pt_set_packagesize(dev, dev->packet_size);
|
synaptics_pt_set_packagesize(dev, dev->packet_size);
|
||||||
}
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,13 +134,12 @@ ps2_dev_publish(ps2_dev *dev)
|
||||||
if (dev->active)
|
if (dev->active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(atomic_get(&dev->flags) & PS2_FLAG_KEYB){
|
if (atomic_get(&dev->flags) & PS2_FLAG_KEYB) {
|
||||||
status = devfs_publish_device(dev->name, &gKeyboardDeviceHooks);
|
status = devfs_publish_device(dev->name, &gKeyboardDeviceHooks);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
device_hooks *hooks;
|
device_hooks *hooks;
|
||||||
status = ps2_dev_detect_pointing(dev, &hooks);
|
status = ps2_dev_detect_pointing(dev, &hooks);
|
||||||
if(status == B_OK){
|
if (status == B_OK) {
|
||||||
status = devfs_publish_device(dev->name, hooks);
|
status = devfs_publish_device(dev->name, hooks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +264,7 @@ pass_to_handler:
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
standart_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout)
|
standard_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout)
|
||||||
{
|
{
|
||||||
status_t res;
|
status_t res;
|
||||||
bigtime_t start;
|
bigtime_t start;
|
||||||
|
|
|
@ -41,7 +41,8 @@ struct ps2_dev
|
||||||
// functions
|
// functions
|
||||||
void (*disconnect)(ps2_dev *);
|
void (*disconnect)(ps2_dev *);
|
||||||
int32 (*handle_int)(ps2_dev *);
|
int32 (*handle_int)(ps2_dev *);
|
||||||
status_t (*command)(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout);
|
status_t (*command)(ps2_dev *dev, uint8 cmd, const uint8 *out,
|
||||||
|
int out_count, uint8 *in, int in_count, bigtime_t timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PS2_DEVICE_COUNT 6
|
#define PS2_DEVICE_COUNT 6
|
||||||
|
@ -52,13 +53,13 @@ extern ps2_dev ps2_device[PS2_DEVICE_COUNT];
|
||||||
#define PS2_DEVICE_SYN_PASSTHROUGH 4
|
#define PS2_DEVICE_SYN_PASSTHROUGH 4
|
||||||
#define PS2_DEVICE_KEYB 5
|
#define PS2_DEVICE_KEYB 5
|
||||||
|
|
||||||
#define PS2_FLAG_KEYB (1<<0)
|
#define PS2_FLAG_KEYB (1 << 0)
|
||||||
#define PS2_FLAG_OPEN (1<<1)
|
#define PS2_FLAG_OPEN (1 << 1)
|
||||||
#define PS2_FLAG_ENABLED (1<<2)
|
#define PS2_FLAG_ENABLED (1 << 2)
|
||||||
#define PS2_FLAG_CMD (1<<3)
|
#define PS2_FLAG_CMD (1 << 3)
|
||||||
#define PS2_FLAG_ACK (1<<4)
|
#define PS2_FLAG_ACK (1 << 4)
|
||||||
#define PS2_FLAG_NACK (1<<5)
|
#define PS2_FLAG_NACK (1 << 5)
|
||||||
#define PS2_FLAG_GETID (1<<6)
|
#define PS2_FLAG_GETID (1 << 6)
|
||||||
|
|
||||||
void ps2_dev_send(ps2_dev *dev, uint8 data);
|
void ps2_dev_send(ps2_dev *dev, uint8 data);
|
||||||
|
|
||||||
|
@ -67,10 +68,13 @@ status_t ps2_dev_detect_pointing(ps2_dev *dev, device_hooks **hooks);
|
||||||
status_t ps2_dev_init(void);
|
status_t ps2_dev_init(void);
|
||||||
void ps2_dev_exit(void);
|
void ps2_dev_exit(void);
|
||||||
|
|
||||||
status_t standart_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout);
|
status_t standard_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out,
|
||||||
|
int out_count, uint8 *in, int in_count, bigtime_t timeout);
|
||||||
|
|
||||||
status_t ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count);
|
status_t ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out,
|
||||||
status_t ps2_dev_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout);
|
int out_count, uint8 *in, int in_count);
|
||||||
|
status_t ps2_dev_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out,
|
||||||
|
int out_count, uint8 *in, int in_count, bigtime_t timeout);
|
||||||
|
|
||||||
void ps2_dev_publish(ps2_dev *dev);
|
void ps2_dev_publish(ps2_dev *dev);
|
||||||
void ps2_dev_unpublish(ps2_dev *dev);
|
void ps2_dev_unpublish(ps2_dev *dev);
|
||||||
|
|
|
@ -58,17 +58,22 @@
|
||||||
|
|
||||||
#include "kb_mouse_driver.h"
|
#include "kb_mouse_driver.h"
|
||||||
#include "ps2_service.h"
|
#include "ps2_service.h"
|
||||||
#include "ps2_standart_mouse.h"
|
#include "ps2_standard_mouse.h"
|
||||||
|
|
||||||
|
|
||||||
const char* kStandartMousePath[4] = {"input/mouse/ps2/standart_0",
|
const char* kStandardMousePath[4] = {
|
||||||
"input/mouse/ps2/standart_1",
|
"input/mouse/ps2/standard_0",
|
||||||
"input/mouse/ps2/standart_2",
|
"input/mouse/ps2/standard_1",
|
||||||
"input/mouse/ps2/standart_3"};
|
"input/mouse/ps2/standard_2",
|
||||||
const char* kIntelliMousePath[4] = {"input/mouse/ps2/intelli_0",
|
"input/mouse/ps2/standard_3"
|
||||||
"input/mouse/ps2/intelli_1",
|
};
|
||||||
"input/mouse/ps2/intelli_2",
|
const char* kIntelliMousePath[4] = {
|
||||||
"input/mouse/ps2/intelli_3"};
|
"input/mouse/ps2/intelli_0",
|
||||||
|
"input/mouse/ps2/intelli_1",
|
||||||
|
"input/mouse/ps2/intelli_2",
|
||||||
|
"input/mouse/ps2/intelli_3"
|
||||||
|
};
|
||||||
|
|
||||||
/** Set sampling rate of the ps2 port.
|
/** Set sampling rate of the ps2 port.
|
||||||
*/
|
*/
|
||||||
static inline status_t
|
static inline status_t
|
||||||
|
@ -81,7 +86,8 @@ ps2_set_sample_rate(ps2_dev *dev, uint8 rate)
|
||||||
/** Converts a packet received by the mouse to a "movement".
|
/** Converts a packet received by the mouse to a "movement".
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ps2_packet_to_movement(standart_mouse_cookie *cookie, uint8 packet[], mouse_movement *pos)
|
ps2_packet_to_movement(standard_mouse_cookie *cookie, uint8 packet[],
|
||||||
|
mouse_movement *pos)
|
||||||
{
|
{
|
||||||
int buttons = packet[0] & 7;
|
int buttons = packet[0] & 7;
|
||||||
int xDelta = ((packet[0] & 0x10) ? ~0xff : 0) | packet[1];
|
int xDelta = ((packet[0] & 0x10) ? ~0xff : 0) | packet[1];
|
||||||
|
@ -107,7 +113,7 @@ ps2_packet_to_movement(standart_mouse_cookie *cookie, uint8 packet[], mouse_move
|
||||||
yDeltaWheel |= ~0x07;
|
yDeltaWheel |= ~0x07;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (cookie->flags & F_standart_mouse_TYPE_2WHEELS) {
|
if (cookie->flags & F_standard_mouse_TYPE_2WHEELS) {
|
||||||
switch (packet[3] & 0x0F) {
|
switch (packet[3] & 0x0F) {
|
||||||
case 0x01: yDeltaWheel = +1; break; // wheel 1 down
|
case 0x01: yDeltaWheel = +1; break; // wheel 1 down
|
||||||
case 0x0F: yDeltaWheel = -1; break; // wheel 1 up
|
case 0x0F: yDeltaWheel = -1; break; // wheel 1 up
|
||||||
|
@ -117,9 +123,10 @@ ps2_packet_to_movement(standart_mouse_cookie *cookie, uint8 packet[], mouse_move
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TRACE("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, w-yd %d\n",
|
// TRACE("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, "
|
||||||
// packet[0], packet[1], packet[2], packet[3],
|
// "w-yd %d\n", packet[0], packet[1], packet[2], packet[3],
|
||||||
// xDelta, yDelta, buttons, cookie->click_count, xDeltaWheel, yDeltaWheel);
|
// xDelta, yDelta, buttons, cookie->click_count, xDeltaWheel,
|
||||||
|
// yDeltaWheel);
|
||||||
|
|
||||||
if (pos) {
|
if (pos) {
|
||||||
pos->xdelta = xDelta;
|
pos->xdelta = xDelta;
|
||||||
|
@ -131,7 +138,8 @@ ps2_packet_to_movement(standart_mouse_cookie *cookie, uint8 packet[], mouse_move
|
||||||
pos->wheel_ydelta = yDeltaWheel;
|
pos->wheel_ydelta = yDeltaWheel;
|
||||||
pos->wheel_xdelta = xDeltaWheel;
|
pos->wheel_xdelta = xDeltaWheel;
|
||||||
|
|
||||||
TRACE("ps2: ps2_packet_to_movement xdelta: %d, ydelta: %d, buttons %x, clicks: %d, timestamp %Ld\n",
|
TRACE("ps2: ps2_packet_to_movement xdelta: %d, ydelta: %d, buttons %x, "
|
||||||
|
"clicks: %d, timestamp %Ld\n",
|
||||||
xDelta, yDelta, buttons, cookie->click_count, currentTime);
|
xDelta, yDelta, buttons, cookie->click_count, currentTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,24 +148,27 @@ ps2_packet_to_movement(standart_mouse_cookie *cookie, uint8 packet[], mouse_move
|
||||||
/** Read a mouse event from the mouse events chain buffer.
|
/** Read a mouse event from the mouse events chain buffer.
|
||||||
*/
|
*/
|
||||||
static status_t
|
static status_t
|
||||||
standart_mouse_read_event(standart_mouse_cookie *cookie, mouse_movement *movement)
|
standard_mouse_read_event(standard_mouse_cookie *cookie,
|
||||||
|
mouse_movement *movement)
|
||||||
{
|
{
|
||||||
uint8 packet[PS2_MAX_PACKET_SIZE];
|
uint8 packet[PS2_MAX_PACKET_SIZE];
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_read_event\n");
|
TRACE("ps2: standard_mouse_read_event\n");
|
||||||
|
|
||||||
status = acquire_sem_etc(cookie->standart_mouse_sem, 1, B_CAN_INTERRUPT, 0);
|
status = acquire_sem_etc(cookie->standard_mouse_sem, 1, B_CAN_INTERRUPT, 0);
|
||||||
TRACE("ps2: standart_mouse_read_event acquired\n");
|
TRACE("ps2: standard_mouse_read_event acquired\n");
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (!cookie->dev->active) {
|
if (!cookie->dev->active) {
|
||||||
TRACE("ps2: standart_mouse_read_event: Error device no longer active\n");
|
TRACE("ps2: standard_mouse_read_event: Error device no longer "
|
||||||
|
"active\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet_buffer_read(cookie->standart_mouse_buffer, packet, cookie->dev->packet_size) != cookie->dev->packet_size) {
|
if (packet_buffer_read(cookie->standard_mouse_buffer, packet,
|
||||||
|
cookie->dev->packet_size) != cookie->dev->packet_size) {
|
||||||
TRACE("ps2: error copying buffer\n");
|
TRACE("ps2: error copying buffer\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -171,12 +182,12 @@ standart_mouse_read_event(standart_mouse_cookie *cookie, mouse_movement *movemen
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
standart_mouse_disconnect(ps2_dev *dev)
|
standard_mouse_disconnect(ps2_dev *dev)
|
||||||
{
|
{
|
||||||
// the mouse device might not be opened at this point
|
// the mouse device might not be opened at this point
|
||||||
INFO("ps2: ps2_standart_mouse_disconnect %s\n", dev->name);
|
INFO("ps2: ps2_standard_mouse_disconnect %s\n", dev->name);
|
||||||
if (dev->flags & PS2_FLAG_OPEN)
|
if (dev->flags & PS2_FLAG_OPEN)
|
||||||
release_sem(((standart_mouse_cookie *)dev->cookie)->standart_mouse_sem);
|
release_sem(((standard_mouse_cookie *)dev->cookie)->standard_mouse_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,12 +198,12 @@ standart_mouse_disconnect(ps2_dev *dev)
|
||||||
* calls to the handler, each holds a different byte on the data port.
|
* calls to the handler, each holds a different byte on the data port.
|
||||||
*/
|
*/
|
||||||
int32
|
int32
|
||||||
standart_mouse_handle_int(ps2_dev *dev)
|
standard_mouse_handle_int(ps2_dev *dev)
|
||||||
{
|
{
|
||||||
standart_mouse_cookie *cookie = (standart_mouse_cookie*)dev->cookie;
|
standard_mouse_cookie *cookie = (standard_mouse_cookie*)dev->cookie;
|
||||||
const uint8 data = dev->history[0].data;
|
const uint8 data = dev->history[0].data;
|
||||||
|
|
||||||
TRACE("ps2: standart mouse: %1x\t%1x\t%1x\t%1x\t%1x\t%1x\t%1x\t%1x\n",
|
TRACE("ps2: standard mouse: %1x\t%1x\t%1x\t%1x\t%1x\t%1x\t%1x\t%1x\n",
|
||||||
data >> 7 & 1, data >> 6 & 1, data >> 5 & 1,
|
data >> 7 & 1, data >> 6 & 1, data >> 5 & 1,
|
||||||
data >> 4 & 1, data >> 3 & 1, data >> 2 & 1,
|
data >> 4 & 1, data >> 3 & 1, data >> 2 & 1,
|
||||||
data >> 1 & 1, data >> 0 & 1);
|
data >> 1 & 1, data >> 0 & 1);
|
||||||
|
@ -209,17 +220,21 @@ standart_mouse_handle_int(ps2_dev *dev)
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
if (cookie->packet_index == 1) {
|
if (cookie->packet_index == 1) {
|
||||||
int xDelta = ((cookie->packet_buffer[0] & 0x10) ? 0xFFFFFF00 : 0) | data;
|
int xDelta
|
||||||
|
= ((cookie->packet_buffer[0] & 0x10) ? 0xFFFFFF00 : 0) | data;
|
||||||
if (xDelta < -100 || xDelta > 100) {
|
if (xDelta < -100 || xDelta > 100) {
|
||||||
INFO("ps2: strange mouse data, x-delta %d, trying resync\n", xDelta);
|
INFO("ps2: strange mouse data, x-delta %d, trying resync\n",
|
||||||
|
xDelta);
|
||||||
cookie->packet_index = 0;
|
cookie->packet_index = 0;
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cookie->packet_index == 2) {
|
if (cookie->packet_index == 2) {
|
||||||
int yDelta = ((cookie->packet_buffer[0] & 0x20) ? 0xFFFFFF00 : 0) | data;
|
int yDelta
|
||||||
|
= ((cookie->packet_buffer[0] & 0x20) ? 0xFFFFFF00 : 0) | data;
|
||||||
if (yDelta < -100 || yDelta > 100) {
|
if (yDelta < -100 || yDelta > 100) {
|
||||||
INFO("ps2: strange mouse data, y-delta %d, trying resync\n", yDelta);
|
INFO("ps2: strange mouse data, y-delta %d, trying resync\n",
|
||||||
|
yDelta);
|
||||||
cookie->packet_index = 0;
|
cookie->packet_index = 0;
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
|
@ -235,12 +250,13 @@ standart_mouse_handle_int(ps2_dev *dev)
|
||||||
// complete packet is assembled
|
// complete packet is assembled
|
||||||
|
|
||||||
cookie->packet_index = 0;
|
cookie->packet_index = 0;
|
||||||
if (packet_buffer_write(cookie->standart_mouse_buffer, cookie->packet_buffer, dev->packet_size) != dev->packet_size) {
|
if (packet_buffer_write(cookie->standard_mouse_buffer,
|
||||||
|
cookie->packet_buffer, dev->packet_size) != dev->packet_size) {
|
||||||
// buffer is full, drop new data
|
// buffer is full, drop new data
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
release_sem_etc(cookie->standart_mouse_sem, 1, B_DO_NOT_RESCHEDULE);
|
release_sem_etc(cookie->standard_mouse_sem, 1, B_DO_NOT_RESCHEDULE);
|
||||||
return B_INVOKE_SCHEDULER;
|
return B_INVOKE_SCHEDULER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +265,7 @@ standart_mouse_handle_int(ps2_dev *dev)
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
probe_standart_mouse(ps2_dev * dev)
|
probe_standard_mouse(ps2_dev * dev)
|
||||||
{
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
uint8 deviceId = 0;
|
uint8 deviceId = 0;
|
||||||
|
@ -269,16 +285,18 @@ probe_standart_mouse(ps2_dev * dev)
|
||||||
status = ps2_set_sample_rate(dev, 200);
|
status = ps2_set_sample_rate(dev, 200);
|
||||||
status |= ps2_set_sample_rate(dev, 100);
|
status |= ps2_set_sample_rate(dev, 100);
|
||||||
status |= ps2_set_sample_rate(dev, 80);
|
status |= ps2_set_sample_rate(dev, 80);
|
||||||
status |= ps2_dev_command(dev, PS2_CMD_GET_DEVICE_ID, NULL, 0, &alternate_device_id, 1);
|
status |= ps2_dev_command(dev, PS2_CMD_GET_DEVICE_ID, NULL, 0,
|
||||||
|
&alternate_device_id, 1);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
TRACE("ps2: probe_mouse alternate device id: %2x\n", alternate_device_id);
|
TRACE("ps2: probe_mouse alternate device id: %2x\n",
|
||||||
|
alternate_device_id);
|
||||||
deviceId = alternate_device_id;
|
deviceId = alternate_device_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceId == PS2_DEV_ID_STANDARD) {
|
if (deviceId == PS2_DEV_ID_STANDARD) {
|
||||||
INFO("ps2: probe_mouse Standard PS/2 mouse found\n");
|
INFO("ps2: probe_mouse Standard PS/2 mouse found\n");
|
||||||
dev->name = kStandartMousePath[dev->idx];
|
dev->name = kStandardMousePath[dev->idx];
|
||||||
dev->packet_size = PS2_PACKET_STANDARD;
|
dev->packet_size = PS2_PACKET_STANDARD;
|
||||||
} else if (deviceId == PS2_DEV_ID_INTELLIMOUSE) {
|
} else if (deviceId == PS2_DEV_ID_INTELLIMOUSE) {
|
||||||
dev->name = kIntelliMousePath[dev->idx];
|
dev->name = kIntelliMousePath[dev->idx];
|
||||||
|
@ -298,14 +316,14 @@ probe_standart_mouse(ps2_dev * dev)
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
standart_mouse_open(const char *name, uint32 flags, void **_cookie)
|
standard_mouse_open(const char *name, uint32 flags, void **_cookie)
|
||||||
{
|
{
|
||||||
standart_mouse_cookie *cookie;
|
standard_mouse_cookie *cookie;
|
||||||
status_t status;
|
status_t status;
|
||||||
ps2_dev *dev = NULL;
|
ps2_dev *dev = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_open %s\n", name);
|
TRACE("ps2: standard_mouse_open %s\n", name);
|
||||||
|
|
||||||
for (dev = NULL, i = 0; i < PS2_DEVICE_COUNT; i++) {
|
for (dev = NULL, i = 0; i < PS2_DEVICE_COUNT; i++) {
|
||||||
if (0 == strcmp(ps2_device[i].name, name)) {
|
if (0 == strcmp(ps2_device[i].name, name)) {
|
||||||
|
@ -327,7 +345,7 @@ standart_mouse_open(const char *name, uint32 flags, void **_cookie)
|
||||||
if (atomic_or(&dev->flags, PS2_FLAG_OPEN) & PS2_FLAG_OPEN)
|
if (atomic_or(&dev->flags, PS2_FLAG_OPEN) & PS2_FLAG_OPEN)
|
||||||
return B_BUSY;
|
return B_BUSY;
|
||||||
|
|
||||||
cookie = malloc(sizeof(standart_mouse_cookie));
|
cookie = malloc(sizeof(standard_mouse_cookie));
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
|
@ -336,26 +354,26 @@ standart_mouse_open(const char *name, uint32 flags, void **_cookie)
|
||||||
|
|
||||||
cookie->dev = dev;
|
cookie->dev = dev;
|
||||||
dev->cookie = cookie;
|
dev->cookie = cookie;
|
||||||
dev->disconnect = &standart_mouse_disconnect;
|
dev->disconnect = &standard_mouse_disconnect;
|
||||||
dev->handle_int = &standart_mouse_handle_int;
|
dev->handle_int = &standard_mouse_handle_int;
|
||||||
|
|
||||||
if(strstr(dev->name, "standard_mouse") != NULL){
|
if (strstr(dev->name, "standard_mouse") != NULL)
|
||||||
cookie->flags = F_pointing_dev_TYPE_STANDARD;
|
cookie->flags = F_pointing_dev_TYPE_STANDARD;
|
||||||
}
|
|
||||||
if(strstr(dev->name, "intelli_mouse") != NULL){
|
|
||||||
cookie->flags = F_pointing_dev_TYPE_INTELLIMOUSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cookie->standart_mouse_buffer = create_packet_buffer(standart_mouse_HISTORY_SIZE * dev->packet_size);
|
if (strstr(dev->name, "intelli_mouse") != NULL)
|
||||||
if (cookie->standart_mouse_buffer == NULL) {
|
cookie->flags = F_pointing_dev_TYPE_INTELLIMOUSE;
|
||||||
|
|
||||||
|
cookie->standard_mouse_buffer
|
||||||
|
= create_packet_buffer(standard_mouse_HISTORY_SIZE * dev->packet_size);
|
||||||
|
if (cookie->standard_mouse_buffer == NULL) {
|
||||||
TRACE("ps2: can't allocate mouse actions buffer\n");
|
TRACE("ps2: can't allocate mouse actions buffer\n");
|
||||||
goto err2;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the mouse semaphore, used for synchronization between
|
// create the mouse semaphore, used for synchronization between
|
||||||
// the interrupt handler and the read operation
|
// the interrupt handler and the read operation
|
||||||
cookie->standart_mouse_sem = create_sem(0, "ps2_standart_mouse_sem");
|
cookie->standard_mouse_sem = create_sem(0, "ps2_standard_mouse_sem");
|
||||||
if (cookie->standart_mouse_sem < 0) {
|
if (cookie->standard_mouse_sem < 0) {
|
||||||
TRACE("ps2: failed creating PS/2 mouse semaphore!\n");
|
TRACE("ps2: failed creating PS/2 mouse semaphore!\n");
|
||||||
goto err3;
|
goto err3;
|
||||||
}
|
}
|
||||||
|
@ -369,54 +387,55 @@ standart_mouse_open(const char *name, uint32 flags, void **_cookie)
|
||||||
atomic_or(&dev->flags, PS2_FLAG_ENABLED);
|
atomic_or(&dev->flags, PS2_FLAG_ENABLED);
|
||||||
|
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_open %s success\n", name);
|
TRACE("ps2: standard_mouse_open %s success\n", name);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
err4:
|
err4:
|
||||||
delete_sem(cookie->standart_mouse_sem);
|
delete_sem(cookie->standard_mouse_sem);
|
||||||
err3:
|
err3:
|
||||||
delete_packet_buffer(cookie->standart_mouse_buffer);
|
delete_packet_buffer(cookie->standard_mouse_buffer);
|
||||||
err2:
|
err2:
|
||||||
free(cookie);
|
free(cookie);
|
||||||
err1:
|
err1:
|
||||||
atomic_and(&dev->flags, ~PS2_FLAG_OPEN);
|
atomic_and(&dev->flags, ~PS2_FLAG_OPEN);
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_open %s failed\n", name);
|
TRACE("ps2: standard_mouse_open %s failed\n", name);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
standart_mouse_close(void *_cookie)
|
standard_mouse_close(void *_cookie)
|
||||||
{
|
{
|
||||||
standart_mouse_cookie *cookie = (standart_mouse_cookie*)_cookie;
|
standard_mouse_cookie *cookie = (standard_mouse_cookie*)_cookie;
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_close %s enter\n", cookie->dev->name);
|
TRACE("ps2: standard_mouse_close %s enter\n", cookie->dev->name);
|
||||||
|
|
||||||
ps2_dev_command_timeout(cookie->dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0, 150000);
|
ps2_dev_command_timeout(cookie->dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0,
|
||||||
|
150000);
|
||||||
|
|
||||||
delete_packet_buffer(cookie->standart_mouse_buffer);
|
delete_packet_buffer(cookie->standard_mouse_buffer);
|
||||||
delete_sem(cookie->standart_mouse_sem);
|
delete_sem(cookie->standard_mouse_sem);
|
||||||
|
|
||||||
atomic_and(&cookie->dev->flags, ~PS2_FLAG_OPEN);
|
atomic_and(&cookie->dev->flags, ~PS2_FLAG_OPEN);
|
||||||
atomic_and(&cookie->dev->flags, ~PS2_FLAG_ENABLED);
|
atomic_and(&cookie->dev->flags, ~PS2_FLAG_ENABLED);
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_close %s done\n", cookie->dev->name);
|
TRACE("ps2: standard_mouse_close %s done\n", cookie->dev->name);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
standart_mouse_freecookie(void *_cookie)
|
standard_mouse_freecookie(void *_cookie)
|
||||||
{
|
{
|
||||||
standart_mouse_cookie *cookie = (standart_mouse_cookie*)_cookie;
|
standard_mouse_cookie *cookie = (standard_mouse_cookie*)_cookie;
|
||||||
free(cookie);
|
free(cookie);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
standart_mouse_read(void *cookie, off_t pos, void *buffer, size_t *_length)
|
standard_mouse_read(void *cookie, off_t pos, void *buffer, size_t *_length)
|
||||||
{
|
{
|
||||||
*_length = 0;
|
*_length = 0;
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
@ -424,7 +443,8 @@ standart_mouse_read(void *cookie, off_t pos, void *buffer, size_t *_length)
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
standart_mouse_write(void *cookie, off_t pos, const void *buffer, size_t *_length)
|
standard_mouse_write(void *cookie, off_t pos, const void *buffer,
|
||||||
|
size_t *_length)
|
||||||
{
|
{
|
||||||
*_length = 0;
|
*_length = 0;
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
@ -432,16 +452,16 @@ standart_mouse_write(void *cookie, off_t pos, const void *buffer, size_t *_lengt
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
standart_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
standard_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
||||||
{
|
{
|
||||||
standart_mouse_cookie *cookie = (standart_mouse_cookie*)_cookie;
|
standard_mouse_cookie *cookie = (standard_mouse_cookie*)_cookie;
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case MS_NUM_EVENTS:
|
case MS_NUM_EVENTS:
|
||||||
{
|
{
|
||||||
int32 count;
|
int32 count;
|
||||||
TRACE("ps2: ioctl MS_NUM_EVENTS\n");
|
TRACE("ps2: ioctl MS_NUM_EVENTS\n");
|
||||||
get_sem_count(cookie->standart_mouse_sem, &count);
|
get_sem_count(cookie->standard_mouse_sem, &count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,10 +470,11 @@ standart_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
||||||
mouse_movement movement;
|
mouse_movement movement;
|
||||||
status_t status;
|
status_t status;
|
||||||
TRACE("ps2: ioctl MS_READ\n");
|
TRACE("ps2: ioctl MS_READ\n");
|
||||||
if ((status = standart_mouse_read_event(cookie, &movement)) < B_OK)
|
if ((status = standard_mouse_read_event(cookie, &movement)) < B_OK)
|
||||||
return status;
|
return status;
|
||||||
// TRACE("%s %d %d %d %d\n", cookie->dev->name,
|
// TRACE("%s %d %d %d %d\n", cookie->dev->name,
|
||||||
// movement.xdelta, movement.ydelta, movement.buttons, movement.clicks);
|
// movement.xdelta, movement.ydelta, movement.buttons,
|
||||||
|
// movement.clicks);
|
||||||
return user_memcpy(buffer, &movement, sizeof(movement));
|
return user_memcpy(buffer, &movement, sizeof(movement));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,15 +483,18 @@ standart_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
case MS_SET_MAP:
|
case MS_SET_MAP:
|
||||||
TRACE("ps2: ioctl MS_SET_MAP (set mouse mapping) not implemented\n");
|
TRACE("ps2: ioctl MS_SET_MAP (set mouse mapping) not "
|
||||||
|
"implemented\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
case MS_GET_ACCEL:
|
case MS_GET_ACCEL:
|
||||||
TRACE("ps2: ioctl MS_GET_ACCEL (get mouse acceleration) not implemented\n");
|
TRACE("ps2: ioctl MS_GET_ACCEL (get mouse acceleration) not "
|
||||||
|
"implemented\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
case MS_SET_ACCEL:
|
case MS_SET_ACCEL:
|
||||||
TRACE("ps2: ioctl MS_SET_ACCEL (set mouse acceleration) not implemented\n");
|
TRACE("ps2: ioctl MS_SET_ACCEL (set mouse acceleration) not "
|
||||||
|
"implemented\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
case MS_SET_CLICKSPEED:
|
case MS_SET_CLICKSPEED:
|
||||||
|
@ -484,11 +508,11 @@ standart_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
device_hooks gStandartMouseDeviceHooks = {
|
device_hooks gStandardMouseDeviceHooks = {
|
||||||
standart_mouse_open,
|
standard_mouse_open,
|
||||||
standart_mouse_close,
|
standard_mouse_close,
|
||||||
standart_mouse_freecookie,
|
standard_mouse_freecookie,
|
||||||
standart_mouse_ioctl,
|
standard_mouse_ioctl,
|
||||||
standart_mouse_read,
|
standard_mouse_read,
|
||||||
standart_mouse_write,
|
standard_mouse_write,
|
||||||
};
|
};
|
|
@ -12,14 +12,14 @@
|
||||||
* Clemens Zeidler <czeidler@gmx.de>
|
* Clemens Zeidler <czeidler@gmx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PS2_STANDART_standart_mouse_H
|
#ifndef __PS2_STANDARD_standard_mouse_H
|
||||||
#define __PS2_STANDART_standart_mouse_H
|
#define __PS2_STANDARD_standard_mouse_H
|
||||||
|
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
|
|
||||||
#include "packet_buffer.h"
|
#include "packet_buffer.h"
|
||||||
|
|
||||||
#define standart_mouse_HISTORY_SIZE 256
|
#define standard_mouse_HISTORY_SIZE 256
|
||||||
// we record that many mouse packets before we start to drop them
|
// we record that many mouse packets before we start to drop them
|
||||||
|
|
||||||
#define F_pointing_dev_TYPE_STANDARD 0x1
|
#define F_pointing_dev_TYPE_STANDARD 0x1
|
||||||
|
@ -29,8 +29,8 @@ typedef struct
|
||||||
{
|
{
|
||||||
ps2_dev * dev;
|
ps2_dev * dev;
|
||||||
|
|
||||||
sem_id standart_mouse_sem;
|
sem_id standard_mouse_sem;
|
||||||
packet_buffer * standart_mouse_buffer;
|
packet_buffer * standard_mouse_buffer;
|
||||||
bigtime_t click_last_time;
|
bigtime_t click_last_time;
|
||||||
bigtime_t click_speed;
|
bigtime_t click_speed;
|
||||||
int click_count;
|
int click_count;
|
||||||
|
@ -39,21 +39,22 @@ typedef struct
|
||||||
size_t packet_index;
|
size_t packet_index;
|
||||||
uint8 packet_buffer[PS2_MAX_PACKET_SIZE];
|
uint8 packet_buffer[PS2_MAX_PACKET_SIZE];
|
||||||
|
|
||||||
} standart_mouse_cookie;
|
} standard_mouse_cookie;
|
||||||
|
|
||||||
|
|
||||||
status_t probe_standart_mouse(ps2_dev *dev);
|
status_t probe_standard_mouse(ps2_dev *dev);
|
||||||
|
|
||||||
status_t standart_mouse_open(const char *name, uint32 flags, void **_cookie);
|
status_t standard_mouse_open(const char *name, uint32 flags, void **_cookie);
|
||||||
status_t standart_mouse_close(void *_cookie);
|
status_t standard_mouse_close(void *_cookie);
|
||||||
status_t standart_mouse_freecookie(void *_cookie);
|
status_t standard_mouse_freecookie(void *_cookie);
|
||||||
status_t standart_mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length);
|
status_t standard_mouse_ioctl(void *_cookie, uint32 op, void *buffer,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
int32 standart_mouse_handle_int(ps2_dev *dev);
|
int32 standard_mouse_handle_int(ps2_dev *dev);
|
||||||
void standart_mouse_disconnect(ps2_dev *dev);
|
void standard_mouse_disconnect(ps2_dev *dev);
|
||||||
|
|
||||||
device_hooks gStandartMouseDeviceHooks;
|
device_hooks gStandardMouseDeviceHooks;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif /* __PS2_STANDARD_standard_mouse_H */
|
||||||
|
|
|
@ -16,13 +16,15 @@
|
||||||
#include "ps2_synaptics.h"
|
#include "ps2_synaptics.h"
|
||||||
#include "kb_mouse_driver.h"
|
#include "kb_mouse_driver.h"
|
||||||
|
|
||||||
const char* kSynapticsPath[4] = {"input/touchpad/ps2/synaptics_0",
|
const char* kSynapticsPath[4] = {
|
||||||
"input/touchpad/ps2/synaptics_1",
|
"input/touchpad/ps2/synaptics_0",
|
||||||
"input/touchpad/ps2/synaptics_2",
|
"input/touchpad/ps2/synaptics_1",
|
||||||
"input/touchpad/ps2/synaptics_3"};
|
"input/touchpad/ps2/synaptics_2",
|
||||||
|
"input/touchpad/ps2/synaptics_3"
|
||||||
|
};
|
||||||
|
|
||||||
static touchpad_info g_touchpad_info;
|
static touchpad_info gTouchpadInfo;
|
||||||
ps2_dev *g_passthrough_dev = &ps2_device[PS2_DEVICE_SYN_PASSTHROUGH];
|
ps2_dev *gPassthroughDevice = &ps2_device[PS2_DEVICE_SYN_PASSTHROUGH];
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -37,7 +39,8 @@ synaptics_pt_set_packagesize(ps2_dev *dev, uint8 size)
|
||||||
{
|
{
|
||||||
synaptics_cookie* syn_cookie = dev->parent_dev->cookie;
|
synaptics_cookie* syn_cookie = dev->parent_dev->cookie;
|
||||||
|
|
||||||
status_t status = ps2_dev_command(dev->parent_dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0);
|
status_t status = ps2_dev_command(dev->parent_dev, PS2_CMD_DISABLE, NULL,
|
||||||
|
0, NULL, 0);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
INFO("SYNAPTICS: cannot disable touchpad %s\n", dev->parent_dev->name);
|
INFO("SYNAPTICS: cannot disable touchpad %s\n", dev->parent_dev->name);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
@ -45,12 +48,10 @@ synaptics_pt_set_packagesize(ps2_dev *dev, uint8 size)
|
||||||
|
|
||||||
syn_cookie->packet_index = 0;
|
syn_cookie->packet_index = 0;
|
||||||
|
|
||||||
if(size == 4){
|
if (size == 4)
|
||||||
syn_cookie->mode|= SYN_FOUR_BYTE_CHILD;
|
syn_cookie->mode|= SYN_FOUR_BYTE_CHILD;
|
||||||
}
|
else
|
||||||
else{
|
|
||||||
syn_cookie->mode&= ~SYN_FOUR_BYTE_CHILD;
|
syn_cookie->mode&= ~SYN_FOUR_BYTE_CHILD;
|
||||||
}
|
|
||||||
set_touchpad_mode(dev->parent_dev, syn_cookie->mode);
|
set_touchpad_mode(dev->parent_dev, syn_cookie->mode);
|
||||||
|
|
||||||
status = ps2_dev_command(dev->parent_dev, PS2_CMD_ENABLE, NULL, 0, NULL, 0);
|
status = ps2_dev_command(dev->parent_dev, PS2_CMD_ENABLE, NULL, 0, NULL, 0);
|
||||||
|
@ -63,16 +64,18 @@ synaptics_pt_set_packagesize(ps2_dev *dev, uint8 size)
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
send_touchpad_arg(ps2_dev *dev, uint8 arg){
|
send_touchpad_arg(ps2_dev *dev, uint8 arg)
|
||||||
|
{
|
||||||
return send_touchpad_arg_timeout(dev, arg, 4000000);
|
return send_touchpad_arg_timeout(dev, arg, 4000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
send_touchpad_arg_timeout(ps2_dev *dev, uint8 arg, bigtime_t timeout){
|
send_touchpad_arg_timeout(ps2_dev *dev, uint8 arg, bigtime_t timeout)
|
||||||
|
{
|
||||||
int8 i;
|
int8 i;
|
||||||
uint8 val[8];
|
uint8 val[8];
|
||||||
for(i = 0; i < 4; i++){
|
for (i = 0; i < 4; i++) {
|
||||||
val[2*i] = (arg >> (6-2*i)) & 3;
|
val[2*i] = (arg >> (6-2*i)) & 3;
|
||||||
val[2*i + 1] = 0xE8;
|
val[2*i + 1] = 0xE8;
|
||||||
}
|
}
|
||||||
|
@ -85,12 +88,14 @@ set_touchpad_mode(ps2_dev *dev, uint8 mode)
|
||||||
{
|
{
|
||||||
uint8 sample_rate = SYN_CHANGE_MODE;
|
uint8 sample_rate = SYN_CHANGE_MODE;
|
||||||
send_touchpad_arg(dev, mode);
|
send_touchpad_arg(dev, mode);
|
||||||
return ps2_dev_command(dev, PS2_CMD_SET_SAMPLE_RATE, &sample_rate, 1, NULL, 0);
|
return ps2_dev_command(dev, PS2_CMD_SET_SAMPLE_RATE, &sample_rate, 1,
|
||||||
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout)
|
passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count,
|
||||||
|
uint8 *in, int in_count, bigtime_t timeout)
|
||||||
{
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
uint8 pt_cmd = SYN_PASSTHROUGH_CMD;
|
uint8 pt_cmd = SYN_PASSTHROUGH_CMD;
|
||||||
|
@ -101,51 +106,45 @@ passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, ui
|
||||||
|
|
||||||
TRACE("SYNAPTICS: passthrough command 0x%x\n", cmd);
|
TRACE("SYNAPTICS: passthrough command 0x%x\n", cmd);
|
||||||
|
|
||||||
status = ps2_dev_command(dev->parent_dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0);
|
status = ps2_dev_command(dev->parent_dev, PS2_CMD_DISABLE, NULL, 0,
|
||||||
if(status != B_OK){
|
NULL, 0);
|
||||||
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = -1; i < out_count; i++) {
|
for (i = -1; i < out_count; i++) {
|
||||||
if (i == -1) {
|
if (i == -1)
|
||||||
val = cmd;
|
val = cmd;
|
||||||
} else {
|
else
|
||||||
val = out[i];
|
val = out[i];
|
||||||
}
|
|
||||||
status = send_touchpad_arg_timeout(dev->parent_dev, val, timeout);
|
status = send_touchpad_arg_timeout(dev->parent_dev, val, timeout);
|
||||||
if(status != B_OK){
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
}
|
if (i != out_count -1) {
|
||||||
if(i != out_count -1){
|
status = ps2_dev_command_timeout(dev->parent_dev,
|
||||||
status = ps2_dev_command_timeout(dev->parent_dev, PS2_CMD_SET_SAMPLE_RATE,
|
PS2_CMD_SET_SAMPLE_RATE, &pt_cmd, 1, NULL, 0, timeout);
|
||||||
&pt_cmd, 1, NULL, 0, timeout);
|
if (status != B_OK)
|
||||||
if(status != B_OK){
|
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = ps2_dev_command_timeout(dev->parent_dev, PS2_CMD_SET_SAMPLE_RATE,
|
status = ps2_dev_command_timeout(dev->parent_dev, PS2_CMD_SET_SAMPLE_RATE,
|
||||||
&pt_cmd, 1, pt_in, pt_in_count, timeout);
|
&pt_cmd, 1, pt_in, pt_in_count, timeout);
|
||||||
if(status != B_OK){
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < in_count + 1; i++){
|
for (i = 0; i < in_count + 1; i++) {
|
||||||
uint8 *inPointer = &(pt_in[i * 6]);
|
uint8 *inPointer = &(pt_in[i * 6]);
|
||||||
if(!IS_SYN_PT_PACKAGE(inPointer)){
|
if (!IS_SYN_PT_PACKAGE(inPointer)) {
|
||||||
TRACE("SYNAPTICS: not a pass throught package\n");
|
TRACE("SYNAPTICS: not a pass throught package\n");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
if(i == 0){
|
if (i == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
in[i - 1] = pt_in[i * 6 + 1];
|
in[i - 1] = pt_in[i * 6 + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ps2_dev_command(dev->parent_dev, PS2_CMD_ENABLE, NULL, 0, NULL, 0);
|
status = ps2_dev_command(dev->parent_dev, PS2_CMD_ENABLE, NULL, 0, NULL, 0);
|
||||||
if(status != B_OK){
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
@ -157,36 +156,31 @@ edge_motion(mouse_movement *movement, touch_event *event, bool validStart)
|
||||||
int32 xdelta = 0;
|
int32 xdelta = 0;
|
||||||
int32 ydelta = 0;
|
int32 ydelta = 0;
|
||||||
|
|
||||||
if(event->xPosition < SYN_AREA_START_X + SYN_EDGE_MOTION_WIDTH){
|
if (event->xPosition < SYN_AREA_START_X + SYN_EDGE_MOTION_WIDTH)
|
||||||
xdelta = -SYN_EDGE_MOTION_SPEED;
|
xdelta = -SYN_EDGE_MOTION_SPEED;
|
||||||
}
|
else if (event->xPosition > SYN_AREA_END_X - SYN_EDGE_MOTION_WIDTH)
|
||||||
else if(event->xPosition > SYN_AREA_END_X - SYN_EDGE_MOTION_WIDTH){
|
|
||||||
xdelta = SYN_EDGE_MOTION_SPEED;
|
xdelta = SYN_EDGE_MOTION_SPEED;
|
||||||
}
|
|
||||||
|
|
||||||
if(event->yPosition < SYN_AREA_START_Y + SYN_EDGE_MOTION_WIDTH){
|
if (event->yPosition < SYN_AREA_START_Y + SYN_EDGE_MOTION_WIDTH)
|
||||||
ydelta = -SYN_EDGE_MOTION_SPEED;
|
ydelta = -SYN_EDGE_MOTION_SPEED;
|
||||||
}
|
else if (event->yPosition > SYN_AREA_END_Y - SYN_EDGE_MOTION_WIDTH)
|
||||||
else if(event->yPosition > SYN_AREA_END_Y - SYN_EDGE_MOTION_WIDTH){
|
|
||||||
ydelta = SYN_EDGE_MOTION_SPEED;
|
ydelta = SYN_EDGE_MOTION_SPEED;
|
||||||
}
|
|
||||||
|
|
||||||
if(xdelta && validStart){
|
if (xdelta && validStart)
|
||||||
movement->xdelta = xdelta;
|
movement->xdelta = xdelta;
|
||||||
}
|
if (ydelta && validStart)
|
||||||
if(ydelta && validStart){
|
|
||||||
movement->ydelta = ydelta;
|
movement->ydelta = ydelta;
|
||||||
}
|
|
||||||
|
|
||||||
if((xdelta || ydelta) && !validStart){
|
if ((xdelta || ydelta) && !validStart)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
touchevent_to_movement(synaptics_cookie* cookie, touch_event *event, mouse_movement *movement)
|
touchevent_to_movement(synaptics_cookie* cookie, touch_event *event,
|
||||||
|
mouse_movement *movement)
|
||||||
{
|
{
|
||||||
bool isSideScrollingV = false;
|
bool isSideScrollingV = false;
|
||||||
bool isSideScrollingH = false;
|
bool isSideScrollingH = false;
|
||||||
|
@ -196,9 +190,8 @@ touchevent_to_movement(synaptics_cookie* cookie, touch_event *event, mouse_movem
|
||||||
bigtime_t currentTime = system_time();
|
bigtime_t currentTime = system_time();
|
||||||
touchpad_settings * settings = &(cookie->settings);
|
touchpad_settings * settings = &(cookie->settings);
|
||||||
|
|
||||||
if(!movement){
|
if (!movement)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
movement->xdelta = 0;
|
movement->xdelta = 0;
|
||||||
movement->ydelta = 0;
|
movement->ydelta = 0;
|
||||||
|
@ -209,62 +202,57 @@ touchevent_to_movement(synaptics_cookie* cookie, touch_event *event, mouse_movem
|
||||||
movement->clicks = 0;
|
movement->clicks = 0;
|
||||||
movement->timestamp = currentTime;
|
movement->timestamp = currentTime;
|
||||||
|
|
||||||
if((currentTime - cookie->tap_time) > SYN_TAP_TIMEOUT){
|
if ((currentTime - cookie->tap_time) > SYN_TAP_TIMEOUT) {
|
||||||
TRACE("SYNAPTICS: tap gesture timed out\n");
|
TRACE("SYNAPTICS: tap gesture timed out\n");
|
||||||
cookie->tap_started = false;
|
cookie->tap_started = false;
|
||||||
if(!cookie->double_click || (currentTime - cookie->tap_time) > 2 * SYN_TAP_TIMEOUT)
|
if (!cookie->double_click
|
||||||
|
|| (currentTime - cookie->tap_time) > 2 * SYN_TAP_TIMEOUT) {
|
||||||
cookie->tap_clicks = 0;
|
cookie->tap_clicks = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event->buttons != 0){
|
if (event->buttons != 0) {
|
||||||
cookie->tap_clicks = 0;
|
cookie->tap_clicks = 0;
|
||||||
cookie->tapdrag_started = false;
|
cookie->tapdrag_started = false;
|
||||||
cookie->tap_started = false;
|
cookie->tap_started = false;
|
||||||
cookie->valid_edge_motion = false;
|
cookie->valid_edge_motion = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event->zPressure >= MIN_PRESSURE && event->zPressure < MAX_PRESSURE
|
if (event->zPressure >= MIN_PRESSURE && event->zPressure < MAX_PRESSURE
|
||||||
&& ((event->wValue >=4 && event->wValue <=7)
|
&& ((event->wValue >=4 && event->wValue <=7)
|
||||||
|| event->wValue == 0 || event->wValue == 1)
|
|| event->wValue == 0 || event->wValue == 1)
|
||||||
&& (event->xPosition != 0 || event->yPosition != 0))
|
&& (event->xPosition != 0 || event->yPosition != 0)) {
|
||||||
{
|
|
||||||
isInTouch = true;
|
isInTouch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isInTouch)
|
if (isInTouch) {
|
||||||
{
|
if ((SYN_AREA_END_X - SYN_AREA_WIDTH_X * settings->scroll_rightrange
|
||||||
if((SYN_AREA_END_X - SYN_AREA_WIDTH_X * settings->scroll_rightrange
|
|
||||||
< event->xPosition && !cookie->movement_started
|
< event->xPosition && !cookie->movement_started
|
||||||
&& settings->scroll_rightrange > 0.000001)
|
&& settings->scroll_rightrange > 0.000001)
|
||||||
|| settings->scroll_rightrange > 0.999999)
|
|| settings->scroll_rightrange > 0.999999) {
|
||||||
{
|
|
||||||
isSideScrollingV = true;
|
isSideScrollingV = true;
|
||||||
}
|
}
|
||||||
if((SYN_AREA_START_Y + SYN_AREA_WIDTH_Y * settings->scroll_bottomrange
|
if ((SYN_AREA_START_Y + SYN_AREA_WIDTH_Y * settings->scroll_bottomrange
|
||||||
> event->yPosition && !cookie->movement_started
|
> event->yPosition && !cookie->movement_started
|
||||||
&& settings->scroll_bottomrange > 0.000001)
|
&& settings->scroll_bottomrange > 0.000001)
|
||||||
|| settings->scroll_bottomrange > 0.999999)
|
|| settings->scroll_bottomrange > 0.999999) {
|
||||||
{
|
|
||||||
isSideScrollingH = true;
|
isSideScrollingH = true;
|
||||||
}
|
}
|
||||||
if(isSideScrollingV || isSideScrollingH
|
if (isSideScrollingV || isSideScrollingH
|
||||||
||(event->wValue == 0 && settings->scroll_twofinger)
|
||(event->wValue == 0 && settings->scroll_twofinger)
|
||||||
||(event->wValue == 1 && settings->scroll_multifinger))
|
||(event->wValue == 1 && settings->scroll_multifinger)) {
|
||||||
{
|
goto scrolling;
|
||||||
goto scrooling;
|
} else {
|
||||||
}
|
|
||||||
else{
|
|
||||||
cookie->scrolling_started = false;
|
cookie->scrolling_started = false;
|
||||||
}
|
}
|
||||||
goto movement;
|
goto movement;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
goto notouch;
|
goto notouch;
|
||||||
}
|
}
|
||||||
|
|
||||||
movement:
|
movement:
|
||||||
TRACE("SYNAPTICS: movement event\n");
|
TRACE("SYNAPTICS: movement event\n");
|
||||||
if(!cookie->movement_started){
|
if (!cookie->movement_started) {
|
||||||
isStartOfMovement = true;
|
isStartOfMovement = true;
|
||||||
cookie->movement_started = true;
|
cookie->movement_started = true;
|
||||||
start_new_movment(&(cookie->movement_maker));
|
start_new_movment(&(cookie->movement_maker));
|
||||||
|
@ -279,24 +267,25 @@ movement:
|
||||||
cookie->tap_delta_x+= cookie->movement_maker.xDelta;
|
cookie->tap_delta_x+= cookie->movement_maker.xDelta;
|
||||||
cookie->tap_delta_y+= cookie->movement_maker.yDelta;
|
cookie->tap_delta_y+= cookie->movement_maker.yDelta;
|
||||||
|
|
||||||
if(cookie->tapdrag_started){
|
if (cookie->tapdrag_started) {
|
||||||
movement->buttons = 0x01; // left button
|
movement->buttons = 0x01; // left button
|
||||||
movement->clicks = 0;
|
movement->clicks = 0;
|
||||||
|
|
||||||
cookie->valid_edge_motion = edge_motion(movement, event, cookie->valid_edge_motion);
|
cookie->valid_edge_motion = edge_motion(movement, event,
|
||||||
|
cookie->valid_edge_motion);
|
||||||
TRACE("SYNAPTICS: tap drag\n");
|
TRACE("SYNAPTICS: tap drag\n");
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
TRACE("SYNAPTICS: movement set buttons\n");
|
TRACE("SYNAPTICS: movement set buttons\n");
|
||||||
movement->buttons = event->buttons;
|
movement->buttons = event->buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use only a fraction of pressure range, the max pressure seems to be to high
|
// use only a fraction of pressure range, the max pressure seems to be
|
||||||
sens = 20 * (event->zPressure - MIN_PRESSURE) / (MAX_PRESSURE - MIN_PRESSURE - 100);
|
// to high
|
||||||
if(!cookie->tap_started
|
sens = 20 * (event->zPressure - MIN_PRESSURE)
|
||||||
|
/ (MAX_PRESSURE - MIN_PRESSURE - 100);
|
||||||
|
if (!cookie->tap_started
|
||||||
&& isStartOfMovement
|
&& isStartOfMovement
|
||||||
&& settings->tapgesture_sensibility > (20 - sens))
|
&& settings->tapgesture_sensibility > (20 - sens)) {
|
||||||
{
|
|
||||||
TRACE("SYNAPTICS: tap started\n");
|
TRACE("SYNAPTICS: tap started\n");
|
||||||
cookie->tap_started = true;
|
cookie->tap_started = true;
|
||||||
cookie->tap_time = system_time();
|
cookie->tap_time = system_time();
|
||||||
|
@ -306,26 +295,25 @@ movement:
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
scrooling:
|
scrolling:
|
||||||
TRACE("SYNAPTICS: scroll event\n");
|
TRACE("SYNAPTICS: scroll event\n");
|
||||||
cookie->tap_started = false;
|
cookie->tap_started = false;
|
||||||
cookie->tap_clicks = 0;
|
cookie->tap_clicks = 0;
|
||||||
cookie->tapdrag_started = false;
|
cookie->tapdrag_started = false;
|
||||||
cookie->valid_edge_motion = false;
|
cookie->valid_edge_motion = false;
|
||||||
if(!cookie->scrolling_started){
|
if (!cookie->scrolling_started) {
|
||||||
cookie->scrolling_started = true;
|
cookie->scrolling_started = true;
|
||||||
start_new_movment(&(cookie->movement_maker));
|
start_new_movment(&(cookie->movement_maker));
|
||||||
}
|
}
|
||||||
get_scrolling(&(cookie->movement_maker), event->xPosition, event->yPosition);
|
get_scrolling(&(cookie->movement_maker), event->xPosition,
|
||||||
|
event->yPosition);
|
||||||
movement->wheel_ydelta = cookie->movement_maker.yDelta;
|
movement->wheel_ydelta = cookie->movement_maker.yDelta;
|
||||||
movement->wheel_xdelta = cookie->movement_maker.xDelta;
|
movement->wheel_xdelta = cookie->movement_maker.xDelta;
|
||||||
|
|
||||||
if(isSideScrollingV && !isSideScrollingH){
|
if (isSideScrollingV && !isSideScrollingH)
|
||||||
movement->wheel_xdelta = 0;
|
movement->wheel_xdelta = 0;
|
||||||
}
|
else if (isSideScrollingH && !isSideScrollingV)
|
||||||
else if(isSideScrollingH && !isSideScrollingV){
|
|
||||||
movement->wheel_ydelta = 0;
|
movement->wheel_ydelta = 0;
|
||||||
}
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
notouch:
|
notouch:
|
||||||
|
@ -333,41 +321,38 @@ notouch:
|
||||||
cookie->scrolling_started = false;
|
cookie->scrolling_started = false;
|
||||||
cookie->movement_started = false;
|
cookie->movement_started = false;
|
||||||
movement->buttons = event->buttons;
|
movement->buttons = event->buttons;
|
||||||
if(event->buttons)
|
if (event->buttons)
|
||||||
movement->clicks = 1;
|
movement->clicks = 1;
|
||||||
|
|
||||||
if(cookie->tapdrag_started
|
if (cookie->tapdrag_started
|
||||||
&& (currentTime - cookie->tap_time) < SYN_TAP_TIMEOUT)
|
&& (currentTime - cookie->tap_time) < SYN_TAP_TIMEOUT) {
|
||||||
{
|
|
||||||
movement->buttons = 0x01;
|
movement->buttons = 0x01;
|
||||||
movement->clicks = 0;
|
movement->clicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the movement stopped switch off the dap trag when timeout is expired
|
// if the movement stopped switch off the dap trag when timeout is expired
|
||||||
if((currentTime - cookie->tap_time) > SYN_TAP_TIMEOUT){
|
if ((currentTime - cookie->tap_time) > SYN_TAP_TIMEOUT) {
|
||||||
cookie->tapdrag_started = false;
|
cookie->tapdrag_started = false;
|
||||||
cookie->valid_edge_motion = false;
|
cookie->valid_edge_motion = false;
|
||||||
TRACE("SYNAPTICS: tap drag gesture timed out\n");
|
TRACE("SYNAPTICS: tap drag gesture timed out\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(abs(cookie->tap_delta_x) > 15 || abs(cookie->tap_delta_y) > 15){
|
if (abs(cookie->tap_delta_x) > 15 || abs(cookie->tap_delta_y) > 15) {
|
||||||
cookie->tap_started = false;
|
cookie->tap_started = false;
|
||||||
cookie->tap_clicks = 0;
|
cookie->tap_clicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cookie->tap_started || cookie->double_click)
|
if (cookie->tap_started || cookie->double_click) {
|
||||||
{
|
|
||||||
TRACE("SYNAPTICS: tap gesture\n");
|
TRACE("SYNAPTICS: tap gesture\n");
|
||||||
cookie->tap_clicks++;
|
cookie->tap_clicks++;
|
||||||
|
|
||||||
if(cookie->tap_clicks > 1){
|
if (cookie->tap_clicks > 1) {
|
||||||
TRACE("SYNAPTICS: empty click\n");
|
TRACE("SYNAPTICS: empty click\n");
|
||||||
movement->buttons = 0x00;
|
movement->buttons = 0x00;
|
||||||
movement->clicks = 0;
|
movement->clicks = 0;
|
||||||
cookie->tap_clicks = 0;
|
cookie->tap_clicks = 0;
|
||||||
cookie->double_click = true;
|
cookie->double_click = true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
movement->buttons = 0x01;
|
movement->buttons = 0x01;
|
||||||
movement->clicks = 1;
|
movement->clicks = 1;
|
||||||
cookie->tap_started = false;
|
cookie->tap_started = false;
|
||||||
|
@ -399,7 +384,8 @@ get_synaptics_movment(synaptics_cookie* cookie, mouse_movement *movement)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet_buffer_read(cookie->synaptics_ring_buffer, event_buffer, cookie->dev->packet_size) != cookie->dev->packet_size) {
|
if (packet_buffer_read(cookie->synaptics_ring_buffer, event_buffer,
|
||||||
|
cookie->dev->packet_size) != cookie->dev->packet_size) {
|
||||||
TRACE("SYNAPTICS: error copying buffer\n");
|
TRACE("SYNAPTICS: error copying buffer\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +393,7 @@ get_synaptics_movment(synaptics_cookie* cookie, mouse_movement *movement)
|
||||||
event.buttons = event_buffer[0] & 3;
|
event.buttons = event_buffer[0] & 3;
|
||||||
event.zPressure = event_buffer[2];
|
event.zPressure = event_buffer[2];
|
||||||
|
|
||||||
if(g_touchpad_info.capExtended){
|
if (gTouchpadInfo.capExtended) {
|
||||||
wValue0 = event_buffer[3] >> 2 & 1;
|
wValue0 = event_buffer[3] >> 2 & 1;
|
||||||
wValue1 = event_buffer[0] >> 2 & 1;
|
wValue1 = event_buffer[0] >> 2 & 1;
|
||||||
wValue2 = event_buffer[0] >> 4 & 1;
|
wValue2 = event_buffer[0] >> 4 & 1;
|
||||||
|
@ -420,10 +406,9 @@ get_synaptics_movment(synaptics_cookie* cookie, mouse_movement *movement)
|
||||||
|
|
||||||
event.wValue = wValue;
|
event.wValue = wValue;
|
||||||
event.gesture = false;
|
event.gesture = false;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
bool finger = event_buffer[0] >> 5 & 1;
|
bool finger = event_buffer[0] >> 5 & 1;
|
||||||
if(finger){
|
if (finger) {
|
||||||
// finger with normal width
|
// finger with normal width
|
||||||
event.wValue = 4;
|
event.wValue = 4;
|
||||||
}
|
}
|
||||||
|
@ -456,18 +441,18 @@ query_capability(ps2_dev *dev)
|
||||||
send_touchpad_arg(dev, 0x02);
|
send_touchpad_arg(dev, 0x02);
|
||||||
ps2_dev_command(dev, 0xE9, NULL, 0, val, 3);
|
ps2_dev_command(dev, 0xE9, NULL, 0, val, 3);
|
||||||
|
|
||||||
g_touchpad_info.capExtended = val[0] >> 7 & 1;
|
gTouchpadInfo.capExtended = val[0] >> 7 & 1;
|
||||||
TRACE("SYNAPTICS: extended mode %2x\n", val[0] >> 7 & 1);
|
TRACE("SYNAPTICS: extended mode %2x\n", val[0] >> 7 & 1);
|
||||||
TRACE("SYNAPTICS: sleep mode %2x\n", val[2] >> 4 & 1);
|
TRACE("SYNAPTICS: sleep mode %2x\n", val[2] >> 4 & 1);
|
||||||
g_touchpad_info.capSleep = val[2] >> 4 & 1;
|
gTouchpadInfo.capSleep = val[2] >> 4 & 1;
|
||||||
TRACE("SYNAPTICS: four buttons %2x\n", val[2] >> 3 & 1);
|
TRACE("SYNAPTICS: four buttons %2x\n", val[2] >> 3 & 1);
|
||||||
g_touchpad_info.capFourButtons = val[2] >> 3 & 1;
|
gTouchpadInfo.capFourButtons = val[2] >> 3 & 1;
|
||||||
TRACE("SYNAPTICS: multi finger %2x\n", val[2] >> 1 & 1);
|
TRACE("SYNAPTICS: multi finger %2x\n", val[2] >> 1 & 1);
|
||||||
g_touchpad_info.capMultiFinger = val[2] >> 1 & 1;
|
gTouchpadInfo.capMultiFinger = val[2] >> 1 & 1;
|
||||||
TRACE("SYNAPTICS: palm detection %2x\n", val[2] & 1);
|
TRACE("SYNAPTICS: palm detection %2x\n", val[2] & 1);
|
||||||
g_touchpad_info.capPalmDetection = val[2] & 1;
|
gTouchpadInfo.capPalmDetection = val[2] & 1;
|
||||||
TRACE("SYNAPTICS: pass through %2x\n", val[2] >> 7 & 1);
|
TRACE("SYNAPTICS: pass through %2x\n", val[2] >> 7 & 1);
|
||||||
g_touchpad_info.capPassThrough = val[2] >> 7 & 1;
|
gTouchpadInfo.capPassThrough = val[2] >> 7 & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -481,18 +466,20 @@ probe_synaptics(ps2_dev *dev)
|
||||||
send_touchpad_arg(dev, 0x00);
|
send_touchpad_arg(dev, 0x00);
|
||||||
ps2_dev_command(dev, 0xE9, NULL, 0, val, 3);
|
ps2_dev_command(dev, 0xE9, NULL, 0, val, 3);
|
||||||
|
|
||||||
g_touchpad_info.minorVersion = val[0];
|
gTouchpadInfo.minorVersion = val[0];
|
||||||
deviceId = val[1];
|
deviceId = val[1];
|
||||||
if(deviceId != SYN_TOUCHPAD){
|
if (deviceId != SYN_TOUCHPAD) {
|
||||||
TRACE("SYNAPTICS: not found\n");
|
TRACE("SYNAPTICS: not found\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("SYNAPTICS: Touchpad found id:l %2x\n", deviceId);
|
TRACE("SYNAPTICS: Touchpad found id:l %2x\n", deviceId);
|
||||||
g_touchpad_info.majorVersion = val[2] & 0x0F;
|
gTouchpadInfo.majorVersion = val[2] & 0x0F;
|
||||||
TRACE("SYNAPTICS: version %d.%d\n", g_touchpad_info.majorVersion, g_touchpad_info.minorVersion);
|
TRACE("SYNAPTICS: version %d.%d\n", gTouchpadInfo.majorVersion,
|
||||||
|
gTouchpadInfo.minorVersion);
|
||||||
// version >= 4.0?
|
// version >= 4.0?
|
||||||
if(g_touchpad_info.minorVersion <= 2 && g_touchpad_info.majorVersion <= 3){
|
if (gTouchpadInfo.minorVersion <= 2
|
||||||
|
&& gTouchpadInfo.majorVersion <= 3) {
|
||||||
TRACE("SYNAPTICS: too old touchpad not supported\n");
|
TRACE("SYNAPTICS: too old touchpad not supported\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +528,8 @@ synaptics_open(const char *name, uint32 flags, void **_cookie)
|
||||||
cookie->movement_maker.speed = 1;
|
cookie->movement_maker.speed = 1;
|
||||||
cookie->movement_maker.scrolling_xStep = cookie->settings.scroll_xstepsize;
|
cookie->movement_maker.scrolling_xStep = cookie->settings.scroll_xstepsize;
|
||||||
cookie->movement_maker.scrolling_yStep = cookie->settings.scroll_ystepsize;
|
cookie->movement_maker.scrolling_yStep = cookie->settings.scroll_ystepsize;
|
||||||
cookie->movement_maker.scroll_acceleration = cookie->settings.scroll_acceleration;
|
cookie->movement_maker.scroll_acceleration
|
||||||
|
= cookie->settings.scroll_acceleration;
|
||||||
cookie->movement_started = false;
|
cookie->movement_started = false;
|
||||||
cookie->scrolling_started = false;
|
cookie->scrolling_started = false;
|
||||||
cookie->tap_started = false;
|
cookie->tap_started = false;
|
||||||
|
@ -550,7 +538,8 @@ synaptics_open(const char *name, uint32 flags, void **_cookie)
|
||||||
|
|
||||||
dev->packet_size = PS2_PACKET_SYNAPTICS;
|
dev->packet_size = PS2_PACKET_SYNAPTICS;
|
||||||
|
|
||||||
cookie->synaptics_ring_buffer = create_packet_buffer(synaptics_HISTORY_SIZE * dev->packet_size);
|
cookie->synaptics_ring_buffer
|
||||||
|
= create_packet_buffer(synaptics_HISTORY_SIZE * dev->packet_size);
|
||||||
if (cookie->synaptics_ring_buffer == NULL) {
|
if (cookie->synaptics_ring_buffer == NULL) {
|
||||||
TRACE("ps2: can't allocate mouse actions buffer\n");
|
TRACE("ps2: can't allocate mouse actions buffer\n");
|
||||||
goto err2;
|
goto err2;
|
||||||
|
@ -566,20 +555,19 @@ synaptics_open(const char *name, uint32 flags, void **_cookie)
|
||||||
query_capability(dev);
|
query_capability(dev);
|
||||||
|
|
||||||
// create pass through dev
|
// create pass through dev
|
||||||
if(g_touchpad_info.capPassThrough){
|
if (gTouchpadInfo.capPassThrough) {
|
||||||
TRACE("SYNAPTICS: pass through detected\n");
|
TRACE("SYNAPTICS: pass through detected\n");
|
||||||
g_passthrough_dev->parent_dev = dev;
|
gPassthroughDevice->parent_dev = dev;
|
||||||
g_passthrough_dev->idx = dev->idx;
|
gPassthroughDevice->idx = dev->idx;
|
||||||
ps2_service_notify_device_added(g_passthrough_dev);
|
ps2_service_notify_device_added(gPassthroughDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Mode
|
// Set Mode
|
||||||
if(g_touchpad_info.capExtended){
|
if (gTouchpadInfo.capExtended)
|
||||||
cookie->mode = SYN_ABSOLUTE_W_MODE;
|
cookie->mode = SYN_ABSOLUTE_W_MODE;
|
||||||
}
|
else
|
||||||
else{
|
|
||||||
cookie->mode = SYN_ABSOLUTE_MODE;
|
cookie->mode = SYN_ABSOLUTE_MODE;
|
||||||
}
|
|
||||||
status = set_touchpad_mode(dev, cookie->mode);
|
status = set_touchpad_mode(dev, cookie->mode);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
INFO("SYNAPTICS: cannot set mode %s\n", name);
|
INFO("SYNAPTICS: cannot set mode %s\n", name);
|
||||||
|
@ -606,7 +594,7 @@ err2:
|
||||||
err1:
|
err1:
|
||||||
atomic_and(&dev->flags, ~PS2_FLAG_OPEN);
|
atomic_and(&dev->flags, ~PS2_FLAG_OPEN);
|
||||||
|
|
||||||
TRACE("ps2: standart_mouse_open %s failed\n", name);
|
TRACE("SYNAPTICS: synaptics_open %s failed\n", name);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +604,8 @@ synaptics_close(void *_cookie)
|
||||||
{
|
{
|
||||||
synaptics_cookie *cookie = _cookie;
|
synaptics_cookie *cookie = _cookie;
|
||||||
|
|
||||||
ps2_dev_command_timeout(cookie->dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0, 150000);
|
ps2_dev_command_timeout(cookie->dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0,
|
||||||
|
150000);
|
||||||
|
|
||||||
delete_packet_buffer(cookie->synaptics_ring_buffer);
|
delete_packet_buffer(cookie->synaptics_ring_buffer);
|
||||||
delete_sem(cookie->synaptics_sem);
|
delete_sem(cookie->synaptics_sem);
|
||||||
|
@ -624,9 +613,8 @@ synaptics_close(void *_cookie)
|
||||||
atomic_and(&cookie->dev->flags, ~PS2_FLAG_OPEN);
|
atomic_and(&cookie->dev->flags, ~PS2_FLAG_OPEN);
|
||||||
atomic_and(&cookie->dev->flags, ~PS2_FLAG_ENABLED);
|
atomic_and(&cookie->dev->flags, ~PS2_FLAG_ENABLED);
|
||||||
|
|
||||||
if(g_touchpad_info.capPassThrough){
|
if (gTouchpadInfo.capPassThrough)
|
||||||
ps2_service_notify_device_removed(g_passthrough_dev);
|
ps2_service_notify_device_removed(gPassthroughDevice);
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("SYNAPTICS: close %s done\n", cookie->dev->name);
|
TRACE("SYNAPTICS: close %s done\n", cookie->dev->name);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
@ -667,7 +655,7 @@ synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case MS_READ:
|
case MS_READ:
|
||||||
TRACE("SYNAPTICS: MS_READ get event\n");
|
TRACE("SYNAPTICS: MS_READ get event\n");
|
||||||
if((status = get_synaptics_movment(cookie, &movement)) != B_OK)
|
if ((status = get_synaptics_movment(cookie, &movement)) != B_OK)
|
||||||
return status;
|
return status;
|
||||||
return user_memcpy(buffer, &movement, sizeof(movement));
|
return user_memcpy(buffer, &movement, sizeof(movement));
|
||||||
case MS_IS_TOUCHPAD:
|
case MS_IS_TOUCHPAD:
|
||||||
|
@ -676,9 +664,12 @@ synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length)
|
||||||
case MS_SET_TOUCHPAD_SETTINGS:
|
case MS_SET_TOUCHPAD_SETTINGS:
|
||||||
TRACE("SYNAPTICS: MS_SET_TOUCHPAD_SETTINGS");
|
TRACE("SYNAPTICS: MS_SET_TOUCHPAD_SETTINGS");
|
||||||
user_memcpy(&(cookie->settings), buffer, sizeof(touchpad_settings));
|
user_memcpy(&(cookie->settings), buffer, sizeof(touchpad_settings));
|
||||||
cookie->movement_maker.scrolling_xStep = cookie->settings.scroll_xstepsize;
|
cookie->movement_maker.scrolling_xStep
|
||||||
cookie->movement_maker.scrolling_yStep = cookie->settings.scroll_ystepsize;
|
= cookie->settings.scroll_xstepsize;
|
||||||
cookie->movement_maker.scroll_acceleration = cookie->settings.scroll_acceleration;
|
cookie->movement_maker.scrolling_yStep
|
||||||
|
= cookie->settings.scroll_ystepsize;
|
||||||
|
cookie->movement_maker.scroll_acceleration
|
||||||
|
= cookie->settings.scroll_acceleration;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
default:
|
default:
|
||||||
TRACE("SYNAPTICS: unknown opcode: %ld\n", op);
|
TRACE("SYNAPTICS: unknown opcode: %ld\n", op);
|
||||||
|
@ -700,11 +691,11 @@ synaptics_handle_int(ps2_dev *dev)
|
||||||
cookie->packet_index = 0;
|
cookie->packet_index = 0;
|
||||||
goto unhandled;
|
goto unhandled;
|
||||||
}
|
}
|
||||||
if(cookie->packet_index == 0 && val >> 6 != 0x02){
|
if (cookie->packet_index == 0 && val >> 6 != 0x02) {
|
||||||
TRACE("SYNAPTICS: first package begins not with bit 1, 0\n");
|
TRACE("SYNAPTICS: first package begins not with bit 1, 0\n");
|
||||||
goto unhandled;
|
goto unhandled;
|
||||||
}
|
}
|
||||||
if(cookie->packet_index == 3 && val >> 6 != 0x03){
|
if (cookie->packet_index == 3 && val >> 6 != 0x03) {
|
||||||
TRACE("SYNAPTICS: third package begins not with bit 1, 1\n");
|
TRACE("SYNAPTICS: third package begins not with bit 1, 1\n");
|
||||||
cookie->packet_index = 0;
|
cookie->packet_index = 0;
|
||||||
goto unhandled;
|
goto unhandled;
|
||||||
|
@ -712,32 +703,33 @@ synaptics_handle_int(ps2_dev *dev)
|
||||||
cookie->packet_buffer[cookie->packet_index] = val;
|
cookie->packet_buffer[cookie->packet_index] = val;
|
||||||
|
|
||||||
cookie->packet_index++;
|
cookie->packet_index++;
|
||||||
if(cookie->packet_index >= 6){
|
if (cookie->packet_index >= 6) {
|
||||||
cookie->packet_index = 0;
|
cookie->packet_index = 0;
|
||||||
|
|
||||||
// check if package is a pass through package if true pass it
|
// check if package is a pass through package if true pass it
|
||||||
// too the pass through interrupt handle
|
// too the pass through interrupt handle
|
||||||
if(g_passthrough_dev->active
|
if (gPassthroughDevice->active
|
||||||
&& g_passthrough_dev->handle_int != NULL
|
&& gPassthroughDevice->handle_int != NULL
|
||||||
&& IS_SYN_PT_PACKAGE(cookie->packet_buffer))
|
&& IS_SYN_PT_PACKAGE(cookie->packet_buffer)) {
|
||||||
{
|
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
g_passthrough_dev->history[0].data = cookie->packet_buffer[1];
|
gPassthroughDevice->history[0].data = cookie->packet_buffer[1];
|
||||||
g_passthrough_dev->handle_int(g_passthrough_dev);
|
gPassthroughDevice->handle_int(gPassthroughDevice);
|
||||||
g_passthrough_dev->history[0].data = cookie->packet_buffer[4];
|
gPassthroughDevice->history[0].data = cookie->packet_buffer[4];
|
||||||
g_passthrough_dev->handle_int(g_passthrough_dev);
|
gPassthroughDevice->handle_int(gPassthroughDevice);
|
||||||
g_passthrough_dev->history[0].data = cookie->packet_buffer[5];
|
gPassthroughDevice->history[0].data = cookie->packet_buffer[5];
|
||||||
status = g_passthrough_dev->handle_int(g_passthrough_dev);
|
status = gPassthroughDevice->handle_int(gPassthroughDevice);
|
||||||
|
|
||||||
if(cookie->dev->packet_size == 4){
|
if (cookie->dev->packet_size == 4) {
|
||||||
g_passthrough_dev->history[0].data = cookie->packet_buffer[2];
|
gPassthroughDevice->history[0].data = cookie->packet_buffer[2];
|
||||||
status = g_passthrough_dev->handle_int(g_passthrough_dev);
|
status = gPassthroughDevice->handle_int(gPassthroughDevice);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet_buffer_write(cookie->synaptics_ring_buffer, cookie->packet_buffer, cookie->dev->packet_size) != cookie->dev->packet_size) {
|
if (packet_buffer_write(cookie->synaptics_ring_buffer,
|
||||||
|
cookie->packet_buffer, cookie->dev->packet_size)
|
||||||
|
!= cookie->dev->packet_size) {
|
||||||
// buffer is full, drop new data
|
// buffer is full, drop new data
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +749,7 @@ synaptics_disconnect(ps2_dev *dev)
|
||||||
{
|
{
|
||||||
synaptics_cookie *cookie = dev->cookie;
|
synaptics_cookie *cookie = dev->cookie;
|
||||||
// the mouse device might not be opened at this point
|
// the mouse device might not be opened at this point
|
||||||
INFO("ps2: ps2_standart_mouse_disconnect %s\n", dev->name);
|
INFO("SYNAPTICS: synaptics_disconnect %s\n", dev->name);
|
||||||
if (dev->flags & PS2_FLAG_OPEN)
|
if (dev->flags & PS2_FLAG_OPEN)
|
||||||
release_sem(cookie->synaptics_sem);
|
release_sem(cookie->synaptics_sem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,23 @@
|
||||||
#include "kb_mouse_driver.h"
|
#include "kb_mouse_driver.h"
|
||||||
#include "ps2_trackpoint.h"
|
#include "ps2_trackpoint.h"
|
||||||
|
|
||||||
const char* kTrackpointPath[4] = {"input/mouse/ps2/ibm_trackpoint_0",
|
const char* kTrackpointPath[4] = {
|
||||||
"input/mouse/ps2/ibm_trackpoint_1",
|
"input/mouse/ps2/ibm_trackpoint_0",
|
||||||
"input/mouse/ps2/ibm_trackpoint_2",
|
"input/mouse/ps2/ibm_trackpoint_1",
|
||||||
"input/mouse/ps2/ibm_trackpoint_3"};
|
"input/mouse/ps2/ibm_trackpoint_2",
|
||||||
|
"input/mouse/ps2/ibm_trackpoint_3"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
probe_trackpoint(ps2_dev *dev)
|
probe_trackpoint(ps2_dev* dev)
|
||||||
{
|
{
|
||||||
uint8 val[2];
|
uint8 val[2];
|
||||||
|
|
||||||
TRACE("TRACKPOINT: probe\n");
|
TRACE("TRACKPOINT: probe\n");
|
||||||
ps2_dev_command(dev, 0xE1, NULL, 0, val, 2);
|
ps2_dev_command(dev, 0xE1, NULL, 0, val, 2);
|
||||||
|
|
||||||
if(val[0] != 0x01){
|
if (val[0] != 0x01) {
|
||||||
TRACE("TRACKPOINT: not found\n");
|
TRACE("TRACKPOINT: not found\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef SYNAPTICS_H
|
#ifndef TRACKPOINT_H
|
||||||
#define SYNAPTICS_H
|
#define TRACKPOINT_H
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
|
||||||
|
@ -9,4 +9,4 @@
|
||||||
status_t probe_trackpoint(ps2_dev *dev);
|
status_t probe_trackpoint(ps2_dev *dev);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif /* TRACKPOINT_H */
|
||||||
|
|
Loading…
Reference in New Issue