Now uses the mouse_pos struct and commands definitions from kb_mouse_drivers.h.
Added cbuf_adapter.h so that the ps2 mouse driver can be compiled also against BeOS R5's kernel (for testing). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9028 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
SubDir OBOS_TOP src add-ons kernel drivers arch x86 ps2mouse ;
|
SubDir OBOS_TOP src add-ons kernel drivers arch x86 ps2mouse ;
|
||||||
|
|
||||||
|
UsePrivateHeaders input ;
|
||||||
|
|
||||||
KernelObjects
|
KernelObjects
|
||||||
ps2mouse.c
|
ps2mouse.c
|
||||||
:
|
:
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef __CBUF_ADAPTER_H
|
||||||
|
#define __CBUF_ADAPTER_H
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
struct cbuffer_t;
|
||||||
|
typedef struct cbuffer_t cbuffer;
|
||||||
|
|
||||||
|
size_t cbuf_getn_no_lock(cbuffer *, char *, size_t);
|
||||||
|
size_t cbuf_putn_no_lock(cbuffer *, char *, size_t);
|
||||||
|
cbuffer *cbuf_init(size_t size);
|
||||||
|
void cbuf_delete(cbuffer *buffer);
|
||||||
|
char cbuf_get(cbuffer *);
|
||||||
|
bool cbuf_mt(cbuffer *);
|
||||||
|
bool cbuf_full(cbuffer *);
|
||||||
|
status_t cbuf_put(cbuffer *, char);
|
||||||
|
status_t cbuf_unput(cbuffer *);
|
||||||
|
void cbuf_flush(cbuffer *);
|
||||||
|
size_t cbuf_size(cbuffer *);
|
||||||
|
size_t cbuf_avail(cbuffer *);
|
||||||
|
size_t cbuf_free(cbuffer *);
|
||||||
|
size_t cbuf_putn(cbuffer *, char *, size_t num_bytes);
|
||||||
|
size_t cbuf_getn(cbuffer *, char *, size_t num_bytes);
|
||||||
|
cpu_status cbuf_lock(cbuffer *);
|
||||||
|
void cbuf_unlock(cbuffer *, cpu_status);
|
||||||
|
|
||||||
|
#define cbuf cbuffer
|
||||||
|
#define cbuf_get_chain(size) cbuf_init(size)
|
||||||
|
#define cbuf_free_chain(chain) cbuf_delete(chain)
|
||||||
|
#define cbuf_memcpy_from_chain(dest, chain, offset, size) \
|
||||||
|
(cbuf_getn(chain, dest, size) - size)
|
||||||
|
#define cbuf_memcpy_to_chain(chain, offset, source, size) \
|
||||||
|
(cbuf_putn(chain, source, size) - size)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -55,6 +55,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <kb_mouse_driver.h>
|
||||||
|
|
||||||
#include "ps2mouse.h"
|
#include "ps2mouse.h"
|
||||||
|
|
||||||
#define DEVICE_NAME "input/mouse/ps2/0"
|
#define DEVICE_NAME "input/mouse/ps2/0"
|
||||||
@@ -67,7 +69,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef COMPILE_FOR_R5
|
#ifdef COMPILE_FOR_R5
|
||||||
#include "cbuf_adapter.h"
|
#include "cbuf_adapter.h"
|
||||||
#else
|
#else
|
||||||
#include <cbuf.h>
|
#include <cbuf.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -79,10 +81,11 @@ static isa_module_info *sIsa = NULL;
|
|||||||
static sem_id sMouseSem;
|
static sem_id sMouseSem;
|
||||||
static int32 sSync;
|
static int32 sSync;
|
||||||
static cbuf *sMouseChain;
|
static cbuf *sMouseChain;
|
||||||
|
|
||||||
static bigtime_t sLastClickTime;
|
static bigtime_t sLastClickTime;
|
||||||
static bigtime_t sClickSpeed;
|
static bigtime_t sClickSpeed;
|
||||||
static uint32 sClickCount;
|
static int32 sClickCount;
|
||||||
static uint32 sButtonsState;
|
static int sButtonsState;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// ps2 protocol stuff
|
// ps2 protocol stuff
|
||||||
@@ -247,11 +250,11 @@ ps2_enable_mouse(bool enable)
|
|||||||
/** Converts a packet received by the mouse to a "movement".
|
/** Converts a packet received by the mouse to a "movement".
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
packet_to_movement(uint8 packet[], mouse_movement *movement)
|
packet_to_movement(uint8 packet[], mouse_pos *pos)
|
||||||
{
|
{
|
||||||
uint32 buttons = packet[0] & 7;
|
int buttons = packet[0] & 7;
|
||||||
int32 xDelta = ((packet[0] & 0x10) ? 0xFFFFFF00 : 0) | packet[1];
|
int xDelta = ((packet[0] & 0x10) ? 0xFFFFFF00 : 0) | packet[1];
|
||||||
int32 yDelta = ((packet[0] & 0x20) ? 0xFFFFFF00 : 0) | packet[2];
|
int yDelta = ((packet[0] & 0x20) ? 0xFFFFFF00 : 0) | packet[2];
|
||||||
bigtime_t currentTime = system_time();
|
bigtime_t currentTime = system_time();
|
||||||
|
|
||||||
if (buttons != 0) {
|
if (buttons != 0) {
|
||||||
@@ -266,13 +269,13 @@ packet_to_movement(uint8 packet[], mouse_movement *movement)
|
|||||||
sLastClickTime = currentTime;
|
sLastClickTime = currentTime;
|
||||||
sButtonsState = buttons;
|
sButtonsState = buttons;
|
||||||
|
|
||||||
if (movement) {
|
if (pos) {
|
||||||
movement->xdelta = xDelta;
|
pos->xdelta = xDelta;
|
||||||
movement->ydelta = yDelta;
|
pos->ydelta = yDelta;
|
||||||
movement->buttons = buttons;
|
pos->buttons = buttons;
|
||||||
movement->click_count = sClickCount;
|
pos->clicks = sClickCount;
|
||||||
movement->mouse_mods = 0;
|
pos->modifiers = 0;
|
||||||
movement->mouse_time = currentTime;
|
pos->time = currentTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +283,7 @@ packet_to_movement(uint8 packet[], mouse_movement *movement)
|
|||||||
/** 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
|
||||||
ps2_mouse_read(mouse_movement *movement)
|
ps2_mouse_read(mouse_pos *pos)
|
||||||
{
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
uint8 packet[PS2_PACKET_SIZE];
|
uint8 packet[PS2_PACKET_SIZE];
|
||||||
@@ -296,7 +299,7 @@ ps2_mouse_read(mouse_movement *movement)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_to_movement(packet, movement);
|
packet_to_movement(packet, pos);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -393,14 +396,6 @@ mouse_freecookie(void * cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Gets a mouse data packet.
|
|
||||||
* Parameters:
|
|
||||||
* cookie, ignored
|
|
||||||
* buf, pointer to a buffer that accepts the data
|
|
||||||
* pos, ignored
|
|
||||||
* len, buffer size, must be at least the size of the data packet
|
|
||||||
*/
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
|
mouse_read(void *cookie, off_t pos, void *buf, size_t *len)
|
||||||
{
|
{
|
||||||
@@ -420,18 +415,18 @@ mouse_write(void * cookie, off_t pos, const void *buf, size_t *len)
|
|||||||
static status_t
|
static status_t
|
||||||
mouse_ioctl(void *cookie, uint32 op, void *buf, size_t len)
|
mouse_ioctl(void *cookie, uint32 op, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
mouse_movement *movement = (mouse_movement *)buf;
|
mouse_pos *pos = (mouse_pos *)buf;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case MOUSE_GET_EVENTS_COUNT:
|
case MS_NUM_EVENTS:
|
||||||
{
|
{
|
||||||
int32 count;
|
int32 count;
|
||||||
TRACE(("PS2_GET_EVENT_COUNT\n"));
|
TRACE(("PS2_GET_EVENT_COUNT\n"));
|
||||||
get_sem_count(sMouseSem, &count);
|
get_sem_count(sMouseSem, &count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
case MOUSE_GET_MOVEMENTS:
|
case MS_READ:
|
||||||
TRACE(("PS2_GET_MOUSE_MOVEMENTS\n"));
|
TRACE(("PS2_GET_MOUSE_MOVEMENTS\n"));
|
||||||
return ps2_mouse_read(movement);
|
return ps2_mouse_read(pos);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
TRACE(("unknown opcode: %ld\n", op));
|
TRACE(("unknown opcode: %ld\n", op));
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
#define _KERNEL_ARCH_x86_PS2MOUSE_H
|
#define _KERNEL_ARCH_x86_PS2MOUSE_H
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// definitions
|
// definitions
|
||||||
@@ -88,35 +87,4 @@
|
|||||||
#define MOUSE_HISTORY_SIZE 256
|
#define MOUSE_HISTORY_SIZE 256
|
||||||
|
|
||||||
|
|
||||||
// TODO: Move these to another file, which will be
|
|
||||||
// included by every mouse driver, and also by the mouse
|
|
||||||
// input server addon. At least, that's the idea.
|
|
||||||
|
|
||||||
// ioctls
|
|
||||||
enum {
|
|
||||||
MOUSE_GET_MOVEMENTS = 0x2773,
|
|
||||||
MOUSE_GET_EVENTS_COUNT = 0x2774,
|
|
||||||
MOUSE_GET_ACCELERATION = 0x2775,
|
|
||||||
MOUSE_SET_ACCELERATION = 0x2776,
|
|
||||||
MOUSE_SET_TYPE = 0x2778,
|
|
||||||
MOUSE_SET_MAP = 0x277A,
|
|
||||||
MOUSE_SET_CLICK_SPEED = 0x277C
|
|
||||||
} ioctls;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* mouse_movements:
|
|
||||||
* Passed as parameter of the MOUSE_GET_MOVEMENTS ioctl() call.
|
|
||||||
* (compatible with the R5 mouse addon/driver)
|
|
||||||
*/
|
|
||||||
typedef struct mouse_movement mouse_movement;
|
|
||||||
struct mouse_movement {
|
|
||||||
int32 ser_fd_index;
|
|
||||||
int32 buttons;
|
|
||||||
int32 xdelta;
|
|
||||||
int32 ydelta;
|
|
||||||
int32 click_count;
|
|
||||||
int32 mouse_mods;
|
|
||||||
int64 mouse_time;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _KERNEL_ARCH_x86_PS2MOUSE_H */
|
#endif /* _KERNEL_ARCH_x86_PS2MOUSE_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user