1 /* 2 * Copyright 2008-2009, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors (in chronological order): 6 * Clemens Zeidler (haiku@Clemens-Zeidler.de) 7 */ 8 #ifndef PS2_SYNAPTICS_H 9 #define PS2_SYNAPTICS_H 10 11 12 #include <KernelExport.h> 13 14 #include "kb_mouse_driver.h" 15 #include "movement_maker.h" 16 #include "packet_buffer.h" 17 #include "ps2_service.h" 18 #include "touchpad_settings.h" 19 20 21 #define SYN_TOUCHPAD 0x47 22 // Synaptics modes 23 #define SYN_ABSOLUTE_MODE 0x80 24 // Absolute plus w mode 25 #define SYN_ABSOLUTE_W_MODE 0x81 26 #define SYN_FOUR_BYTE_CHILD (1 << 1) 27 // Low power sleep mode 28 #define SYN_SLEEP_MODE 0x0C 29 // Synaptics Passthrough port 30 #define SYN_CHANGE_MODE 0x14 31 #define SYN_PASSTHROUGH_CMD 0x28 32 33 34 // synaptics touchpad proportions 35 #define SYN_EDGE_MOTION_WIDTH 50 36 #define SYN_EDGE_MOTION_SPEED 5 37 #define SYN_AREA_OFFSET 40 38 // increase the touchpad size a little bit 39 #define SYN_AREA_TOP_LEFT_OFFSET 40 40 #define SYN_AREA_BOTTOM_RIGHT_OFFSET 60 41 #define SYN_AREA_START_X (1472 - SYN_AREA_TOP_LEFT_OFFSET) 42 #define SYN_AREA_END_X (5472 + SYN_AREA_BOTTOM_RIGHT_OFFSET) 43 #define SYN_AREA_WIDTH_X (SYN_AREA_END_X - SYN_AREA_START_X) 44 #define SYN_AREA_START_Y (1408 - SYN_AREA_TOP_LEFT_OFFSET) 45 #define SYN_AREA_END_Y (4448 + SYN_AREA_BOTTOM_RIGHT_OFFSET) 46 #define SYN_AREA_WIDTH_Y (SYN_AREA_END_Y - SYN_AREA_START_Y) 47 48 #define SYN_TAP_TIMEOUT 200000 49 50 #define MIN_PRESSURE 30 51 #define MAX_PRESSURE 200 52 53 #define SYNAPTICS_HISTORY_SIZE 256 54 55 // no touchpad / left / right button pressed 56 #define IS_SYN_PT_PACKAGE(val) ((val[0] & 0xFC) == 0x84 \ 57 && (val[3] & 0xCC) == 0xc4) 58 59 60 typedef struct { 61 uint8 majorVersion; 62 uint8 minorVersion; 63 64 bool capExtended; 65 bool capSleep; 66 bool capFourButtons; 67 bool capMultiFinger; 68 bool capPalmDetection; 69 bool capPassThrough; 70 } touchpad_info; 71 72 73 typedef struct { 74 uint8 buttons; 75 uint32 xPosition; 76 uint32 yPosition; 77 uint8 zPressure; 78 // absolut mode 79 bool finger; 80 bool gesture; 81 // absolut w mode 82 uint8 wValue; 83 } touch_event; 84 85 86 typedef struct { 87 ps2_dev* dev; 88 89 sem_id synaptics_sem; 90 packet_buffer* synaptics_ring_buffer; 91 size_t packet_index; 92 uint8 packet_buffer[PS2_PACKET_SYNAPTICS]; 93 uint8 mode; 94 95 movement_maker movement_maker; 96 bool movement_started; 97 bool scrolling_started; 98 bool tap_started; 99 bigtime_t tap_time; 100 int32 tap_delta_x; 101 int32 tap_delta_y; 102 int32 tap_clicks; 103 bool tapdrag_started; 104 bool valid_edge_motion; 105 bool double_click; 106 107 bigtime_t click_last_time; 108 bigtime_t click_speed; 109 int32 click_count; 110 uint32 buttons_state; 111 112 touchpad_settings settings; 113 } synaptics_cookie; 114 115 116 117 status_t synaptics_pass_through_set_packet_size(ps2_dev *dev, uint8 size); 118 status_t passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out, 119 int out_count, uint8 *in, int in_count, bigtime_t timeout); 120 status_t probe_synaptics(ps2_dev *dev); 121 122 status_t synaptics_open(const char *name, uint32 flags, void **_cookie); 123 status_t synaptics_close(void *_cookie); 124 status_t synaptics_freecookie(void *_cookie); 125 status_t synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length); 126 127 int32 synaptics_handle_int(ps2_dev *dev); 128 void synaptics_disconnect(ps2_dev *dev); 129 130 device_hooks gSynapticsDeviceHooks; 131 132 #endif // PS2_SYNAPTICS_H 133