Changes in uspace/lib/usbhid/src/hidiface.c [160b75e:9dddb3d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidiface.c
r160b75e r9dddb3d 46 46 * @return Number of usages returned or negative error code. 47 47 */ 48 int usbhid_dev_get_event_length(int dev_phone )48 int usbhid_dev_get_event_length(int dev_phone, size_t *size) 49 49 { 50 50 if (dev_phone < 0) { … … 56 56 IPC_M_USBHID_GET_EVENT_LENGTH, &len); 57 57 if (rc == EOK) { 58 return (int) len; 59 } else { 60 return rc; 61 } 58 if (size != NULL) { 59 *size = (size_t) len; 60 } 61 } 62 63 return rc; 62 64 } 63 65 … … 74 76 * @return Error code. 75 77 */ 76 int usbhid_dev_get_event(int dev_phone, uint16_t *usage_pages, uint16_t *usages, 77 size_t usage_count, size_t *actual_usage_count, unsigned int flags) 78 { 79 if (dev_phone < 0) { 80 return EINVAL; 81 } 82 if ((usage_pages == NULL) || (usages == NULL)) { 83 return ENOMEM; 84 } 85 if (usage_count == 0) { 86 return EINVAL; 87 } 88 89 size_t buffer_size = sizeof(uint16_t) * usage_count * 2; 90 uint16_t *buffer = malloc(buffer_size); 78 int usbhid_dev_get_event(int dev_phone, uint8_t *buf, 79 size_t size, size_t *actual_size, unsigned int flags) 80 { 81 if (dev_phone < 0) { 82 return EINVAL; 83 } 84 if ((buf == NULL)) { 85 return ENOMEM; 86 } 87 if (size == 0) { 88 return EINVAL; 89 } 90 91 // if (size == 0) { 92 // return EOK; 93 // } 94 95 size_t buffer_size = size; 96 uint8_t *buffer = malloc(buffer_size); 91 97 if (buffer == NULL) { 92 98 return ENOMEM; … … 128 134 } 129 135 130 size_t actual_size = IPC_GET_ARG2(data_request_call); 131 size_t items = actual_size / 2; 136 size_t act_size = IPC_GET_ARG2(data_request_call); 132 137 133 138 /* Copy the individual items. */ 134 memcpy(usage_pages, buffer, items * sizeof(uint16_t)); 135 memcpy(usages, buffer + items, items * sizeof(uint16_t)); 136 137 if (actual_usage_count != NULL) { 138 *actual_usage_count = items; 139 memcpy(buf, buffer, act_size); 140 // memcpy(usages, buffer + items, items * sizeof(int32_t)); 141 142 if (actual_size != NULL) { 143 *actual_size = act_size; 144 } 145 146 return EOK; 147 } 148 149 150 int usbhid_dev_get_report_descriptor_length(int dev_phone, size_t *size) 151 { 152 if (dev_phone < 0) { 153 return EINVAL; 154 } 155 156 sysarg_t arg_size; 157 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(USBHID_DEV_IFACE), 158 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, &arg_size); 159 if (rc == EOK) { 160 if (size != NULL) { 161 *size = (size_t) arg_size; 162 } 163 } 164 return rc; 165 } 166 167 int usbhid_dev_get_report_descriptor(int dev_phone, uint8_t *buf, size_t size, 168 size_t *actual_size) 169 { 170 if (dev_phone < 0) { 171 return EINVAL; 172 } 173 if ((buf == NULL)) { 174 return ENOMEM; 175 } 176 if (size == 0) { 177 return EINVAL; 178 } 179 180 aid_t opening_request = async_send_1(dev_phone, 181 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_REPORT_DESCRIPTOR, 182 NULL); 183 if (opening_request == 0) { 184 return ENOMEM; 185 } 186 187 ipc_call_t data_request_call; 188 aid_t data_request = async_data_read(dev_phone, buf, size, 189 &data_request_call); 190 if (data_request == 0) { 191 async_wait_for(opening_request, NULL); 192 return ENOMEM; 193 } 194 195 sysarg_t data_request_rc; 196 sysarg_t opening_request_rc; 197 async_wait_for(data_request, &data_request_rc); 198 async_wait_for(opening_request, &opening_request_rc); 199 200 if (data_request_rc != EOK) { 201 /* Prefer return code of the opening request. */ 202 if (opening_request_rc != EOK) { 203 return (int) opening_request_rc; 204 } else { 205 return (int) data_request_rc; 206 } 207 } 208 209 if (opening_request_rc != EOK) { 210 return (int) opening_request_rc; 211 } 212 213 size_t act_size = IPC_GET_ARG2(data_request_call); 214 215 if (actual_size != NULL) { 216 *actual_size = act_size; 139 217 } 140 218
Note:
See TracChangeset
for help on using the changeset viewer.