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