├── CHANGELOG ├── .gitignore ├── usr └── src │ └── hid-magictrackpad2-4.10+hid-magictrackpad2 │ ├── dkms.conf │ ├── Makefile │ └── hid-magictrackpad2.c ├── scripts ├── pre-uninstall.sh └── post-install.sh ├── Makefile ├── README.md └── LICENSE /CHANGELOG: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.o.cmd 3 | *.mod.c 4 | *.ko 5 | *.ko.cmd 6 | Module.symvers 7 | modules.order 8 | 9 | .tmp_versions 10 | 11 | build 12 | -------------------------------------------------------------------------------- /usr/src/hid-magictrackpad2-4.10+hid-magictrackpad2/dkms.conf: -------------------------------------------------------------------------------- 1 | MAKE="make KERNEL_VERSION=${kernelver} all" 2 | CLEAN="make KERNEL_VERSION=${kernelver} clean" 3 | BUILT_MODULE_NAME[0]=hid-magictrackpad2 4 | DEST_MODULE_LOCATION[0]='/kernel/drivers/input/mouse' 5 | PACKAGE_NAME=hid-magictrackpad2 6 | PACKAGE_VERSION=4.10 7 | REMAKE_INITRD=yes 8 | AUTOINSTALL=yes 9 | -------------------------------------------------------------------------------- /usr/src/hid-magictrackpad2-4.10+hid-magictrackpad2/Makefile: -------------------------------------------------------------------------------- 1 | KERNEL_VERSION := $(shell uname -r) 2 | KERNEL_MODULES := /lib/modules/$(KERNEL_VERSION)/build 3 | 4 | hid-y := hid-magictrackpad2.o 5 | 6 | obj-m += hid-magictrackpad2.o 7 | 8 | all: 9 | $(MAKE) -C $(KERNEL_MODULES) M=$(PWD) modules 10 | 11 | clean: 12 | $(MAKE) -C $(KERNEL_MODULES) M=$(PWD) clean 13 | -------------------------------------------------------------------------------- /scripts/pre-uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | dkms_name="hid-magictrackpad2" 6 | dkms_version="4.10+hid-magictrackpad2" 7 | 8 | case "$1" in 9 | remove|upgrade|deconfigure) 10 | if dkms status -m $dkms_name -v $dkms_version | egrep '(added|built|installed)' >/dev/null ; then 11 | # if dkms bindings exist, remove them 12 | dkms remove $dkms_name/$dkms_version --all 13 | fi 14 | ;; 15 | 16 | *) 17 | echo "prerm called with unknown argument: $1" 18 | exit 1 19 | ;; 20 | esac 21 | 22 | #DEBHELPER# 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | PKG_NAME=hid-magictrackpad2-dkms 4 | PKG_VERSION=1.0.0 5 | PKG_DESCRIPTION="Magic Trackpad 2 Support via HID Layer" 6 | 7 | MAINTAINER="claudio " 8 | HOMEPAGE="https://github.com/ponyfleisch/hid-magictrackpad2-dkms" 9 | 10 | all: 11 | test -d build || mkdir build 12 | fpm -f -s dir -t deb -n $(PKG_NAME) -v $(PKG_VERSION) -a all -p build/ \ 13 | -d dkms -d build-essential -d linux-headers-generic \ 14 | -m $(MAINTAINER) --vendor ponyfleisch --license GPLv2 --description $(PKG_DESCRIPTION) \ 15 | --url $(HOMEPAGE) --deb-changelog CHANGELOG \ 16 | --post-install scripts/post-install.sh --pre-uninstall scripts/pre-uninstall.sh \ 17 | --exclude '.git*' usr/ 18 | 19 | clean: 20 | rm -f build/$(PKG_NAME)_$(PKG_VERSION)_all.deb 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | magictrackpad2-dkms 2 | =================== 3 | 4 | DKMS module for apple magic trackpad2 clobbered together from various sources. 5 | 6 | Very very alpha. 7 | 8 | Does force touch (does not trigger an event at the moment though - coming soon) and supports bluetooth only at the moment. 9 | 10 | This is based *heavily* on work by @robbi5 and @robotrovsky. Proper attribution will be added soon. My apologies. 11 | 12 | Thanks: 13 | ------- 14 | 15 | * https://github.com/robbi5/magictrackpad2-dkms 16 | * https://github.com/robotrovsky/linux/commit/7b50169c3a8948e67a67eb530b91117a7f5d9d5b 17 | * https://github.com/naftulikay/bcm5974-3.19 18 | * https://bbs.archlinux.org/viewtopic.php?id=66397 19 | * https://github.com/SicVolo/hid-apple-4.0.x 20 | * https://github.com/SicVolo/hid-apple-3.19 21 | -------------------------------------------------------------------------------- /scripts/post-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | dkms_name="hid-magictrackpad2" 6 | dkms_version="4.10+hid-magictrackpad2" 7 | 8 | case "$1" in 9 | configure) 10 | # add 11 | if ! dkms status -m $dkms_name -v $dkms_version | egrep '(added|built|installed)' >/dev/null ; then 12 | # if it's not been added yet, add it 13 | dkms add -m $dkms_name -v $dkms_version 14 | fi 15 | 16 | # build 17 | if ! dkms status -m $dkms_name -v $dkms_version | egrep '(built|installed)' >/dev/null ; then 18 | # if it's not been built yet, build it 19 | dkms build $dkms_name/$dkms_version 20 | fi 21 | 22 | # install 23 | if ! dkms status -m $dkms_name -v $dkms_version | egrep '(installed)' >/dev/null; then 24 | # if it's not been installed yet, install it 25 | dkms install --force $dkms_name/$dkms_version 26 | fi 27 | ;; 28 | 29 | *) 30 | echo "postinst called with unknown argument: $1" 31 | exit 1 32 | ;; 33 | esac 34 | 35 | #DEBHELPER# 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /usr/src/hid-magictrackpad2-4.10+hid-magictrackpad2/hid-magictrackpad2.c: -------------------------------------------------------------------------------- 1 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define BT_VENDOR_ID_APPLE 0x004c 11 | #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 0x0265 12 | 13 | static const struct hid_device_id magic_trackpads[] = { 14 | {HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, 15 | USB_DEVICE_ID_APPLE_MAGICTRACKPAD2), .driver_data = 0}, 16 | 17 | // USB is broken right now. 18 | 19 | // { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 20 | // USB_DEVICE_ID_APPLE_MAGICTRACKPAD2), .driver_data = 0 }, 21 | {} 22 | }; 23 | 24 | // host controlled haptic feedback for the click/force clicks. 25 | // reverse engineered. values at index 4, 7 and 15 change the click behaviour 26 | static __u8 button_down[] = {0xF2, 0x53, 0x01, 0x17, 0x78, 0x02, 0x06, 0x24, 0x30, 0x06, 0x01, 0x06, 0x18, 0x48, 0x12}; 27 | static __u8 button_force[] = {0xF2, 0x53, 0x01, 0x1c, 0x78, 0x02, 0x0A, 0x24, 0x30, 0x06, 0x01, 0x0d, 0x18, 0x48, 0x12}; 28 | static __u8 button_up[] = {0xF2, 0x53, 0x01, 0x14, 0x78, 0x02, 0x00, 0x24, 0x30, 0x06, 0x01, 0x00, 0x18, 0x48, 0x12}; 29 | 30 | MODULE_DEVICE_TABLE(hid, magic_trackpads 31 | ); 32 | 33 | #define MAX_FINGERS 16 34 | #define MAX_FINGER_ORIENTATION 16384 35 | 36 | #define PRESSURE_CLICK_THRESHOLD 50 37 | #define PRESSURE_FORCE_THRESHOLD 140 38 | 39 | /* list of device capability bits */ 40 | #define HAS_INTEGRATED_BUTTON 1 41 | 42 | /* logical signal quality */ 43 | #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */ 44 | #define SN_WIDTH 25 /* width signal-to-noise ratio */ 45 | #define SN_COORD 250 /* coordinate signal-to-noise ratio */ 46 | #define SN_ORIENT 10 /* orientation signal-to-noise ratio */ 47 | 48 | struct bcm5974_param { 49 | int snratio; /* signal-to-noise ratio */ 50 | int min; /* device minimum reading */ 51 | int max; /* device maximum reading */ 52 | }; 53 | struct bt_data { 54 | u8 unknown1; /* constant */ 55 | u8 button; /* left button */ 56 | u8 rel_x; /* relative x coordinate */ 57 | u8 rel_y; /* relative y coordinate */ 58 | }; 59 | 60 | struct tp_finger { 61 | u8 abs_x; /* absolute x coodinate */ 62 | u8 abs_x_y; /* absolute x,y coodinate */ 63 | u8 abs_y[2]; /* absolute y coodinate */ 64 | u8 touch_major; /* touch area, major axis */ 65 | u8 touch_minor; /* touch area, minor axis */ 66 | u8 size; /* tool area, size */ 67 | u8 pressure; /* pressure on forcetouch touchpad */ 68 | u8 orientation_origin; /* orientation and id */ 69 | } __attribute__((packed, aligned(2))); 70 | 71 | struct bcm5974_config { 72 | int ansi, iso, jis; /* the product id of this device */ 73 | int caps; /* device capability bitmask */ 74 | int bt_ep; /* the endpoint of the button interface */ 75 | int bt_datalen; /* data length of the button interface */ 76 | struct bcm5974_param p; /* finger pressure limits */ 77 | struct bcm5974_param w; /* finger width limits */ 78 | struct bcm5974_param x; /* horizontal limits */ 79 | struct bcm5974_param y; /* vertical limits */ 80 | struct bcm5974_param o; /* orientation limits */ 81 | }; 82 | 83 | struct bcm5974 { 84 | struct input_dev *input; /* input dev */ 85 | struct bcm5974_config cfg; /* device configuration */ 86 | struct mutex pm_mutex; /* serialize access to open/suspend */ 87 | int opened; /* 1: opened, 0: closed */ 88 | struct urb *bt_urb; /* button usb request block */ 89 | struct bt_data *bt_data; /* button transferred data */ 90 | struct urb *tp_urb; /* trackpad usb request block */ 91 | u8 *tp_data; /* trackpad transferred data */ 92 | const struct tp_finger *index[MAX_FINGERS]; /* finger index data */ 93 | struct input_mt_pos pos[MAX_FINGERS]; /* position array */ 94 | int slots[MAX_FINGERS]; /* slot assignments */ 95 | }; 96 | 97 | static const struct bcm5974_config trackpad_config = { 98 | USB_DEVICE_ID_APPLE_MAGICTRACKPAD2, 99 | USB_DEVICE_ID_APPLE_MAGICTRACKPAD2, 100 | USB_DEVICE_ID_APPLE_MAGICTRACKPAD2, 101 | HAS_INTEGRATED_BUTTON, 102 | 0, sizeof(struct bt_data), 103 | {SN_PRESSURE, 0, 300}, 104 | {SN_WIDTH, 0, 2048}, 105 | {SN_COORD, -3678, 3934}, 106 | {SN_COORD, -2479, 2586}, 107 | {SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION} 108 | }; 109 | 110 | static int probe(struct hid_device *hdev, const struct hid_device_id *id) { 111 | struct bcm5974 *device; 112 | int ret; 113 | 114 | device = devm_kzalloc(&hdev->dev, sizeof(*device), GFP_KERNEL); 115 | 116 | if (device == NULL) { 117 | hid_err(hdev, "can't alloc trackpad descriptor\n"); 118 | return -ENOMEM; 119 | } 120 | 121 | hid_set_drvdata(hdev, device); 122 | ret = hid_parse(hdev); 123 | if (ret) { 124 | hid_err(hdev, "trackpad hid parse failed\n"); 125 | return ret; 126 | } 127 | 128 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 129 | if (ret) { 130 | hid_err(hdev, "trackpad hw start failed\n"); 131 | return ret; 132 | } 133 | 134 | if (!device->input) { 135 | hid_err(hdev, "trackpad input not registered\n"); 136 | ret = -ENOMEM; 137 | goto err_stop_hw; 138 | } 139 | 140 | hid_register_report(hdev, HID_INPUT_REPORT, 0x31); 141 | 142 | return 0; 143 | 144 | err_stop_hw: 145 | hid_hw_stop(hdev); 146 | return ret; 147 | } 148 | 149 | static inline void bup(struct hid_device *hdev) { 150 | hid_hw_output_report(hdev, button_up, sizeof(button_up)); 151 | } 152 | 153 | static inline void bdown(struct hid_device *hdev) { 154 | hid_hw_output_report(hdev, button_down, sizeof(button_down)); 155 | } 156 | 157 | static inline void bforce(struct hid_device *hdev) { 158 | hid_hw_output_report(hdev, button_force, sizeof(button_force)); 159 | } 160 | 161 | 162 | /* convert 16-bit little endian to signed integer */ 163 | static inline int raw2int(__le16 x) { 164 | return (signed short) le16_to_cpu(x); 165 | } 166 | 167 | 168 | static int raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { 169 | static char status = 0; 170 | __u8 pressure = 0; 171 | __u8 id = 0; 172 | int active_ids[MAX_FINGERS + 1] = {0}; 173 | int current_slot = -1; 174 | int i = 0, j = 0; 175 | s16 tmp_x; 176 | s32 tmp_y; 177 | struct bcm5974 *device = hid_get_drvdata(hdev); 178 | 179 | const struct tp_finger *finger; 180 | 181 | // message with only a timestamp means all fingers have been lifted 182 | if (size <= 4) { 183 | for (i = 0; i < MAX_FINGERS; i++) { 184 | if (device->slots[i] != 0) { 185 | input_mt_slot(device->input, i); 186 | input_report_abs(device->input, ABS_MT_TRACKING_ID, -1); 187 | device->slots[i] = 0; 188 | input_mt_sync_frame(device->input); 189 | } 190 | } 191 | input_sync(device->input); 192 | return 0; 193 | } else { 194 | for (i = 0; i < (size - 4) / 9; i++) { 195 | finger = (const struct tp_finger *) (data + 4 + (i * 9)); 196 | id = finger->orientation_origin & 0x0F; 197 | active_ids[id] = 1; 198 | 199 | current_slot = -1; 200 | 201 | // do we already track this finger? 202 | for (j = 0; j < MAX_FINGERS; j++) { 203 | if (device->slots[j] == id) { 204 | current_slot = j; 205 | input_mt_slot(device->input, current_slot); 206 | break; 207 | } 208 | } 209 | 210 | // new finger? 211 | if (current_slot == -1) { 212 | for (j = 0; j < MAX_FINGERS; j++) { 213 | if (device->slots[j] == 0) { 214 | device->slots[j] = id; 215 | current_slot = j; 216 | input_mt_slot(device->input, current_slot); 217 | input_report_abs(device->input, ABS_MT_TRACKING_ID, id); 218 | break; 219 | } 220 | } 221 | } 222 | 223 | tmp_x = (s16)((le16_to_cpu(*((__le16 *) finger)) & 0x1fff) << 3) >> 3; 224 | tmp_y = -(s32)(((s32) le32_to_cpu(*((__le32 *) finger))) << 6) >> 19; 225 | 226 | // for the first finger, we also report non-multitrack data 227 | if (i == 0) { 228 | input_report_abs(device->input, ABS_X, tmp_x); 229 | input_report_abs(device->input, ABS_Y, tmp_y); 230 | 231 | // i'm not sure if that is a synaptics issue, but there is no movement 232 | // if the pressure is below ~30 233 | input_report_abs(device->input, ABS_PRESSURE, finger->pressure + 30); 234 | 235 | // no idea if this is correct 236 | input_report_abs(device->input, ABS_TOOL_WIDTH, finger->size); 237 | } 238 | 239 | // save the greatest pressure for later (button) use 240 | if (finger->pressure > pressure) { 241 | pressure = finger->pressure; 242 | } 243 | 244 | input_mt_report_slot_state(device->input, MT_TOOL_FINGER, true); 245 | input_report_abs(device->input, ABS_MT_PRESSURE, finger->pressure); 246 | input_report_abs(device->input, ABS_MT_TOUCH_MAJOR, 247 | raw2int(finger->touch_major) << 2); 248 | input_report_abs(device->input, ABS_MT_TOUCH_MINOR, 249 | raw2int(finger->touch_minor) << 2); 250 | 251 | input_report_abs(device->input, ABS_MT_ORIENTATION, 252 | MAX_FINGER_ORIENTATION - ((finger->orientation_origin & 0xf0) << 6)); 253 | 254 | input_report_abs(device->input, ABS_MT_POSITION_X, tmp_x); 255 | input_report_abs(device->input, ABS_MT_POSITION_Y, tmp_y); 256 | } 257 | } 258 | 259 | // have any fingers been lifted? 260 | for (i = 0; i < MAX_FINGERS; i++) { 261 | if (device->slots[i] != 0) { 262 | if (active_ids[device->slots[i]] == 0) { 263 | device->slots[i] = 0; 264 | input_mt_slot(device->input, i); 265 | input_report_abs(device->input, ABS_MT_TRACKING_ID, -1); 266 | } 267 | } 268 | } 269 | 270 | input_sync(device->input); 271 | 272 | if (pressure > PRESSURE_CLICK_THRESHOLD && pressure < PRESSURE_FORCE_THRESHOLD && status == 0) { 273 | bdown(hdev); 274 | status = 1; 275 | input_report_key(device->input, BTN_LEFT, 1); 276 | } else if (pressure >= PRESSURE_FORCE_THRESHOLD && status == 1) { 277 | bforce(hdev); 278 | status = 2; 279 | input_report_key(device->input, BTN_LEFT, 0); 280 | input_report_key(device->input, BTN_MIDDLE, 1); 281 | } else if (pressure > PRESSURE_CLICK_THRESHOLD && pressure < PRESSURE_FORCE_THRESHOLD && status == 2) { 282 | bup(hdev); 283 | status = 3; 284 | input_report_key(device->input, BTN_LEFT, 0); 285 | input_report_key(device->input, BTN_MIDDLE, 0); 286 | } else if (pressure <= PRESSURE_CLICK_THRESHOLD && status == 1) { 287 | bup(hdev); 288 | status = 0; 289 | input_report_key(device->input, BTN_LEFT, 0); 290 | } else if (pressure <= PRESSURE_CLICK_THRESHOLD && status == 3) { 291 | status = 0; 292 | } 293 | 294 | return 0; 295 | } 296 | 297 | static int input_mapping(struct hid_device *hdev, 298 | struct hid_input *hi, struct hid_field *field, 299 | struct hid_usage *usage, unsigned long **bit, int *max) { 300 | struct bcm5974 *device = hid_get_drvdata(hdev); 301 | 302 | if (!device->input) { 303 | device->input = hi->input; 304 | } 305 | 306 | return 0; 307 | } 308 | 309 | static void set_abs(struct input_dev *input, unsigned int code, 310 | const struct bcm5974_param *p) { 311 | int fuzz = p->snratio ? (p->max - p->min) / p->snratio : 0; 312 | input_set_abs_params(input, code, p->min, p->max, fuzz, 0); 313 | } 314 | 315 | 316 | static int setup_input(struct input_dev *input_dev, struct hid_device *hdev) { 317 | int size; 318 | 319 | // reverse engineered. 320 | __u8 m1[] = {0xF1, 0x01, 0xDB}, // unknown purpose. 321 | enableHostClick[] = {0xF2, 0x21, 0x01}, // enables host clicks/disables autonomous clicks 322 | m5[] = {0xF1, 0x01, 0xC8}, // unknown purpose. 323 | enableMultiTrackMode[] = {0xF1, 0x02, 0x01}, 324 | enableEmptyFingerReport[] = {0xF1, 0xC8, 0x09}; 325 | 326 | // if we leave the bt device name, the default synaptics/X11 327 | // config will not apply the special rules for apple devices. 328 | input_dev->name = "Apple Magic Trackpad 2"; 329 | 330 | __clear_bit(EV_REL, input_dev->evbit); 331 | __clear_bit(REL_X, input_dev->relbit); 332 | __clear_bit(REL_Y, input_dev->relbit); 333 | 334 | __set_bit(EV_ABS, input_dev->evbit); 335 | __clear_bit(BTN_RIGHT, input_dev->keybit); 336 | 337 | // if we enable this, the X11 synaptics driver 338 | // will set ClickAction to 1 1 0 rather than 1 3 0 339 | //__set_bit(BTN_MIDDLE, input_dev->keybit); 340 | 341 | __set_bit(BTN_MOUSE, input_dev->keybit); 342 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 343 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 344 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 345 | __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); 346 | __set_bit(BTN_TOOL_QUINTTAP, input_dev->keybit); 347 | __set_bit(BTN_TOUCH, input_dev->keybit); 348 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 349 | __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); 350 | 351 | /* for synaptics only */ 352 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 256, 0, 0); 353 | input_set_abs_params(input_dev, ABS_TOOL_WIDTH, 0, 16, 0, 0); 354 | 355 | /* finger touch area */ 356 | set_abs(input_dev, ABS_MT_TOUCH_MAJOR, &trackpad_config.w); 357 | set_abs(input_dev, ABS_MT_TOUCH_MINOR, &trackpad_config.w); 358 | /* finger orientation */ 359 | set_abs(input_dev, ABS_MT_ORIENTATION, &trackpad_config.o); 360 | /* finger position */ 361 | set_abs(input_dev, ABS_MT_POSITION_X, &trackpad_config.x); 362 | set_abs(input_dev, ABS_MT_POSITION_Y, &trackpad_config.y); 363 | 364 | __set_bit(EV_KEY, input_dev->evbit); 365 | __set_bit(BTN_LEFT, input_dev->keybit); 366 | 367 | if (trackpad_config.caps & HAS_INTEGRATED_BUTTON) 368 | __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); 369 | 370 | input_mt_init_slots(input_dev, MAX_FINGERS, INPUT_MT_POINTER); 371 | 372 | 373 | input_set_abs_params(input_dev, ABS_X, trackpad_config.x.min, 374 | trackpad_config.x.max, 4, 0); 375 | input_set_abs_params(input_dev, ABS_Y, trackpad_config.y.min, 376 | trackpad_config.y.max, 4, 0); 377 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, 378 | trackpad_config.x.min, 379 | trackpad_config.x.max, 4, 0); 380 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 381 | trackpad_config.y.min, 382 | trackpad_config.y.max, 4, 0); 383 | 384 | 385 | // hardware device initialisation. probably doesn't belong here. 386 | size = hid_hw_raw_request(hdev, 387 | m1[0], m1, 388 | sizeof(m1), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 389 | size = hid_hw_raw_request(hdev, 390 | enableHostClick[0], 391 | enableHostClick, 392 | sizeof(enableHostClick), 393 | HID_FEATURE_REPORT, 394 | HID_REQ_SET_REPORT 395 | ); 396 | size = hid_hw_raw_request(hdev, 397 | m5[0], m5, 398 | sizeof(m5), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 399 | size = hid_hw_raw_request(hdev, 400 | enableMultiTrackMode[0], 401 | enableMultiTrackMode, 402 | sizeof(enableMultiTrackMode), 403 | HID_FEATURE_REPORT, 404 | HID_REQ_SET_REPORT 405 | ); 406 | size = hid_hw_raw_request(hdev, 407 | enableEmptyFingerReport[0], 408 | enableEmptyFingerReport, 409 | sizeof(enableEmptyFingerReport), 410 | HID_FEATURE_REPORT, 411 | HID_REQ_SET_REPORT 412 | ); 413 | 414 | return 0; 415 | } 416 | 417 | static int input_configured(struct hid_device *hdev, struct hid_input *hi) { 418 | struct bcm5974 *device = hid_get_drvdata(hdev); 419 | int ret; 420 | 421 | ret = setup_input(device->input, hdev); 422 | if (ret) { 423 | hid_err(hdev, "trackpad setup input failed (%d)\n", ret); 424 | /* clean msc->input to notify probe() of the failure */ 425 | device->input = NULL; 426 | return ret; 427 | } 428 | 429 | return 0; 430 | } 431 | 432 | static struct hid_driver trackpad_driver = { 433 | .name = "magictrackpad", 434 | .id_table = magic_trackpads, 435 | .probe = probe, 436 | .raw_event = raw_event, 437 | .input_mapping = input_mapping, 438 | .input_configured = input_configured, 439 | }; 440 | module_hid_driver(trackpad_driver); 441 | 442 | MODULE_LICENSE("GPL"); 443 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | --------------------------------------------------------------------------------