Automatic white space cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28459 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-11-02 11:30:41 +00:00
parent b5c3e3f430
commit 03973d27eb
14 changed files with 92 additions and 89 deletions

View File

@ -20,8 +20,8 @@ extern "C" {
typedef struct {
bus_manager_info binfo;
int32 (*function1)();
int32 (*function2)();
int32 (*function1)();
int32 (*function2)();
} ps2_module_info;

View File

@ -100,17 +100,17 @@ float
sqrtf(float x)
{
float z;
int32 sign = (int)0x80000000;
int32 sign = (int)0x80000000;
int32 ix,s,q,m,t,i;
uint32 r;
GET_FLOAT_WORD(ix,x);
/* take care of Inf and NaN */
if ((ix&0x7f800000)==0x7f800000) {
if ((ix&0x7f800000)==0x7f800000) {
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
sqrt(-inf)=sNaN */
}
}
/* take care of zero */
if (ix<=0) {
if ((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */
@ -135,12 +135,12 @@ sqrtf(float x)
r = 0x01000000; /* r = moving bit from right to left */
while(r!=0) {
t = s+r;
if (t<=ix) {
s = t+r;
ix -= t;
q += r;
}
t = s+r;
if (t<=ix) {
s = t+r;
ix -= t;
q += r;
}
ix += ix;
r>>=1;
}
@ -163,7 +163,7 @@ sqrtf(float x)
}
int32
int32
make_small(float value)
{
if (value > 0)
@ -173,17 +173,17 @@ make_small(float value)
}
void
void
get_raw_movement(movement_maker *move, uint32 posX, uint32 posY)
{
int16 i;
float meanXOld = 0, meanYOld = 0;
float meanX = 0, meanY = 0;
// calculate mean
for (i = 0; i < move->n_points; i++) {
meanXOld+= move->historyX[i];
meanYOld+= move->historyY[i];
meanXOld += move->historyX[i];
meanYOld += move->historyY[i];
}
if (move->n_points == 0) {
meanXOld = posX;
@ -192,10 +192,10 @@ get_raw_movement(movement_maker *move, uint32 posX, uint32 posY)
meanXOld = meanXOld / move->n_points;
meanYOld = meanYOld / move->n_points;
}
meanX = (meanXOld + posX) / 2;
meanY = (meanYOld + posY) / 2;
// fill history
for (i = 0; i < HISTORY_SIZE - 1; i++) {
move->historyX[i] = move->historyX[i + 1];
@ -203,14 +203,14 @@ get_raw_movement(movement_maker *move, uint32 posX, uint32 posY)
}
move->historyX[HISTORY_SIZE - 1] = meanX;
move->historyY[HISTORY_SIZE - 1] = meanY;
if (move->n_points < HISTORY_SIZE) {
move->n_points++;
move->xDelta = 0;
move->yDelta = 0;
return;
}
move->xDelta = make_small((meanX - meanXOld) / 16);
move->yDelta = make_small((meanY - meanYOld) / 16);
}
@ -221,9 +221,9 @@ compute_acceleration(movement_maker *move, int8 accel_factor)
{
// acceleration
float acceleration = 1;
if (accel_factor) {
acceleration = 1 + sqrtf(move->xDelta * move->xDelta + move->yDelta * move->yDelta)
* accel_factor / 50.0;
if (accel_factor != 0) {
acceleration = 1 + sqrtf(move->xDelta * move->xDelta
+ move->yDelta * move->yDelta) * accel_factor / 50.0;
}
move->xDelta = make_small(move->xDelta * acceleration);
@ -231,7 +231,7 @@ compute_acceleration(movement_maker *move, int8 accel_factor)
}
void
void
get_movement(movement_maker *move, uint32 posX, uint32 posY)
{
get_raw_movement(move, posX, posY);
@ -244,21 +244,21 @@ void
get_scrolling(movement_maker *move, uint32 posX, uint32 posY)
{
int32 stepsX = 0, stepsY = 0;
get_raw_movement(move, posX, posY);
compute_acceleration(move, move->scroll_acceleration);
move->scrolling_x+= move->xDelta;
move->scrolling_y+= move->yDelta;
stepsX = make_small(move->scrolling_x / move->scrolling_xStep);
stepsY = make_small(move->scrolling_y / move->scrolling_yStep);
move->scrolling_x-= stepsX * move->scrolling_xStep;
move->scrolling_y-= stepsY * move->scrolling_yStep;
move->xDelta = stepsX;
move->yDelta = -1 * stepsY;
move->yDelta = -1 * stepsY;
}
@ -269,7 +269,7 @@ start_new_movment(movement_maker *move)
move->scrolling_xStep = 1;
if (move->scrolling_yStep <= 0)
move->scrolling_yStep = 1;
move->n_points = 0;
move->scrolling_x = 0;
move->scrolling_y = 0;

View File

@ -11,20 +11,19 @@ float ceilf(float x);
float sqrtf(float x);
int32 make_small(float value);
typedef struct
{
typedef struct {
int32 xDelta;
int32 yDelta;
int8 acceleration;
int8 speed;
float scrolling_x;
float scrolling_y;
int32 scrolling_xStep;
int32 scrolling_yStep;
int32 scroll_acceleration;
uint8 n_points;
float historyX[HISTORY_SIZE];
float historyY[HISTORY_SIZE];

View File

@ -31,7 +31,8 @@ struct packet_buffer {
struct packet_buffer *
create_packet_buffer(size_t size)
{
struct packet_buffer *buffer = (packet_buffer *)malloc(sizeof(packet_buffer));
struct packet_buffer *buffer
= (packet_buffer *)malloc(sizeof(packet_buffer));
if (buffer == NULL)
return NULL;
@ -126,7 +127,8 @@ packet_buffer_read(struct packet_buffer *buffer, uint8 *data, size_t length)
size_t
packet_buffer_write(struct packet_buffer *buffer, const uint8 *data, size_t length)
packet_buffer_write(struct packet_buffer *buffer, const uint8 *data,
size_t length)
{
cpu_status state = disable_interrupts();
acquire_spinlock(&buffer->lock);

View File

@ -23,8 +23,10 @@ void packet_buffer_clear(struct packet_buffer *buffer);
size_t packet_buffer_readable(struct packet_buffer *buffer);
size_t packet_buffer_writable(struct packet_buffer *buffer);
void packet_buffer_flush(struct packet_buffer *buffer, size_t bytes);
size_t packet_buffer_read(struct packet_buffer *buffer, uint8 *data, size_t length);
size_t packet_buffer_write(struct packet_buffer *buffer, const uint8 *data, size_t length);
size_t packet_buffer_read(struct packet_buffer *buffer, uint8 *data, size_t
length);
size_t packet_buffer_write(struct packet_buffer *buffer, const uint8 *data,
size_t length);
#ifdef __cplusplus
}

View File

@ -321,7 +321,7 @@ status_t
ps2_init(void)
{
status_t status;
TRACE("ps2: init\n");
status = get_module(B_ISA_MODULE_NAME, (module_info **)&gIsa);
@ -383,7 +383,7 @@ ps2_init(void)
ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_MOUSE]);
ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_KEYB]);
}
TRACE("ps2: init done!\n");
return B_OK;

View File

@ -102,7 +102,7 @@ ps2_dev_detect_pointing(ps2_dev *dev, device_hooks **hooks)
// probe devices
// the probe function has to set the dev name and the dev packet size
#if 0
#if 1
status = probe_trackpoint(dev);
if (status == B_OK) {
*hooks = &gStandardMouseDeviceHooks;

View File

@ -35,7 +35,7 @@ struct ps2_dev {
data_history history[2];
ps2_dev * parent_dev;
size_t packet_size;
// functions
void (*disconnect)(ps2_dev *);
int32 (*handle_int)(ps2_dev *);

View File

@ -60,7 +60,7 @@ static status_t
set_typematic(int32 rate, bigtime_t delay)
{
uint8 value;
TRACE("ps2: set_typematic rate %ld, delay %Ld\n", rate, delay);
// input server and keyboard preferences *seem* to use a range of 20-300
@ -68,22 +68,22 @@ set_typematic(int32 rate, bigtime_t delay)
rate = 20;
if (rate > 300)
rate = 300;
// map this into range 0-31
rate = ((rate - 20) * 31) / (300 - 20);
// keyboard uses 0 == fast, 31 == slow
value = 31 - rate;
if (delay >= 875000)
value |= 3 << 5;
else if (delay >= 625000)
value |= 2 << 5;
else if (delay >= 375000)
value |= 1 << 5;
else
else
value |= 0 << 5;
return ps2_dev_command(&ps2_device[PS2_DEVICE_KEYB], PS2_CMD_KEYBOARD_SET_TYPEMATIC, &value, 1, NULL, 0);
}
@ -103,13 +103,13 @@ keyboard_handle_int(ps2_dev *dev)
sIsExtended = true;
// TRACE("Extended key\n");
return B_HANDLED_INTERRUPT;
}
}
// TRACE("scancode: %x\n", scancode);
if (scancode & 0x80) {
keyInfo.is_keydown = false;
scancode &= 0x7f;
scancode &= 0x7f;
} else
keyInfo.is_keydown = true;
@ -143,7 +143,7 @@ read_keyboard_packet(at_kbd_io *packet)
status = acquire_sem_etc(sKeyboardSem, 1, B_CAN_INTERRUPT, 0);
if (status < B_OK)
return status;
if (!ps2_device[PS2_DEVICE_KEYB].active) {
TRACE("ps2: read_keyboard_packet, Error device no longer active\n");
return B_ERROR;
@ -219,7 +219,7 @@ keyboard_open(const char *name, uint32 flags, void **_cookie)
if (atomic_or(&sKeyboardOpenMask, 1) != 0)
return B_BUSY;
status = probe_keyboard();
if (status != B_OK) {
INFO("ps2: keyboard probing failed\n");
@ -269,7 +269,7 @@ keyboard_close(void *cookie)
delete_sem(sKeyboardSem);
atomic_and(&ps2_device[PS2_DEVICE_KEYB].flags, ~PS2_FLAG_ENABLED);
atomic_and(&sKeyboardOpenMask, 0);
TRACE("ps2: keyboard_close done\n");
@ -338,7 +338,7 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
// 0xF8 (Set All Keys Make/Break) - Keyboard responds with "ack" (0xFA).
return ps2_dev_command(&ps2_device[PS2_DEVICE_KEYB], 0xf8, NULL, 0, NULL, 0);
}
case KB_SET_KEY_REPEAT_RATE:
{
int32 key_repeat_rate;
@ -350,7 +350,7 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
sKeyboardRepeatRate = key_repeat_rate;
return B_OK;
}
case KB_GET_KEY_REPEAT_RATE:
{
TRACE("ps2: ioctl KB_GET_KEY_REPEAT_RATE\n");
@ -367,7 +367,7 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
return B_ERROR;
sKeyboardRepeatDelay = key_repeat_delay;
return B_OK;
}
case KB_GET_KEY_REPEAT_DELAY:

View File

@ -34,31 +34,31 @@ std_ops(int32 op, ...)
case B_MODULE_INIT:
return ps2_init();
case B_MODULE_UNINIT:
case B_MODULE_UNINIT:
ps2_uninit();
break;
default:
break;
default:
return B_ERROR;
}
return B_OK;
return B_OK;
}
static ps2_module_info ps2_module = {
.binfo = {
.minfo = {
.minfo = {
.name = B_PS2_MODULE_NAME,
.flags = B_KEEP_LOADED,
.std_ops = std_ops,
},
.rescan = NULL,
},
&function1,
&function2,
&function1,
&function2,
};
module_info *modules[] = {
(module_info *)&ps2_module,
module_info *modules[] = {
(module_info *)&ps2_module,
NULL
};

View File

@ -42,10 +42,10 @@ ps2_service_notify_device_added(ps2_dev *dev)
ps2_service_cmd cmd;
TRACE("ps2: ps2_service_notify_device_added %s\n", dev->name);
cmd.id = PS2_SERVICE_NOTIFY_DEVICE_ADDED;
cmd.dev = dev;
packet_buffer_write(sServiceCmdBuffer, (const uint8 *)&cmd, sizeof(cmd));
release_sem_etc(sServiceSem, 1, B_DO_NOT_RESCHEDULE);
@ -59,10 +59,10 @@ ps2_service_notify_device_republish(ps2_dev *dev)
ps2_service_cmd cmd;
TRACE("ps2: ps2_service_notify_device_republish %s\n", dev->name);
cmd.id = PS2_SERVICE_NOTIFY_DEVICE_REPUBLISH;
cmd.dev = dev;
packet_buffer_write(sServiceCmdBuffer, (const uint8 *)&cmd, sizeof(cmd));
release_sem_etc(sServiceSem, 1, B_DO_NOT_RESCHEDULE);
@ -79,7 +79,7 @@ ps2_service_notify_device_removed(ps2_dev *dev)
cmd.id = PS2_SERVICE_NOTIFY_DEVICE_REMOVED;
cmd.dev = dev;
packet_buffer_write(sServiceCmdBuffer, (const uint8 *)&cmd, sizeof(cmd));
release_sem_etc(sServiceSem, 1, B_DO_NOT_RESCHEDULE);
@ -115,7 +115,7 @@ ps2_service_thread(void *arg)
snooze(2500000);
ps2_dev_publish(cmd.dev);
break;
case PS2_SERVICE_NOTIFY_DEVICE_REMOVED:
TRACE("ps2: PS2_SERVICE_NOTIFY_DEVICE_REMOVED %s\n", cmd.dev->name);
ps2_dev_unpublish(cmd.dev);
@ -139,7 +139,7 @@ static int
ps2_republish(int argc, char **argv)
{
int dev = 4;
if (argc == 2)
if (argc == 2)
dev = strtoul(argv[1], NULL, 0);
if (dev < 0 || dev > 4)
dev = 4;
@ -171,7 +171,7 @@ ps2_service_init(void)
TRACE("ps2: ps2_service_init done\n");
return B_OK;
err3:
delete_sem(sServiceSem);
err2:

View File

@ -28,7 +28,7 @@
typedef struct
{
ps2_dev * dev;
sem_id standard_mouse_sem;
packet_buffer * standard_mouse_buffer;
bigtime_t click_last_time;
@ -49,11 +49,11 @@ status_t standard_mouse_close(void *_cookie);
status_t standard_mouse_freecookie(void *_cookie);
status_t standard_mouse_ioctl(void *_cookie, uint32 op, void *buffer,
size_t length);
int32 standard_mouse_handle_int(ps2_dev *dev);
void standard_mouse_disconnect(ps2_dev *dev);
device_hooks gStandardMouseDeviceHooks;
device_hooks gStandardMouseDeviceHooks;
#endif /* __PS2_STANDARD_MOUSE_H */

View File

@ -11,7 +11,7 @@
#define SYN_TOUCHPAD 0x47
// Synaptics modes
#define SYN_ABSOLUTE_MODE 0x80
#define SYN_ABSOLUTE_MODE 0x80
// Absolute plus w mode
#define SYN_ABSOLUTE_W_MODE 0x81
#define SYN_FOUR_BYTE_CHILD (1 << 1)
@ -25,7 +25,7 @@
// synaptics touchpad proportions
#define SYN_EDGE_MOTION_WIDTH 50
#define SYN_EDGE_MOTION_SPEED 5
#define SYN_AREA_OFFSET 40 // increase the touchpad size a little bit
#define SYN_AREA_OFFSET 40 // increase the touchpad size a little bit
#define SYN_AREA_START_X (1472 - SYN_AREA_OFFSET)
#define SYN_AREA_END_X (5472 + SYN_AREA_OFFSET)
#define SYN_AREA_WIDTH_X (SYN_AREA_END_X - SYN_AREA_START_X)
@ -48,14 +48,14 @@
typedef struct {
uint8 majorVersion;
uint8 minorVersion;
bool capExtended;
bool capSleep;
bool capFourButtons;
bool capMultiFinger;
bool capPalmDetection;
bool capPassThrough;
} touchpad_info;
@ -68,20 +68,20 @@ typedef struct {
bool finger;
bool gesture;
// absolut w mode
uint8 wValue;
uint8 wValue;
} touch_event;
typedef struct
{
ps2_dev * dev;
sem_id synaptics_sem;
packet_buffer * synaptics_ring_buffer;
size_t packet_index;
uint8 packet_buffer[PS2_PACKET_SYNAPTICS];
uint8 mode;
movement_maker movement_maker;
bool movement_started;
bool scrolling_started;
@ -93,7 +93,7 @@ typedef struct
bool tapdrag_started;
bool valid_edge_motion;
bool double_click;
touchpad_settings settings;
} synaptics_cookie;
@ -119,7 +119,7 @@ status_t synaptics_open(const char *name, uint32 flags, void **_cookie);
status_t synaptics_close(void *_cookie);
status_t synaptics_freecookie(void *_cookie);
status_t synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length);
int32 synaptics_handle_int(ps2_dev *dev);
void synaptics_disconnect(ps2_dev *dev);

View File

@ -19,14 +19,14 @@ probe_trackpoint(ps2_dev* dev)
TRACE("TRACKPOINT: probe\n");
ps2_dev_command(dev, 0xE1, NULL, 0, val, 2);
if (val[0] != 0x01) {
TRACE("TRACKPOINT: not found\n");
return B_ERROR;
}
dev->name = kTrackpointPath[dev->idx];
dev->packet_size = 3;
TRACE("TRACKPOINT: version 0x%x found\n", val[1]);
TRACE("TRACKPOINT: version 0x%x found\n", val[1]);
return B_OK;
}