Changeset cac458f in mainline for uspace/srv/hid/input/proto/adb.c
- Timestamp:
- 2011-06-22T01:59:39Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41e2118
- Parents:
- 79506d6 (diff), f1fae414 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/srv/hid/input/proto/adb.c (moved) (moved from uspace/lib/c/include/devmap_obsolete.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/proto/adb.c
r79506d6 rcac458f 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc 29 /** @addtogroup mouse_proto 30 * @ingroup input 30 31 * @{ 31 32 */ 32 /** @file 33 /** 34 * @file 35 * @brief ADB protocol driver. 33 36 */ 34 37 35 #ifndef LIBC_DEVMAP_OBSOLETE_H_ 36 #define LIBC_DEVMAP_OBSOLETE_H_ 38 #include <bool.h> 39 #include <mouse.h> 40 #include <mouse_port.h> 41 #include <mouse_proto.h> 37 42 38 #include <ipc/devmap.h> 39 #include <async.h> 40 #include <bool.h> 43 static mouse_dev_t *mouse_dev; 44 static bool b1_pressed; 45 static bool b2_pressed; 41 46 42 extern int devmap_obsolete_get_phone(devmap_interface_t, unsigned int); 43 extern void devmap_obsolete_hangup_phone(devmap_interface_t iface); 47 static int adb_proto_init(mouse_dev_t *mdev) 48 { 49 mouse_dev = mdev; 50 b1_pressed = false; 51 b2_pressed = false; 52 53 return 0; 54 } 44 55 45 extern int devmap_obsolete_device_connect(devmap_handle_t, unsigned int); 56 /** Process mouse data */ 57 static void adb_proto_parse(sysarg_t data) 58 { 59 bool b1, b2; 60 uint16_t udx, udy; 61 int dx, dy; 62 63 /* Extract fields. */ 64 b1 = ((data >> 15) & 1) == 0; 65 udy = (data >> 8) & 0x7f; 66 b2 = ((data >> 7) & 1) == 0; 67 udx = data & 0x7f; 68 69 /* Decode 7-bit two's complement signed values. */ 70 dx = (udx & 0x40) ? (udx - 0x80) : udx; 71 dy = (udy & 0x40) ? (udy - 0x80) : udy; 72 73 if (b1 != b1_pressed) { 74 mouse_push_event_button(mouse_dev, 1, b1); 75 b1_pressed = b1; 76 } 77 78 if (b2 != b2_pressed) { 79 mouse_push_event_button(mouse_dev, 2, b2); 80 b1_pressed = b1; 81 } 82 83 if (dx != 0 || dy != 0) 84 mouse_push_event_move(mouse_dev, dx, dy); 85 } 46 86 47 #endif 87 mouse_proto_ops_t adb_proto = { 88 .parse = adb_proto_parse, 89 .init = adb_proto_init 90 }; 48 91 49 /** @} 92 /** 93 * @} 50 94 */
Note:
See TracChangeset
for help on using the changeset viewer.
