Changes in uspace/lib/usbhid/src/hidiface.c [9dddb3d:160b75e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidiface.c
r9dddb3d r160b75e 46 46 * @return Number of usages returned or negative error code. 47 47 */ 48 int usbhid_dev_get_event_length(int dev_phone , size_t *size)48 int usbhid_dev_get_event_length(int dev_phone) 49 49 { 50 50 if (dev_phone < 0) { … … 56 56 IPC_M_USBHID_GET_EVENT_LENGTH, &len); 57 57 if (rc == EOK) { 58 if (size != NULL) {59 *size = (size_t) len;60 }58 return (int) len; 59 } else { 60 return rc; 61 61 } 62 63 return rc;64 62 } 65 63 … … 76 74 * @return Error code. 77 75 */ 78 int usbhid_dev_get_event(int dev_phone, uint 8_t *buf,79 size_t size, size_t *actual_size, unsigned int flags)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) 80 78 { 81 79 if (dev_phone < 0) { 82 80 return EINVAL; 83 81 } 84 if (( buf== NULL)) {82 if ((usage_pages == NULL) || (usages == NULL)) { 85 83 return ENOMEM; 86 84 } 87 if ( size== 0) {85 if (usage_count == 0) { 88 86 return EINVAL; 89 87 } 90 91 // if (size == 0) {92 // return EOK;93 // }94 88 95 size_t buffer_size = size;96 uint 8_t *buffer = malloc(buffer_size);89 size_t buffer_size = sizeof(uint16_t) * usage_count * 2; 90 uint16_t *buffer = malloc(buffer_size); 97 91 if (buffer == NULL) { 98 92 return ENOMEM; … … 134 128 } 135 129 136 size_t act_size = IPC_GET_ARG2(data_request_call); 130 size_t actual_size = IPC_GET_ARG2(data_request_call); 131 size_t items = actual_size / 2; 137 132 138 133 /* Copy the individual items. */ 139 memcpy( buf, buffer, act_size);140 // memcpy(usages, buffer + items, items * sizeof(int32_t));134 memcpy(usage_pages, buffer, items * sizeof(uint16_t)); 135 memcpy(usages, buffer + items, items * sizeof(uint16_t)); 141 136 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; 137 if (actual_usage_count != NULL) { 138 *actual_usage_count = items; 217 139 } 218 140
Note:
See TracChangeset
for help on using the changeset viewer.