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 // increase the touchpad size a little bit 38 #define SYN_AREA_START_X (1472 - SYN_AREA_OFFSET) 39 #define SYN_AREA_END_X (5472 + SYN_AREA_OFFSET) 40 #define SYN_AREA_WIDTH_X (SYN_AREA_END_X - SYN_AREA_START_X) 41 #define SYN_AREA_START_Y (1408 - SYN_AREA_OFFSET) 42 #define SYN_AREA_END_Y (4448 + SYN_AREA_OFFSET) 43 #define SYN_AREA_WIDTH_Y (SYN_AREA_END_Y - SYN_AREA_START_Y) 44 45 #define SYN_TAP_TIMEOUT 200000 46 47 #define MIN_PRESSURE 30 48 #define MAX_PRESSURE 200 49 50 #define SYNAPTICS_HISTORY_SIZE 256 51 52 // no touchpad / left / right button pressed 53 #define IS_SYN_PT_PACKAGE(val) ((val[0] & 0xFC) == 0x84 \ 54 && (val[3] & 0xCC) == 0xc4) 55 56 57 typedef struct { 58 uint8 majorVersion; 59 uint8 minorVersion; 60 61 bool capExtended; 62 bool capSleep; 63 bool capFourButtons; 64 bool capMultiFinger; 65 bool capPalmDetection; 66 bool capPassThrough; 67 } touchpad_info; 68 69 70 typedef struct { 71 uint8 buttons; 72 uint32 xPosition; 73 uint32 yPosition; 74 uint8 zPressure; 75 // absolut mode 76 bool finger; 77 bool gesture; 78 // absolut w mode 79 uint8 wValue; 80 } touch_event; 81 82 83 typedef struct { 84 ps2_dev* dev; 85 86 sem_id synaptics_sem; 87 packet_buffer* synaptics_ring_buffer; 88 size_t packet_index; 89 uint8 packet_buffer[PS2_PACKET_SYNAPTICS]; 90 uint8 mode; 91 92 movement_maker movement_maker; 93 bool movement_started; 94 bool scrolling_started; 95 bool tap_started; 96 bigtime_t tap_time; 97 int32 tap_delta_x; 98 int32 tap_delta_y; 99 int32 tap_clicks; 100 bool tapdrag_started; 101 bool valid_edge_motion; 102 bool double_click; 103 104 bigtime_t click_last_time; 105 bigtime_t click_speed; 106 int32 click_count; 107 uint32 buttons_state; 108 109 touchpad_settings settings; 110 } synaptics_cookie; 111 112 113 114 status_t synaptics_pass_through_set_packet_size(ps2_dev *dev, uint8 size); 115 status_t passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out, 116 int out_count, uint8 *in, int in_count, bigtime_t timeout); 117 status_t probe_synaptics(ps2_dev *dev); 118 119 status_t synaptics_open(const char *name, uint32 flags, void **_cookie); 120 status_t synaptics_close(void *_cookie); 121 status_t synaptics_freecookie(void *_cookie); 122 status_t synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length); 123 124 int32 synaptics_handle_int(ps2_dev *dev); 125 void synaptics_disconnect(ps2_dev *dev); 126 127 device_hooks gSynapticsDeviceHooks; 128 129 #endif // PS2_SYNAPTICS_H 130