BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / ps2 / movement_maker.h
blob2c762b5574d0813e7707966288876ab9d6d7d1d3
1 #ifndef MOVEMENT_MAKER_H
2 #define MOVEMENT_MAKER_H
4 #include <OS.h>
6 #include <keyboard_mouse_driver.h>
7 #include <touchpad_settings.h>
10 float floorf(float x);
11 float ceilf(float x);
12 float sqrtf(float x);
13 int32 make_small(float value);
16 struct touch_event {
17 uint8 buttons;
18 uint32 xPosition;
19 uint32 yPosition;
20 uint8 zPressure;
21 // absolut mode (unused)
22 bool finger;
23 bool gesture;
24 // absolut w mode
25 uint8 wValue;
29 struct hardware_specs {
30 uint16 edgeMotionWidth;
32 uint16 areaStartX;
33 uint16 areaEndX;
34 uint16 areaStartY;
35 uint16 areaEndY;
37 uint16 minPressure;
38 // the value you reach when you hammer really hard on the touchpad
39 uint16 realMaxPressure;
40 uint16 maxPressure;
44 /*! The raw movement calculation is calibrated on ths synaptics touchpad. */
45 // increase the touchpad size a little bit
46 #define SYN_AREA_TOP_LEFT_OFFSET 40
47 #define SYN_AREA_BOTTOM_RIGHT_OFFSET 60
48 #define SYN_AREA_START_X (1472 - SYN_AREA_TOP_LEFT_OFFSET)
49 #define SYN_AREA_END_X (5472 + SYN_AREA_BOTTOM_RIGHT_OFFSET)
50 #define SYN_WIDTH (SYN_AREA_END_X - SYN_AREA_START_X)
51 #define SYN_AREA_START_Y (1408 - SYN_AREA_TOP_LEFT_OFFSET)
52 #define SYN_AREA_END_Y (4448 + SYN_AREA_BOTTOM_RIGHT_OFFSET)
53 #define SYN_HEIGHT (SYN_AREA_END_Y - SYN_AREA_START_Y)
56 class MovementMaker {
57 public:
58 void SetSettings(touchpad_settings* settings);
59 void SetSpecs(hardware_specs* specs);
61 int32 xDelta;
62 int32 yDelta;
64 float scrolling_x;
65 float scrolling_y;
67 protected:
68 void StartNewMovment();
69 void GetMovement(uint32 posX, uint32 posY);
70 void GetScrolling(uint32 posX, uint32 posY);
72 touchpad_settings* fSettings;
73 hardware_specs* fSpecs;
75 int8 fSpeed;
76 int16 fAreaWidth;
77 int16 fAreaHeight;
79 private:
80 void _GetRawMovement(uint32 posX, uint32 posY);
81 void _ComputeAcceleration(int8 accel_factor);
84 bool fMovementMakerStarted;
86 uint32 fPreviousX;
87 uint32 fPreviousY;
88 int32 fDeltaSumX;
89 int32 fDeltaSumY;
91 int8 fSmallMovement;
95 enum button_ids
97 kNoButton = 0x00,
98 kLeftButton = 0x01,
99 kRightButton = 0x02,
100 kMiddleButton = 0x04
104 class TouchpadMovement : public MovementMaker {
105 public:
106 void Init();
108 status_t EventToMovement(touch_event *event,
109 mouse_movement *movement);
111 bool TapDragStarted() { return fTapdragStarted; }
112 bool WasEdgeMotion() { return fValidEdgeMotion; }
114 void UpdateButtons(mouse_movement *movement);
116 bigtime_t click_speed;
117 private:
118 bool _EdgeMotion(mouse_movement *movement,
119 touch_event *event, bool validStart);
120 inline void _NoTouchToMovement(touch_event *event,
121 mouse_movement *movement);
122 inline void _MoveToMovement(touch_event *event,
123 mouse_movement *movement);
124 inline bool _CheckScrollingToMovement(touch_event *event,
125 mouse_movement *movement);
127 bool fMovementStarted;
128 bool fScrollingStarted;
129 bool fTapStarted;
130 bigtime_t fTapTime;
131 int32 fTapDeltaX;
132 int32 fTapDeltaY;
133 int32 fTapClicks;
134 bool fTapdragStarted;
136 bool fValidEdgeMotion;
137 bigtime_t fLastEdgeMotion;
138 float fRestEdgeMotion;
140 bool fDoubleClick;
142 bigtime_t fClickLastTime;
143 int32 fClickCount;
144 uint32 fButtonsState;
148 #endif