source: mainline/uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c@ 6513110

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6513110 was 6513110, checked in by Lubos Slovak <lubos.slovak@…>, 14 years ago

Fixes

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2011 Lubos Slovak, Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbhid
30 * @{
31 */
32/**
33 * @file
34 * USB Logitech UltraX Keyboard sample driver.
35 */
36
37
38#include "lgtch-ultrax.h"
39#include "../usbhid.h"
40
41#include <usb/classes/hidparser.h>
42#include <usb/debug.h>
43#include <errno.h>
44#include <str_error.h>
45
46#define NAME "lgtch-ultrax"
47
48/*----------------------------------------------------------------------------*/
49
50static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
51 uint8_t report_id, void *arg);
52
53static const usb_hid_report_in_callbacks_t usb_lgtch_parser_callbacks = {
54 .keyboard = usb_lgtch_process_keycodes
55};
56
57/*----------------------------------------------------------------------------*/
58
59static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
60 uint8_t report_id, void *arg)
61{
62 // TODO: checks
63
64 usb_log_debug(NAME " Got keys from parser (report id: %u): %s\n",
65 report_id, usb_debug_str_buffer(key_codes, count, 0));
66}
67
68/*----------------------------------------------------------------------------*/
69
70bool usb_lgtch_polling_callback(struct usb_hid_dev *hid_dev,
71 uint8_t *buffer, size_t buffer_size)
72{
73 // TODO: checks
74
75 usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n",
76 hid_dev, buffer, buffer_size);
77
78 usb_log_debug(NAME " Calling usb_hid_parse_report() with "
79 "buffer %s\n", usb_debug_str_buffer(buffer, buffer_size, 0));
80
81 usb_hid_report_path_t *path = usb_hid_report_path();
82 usb_hid_report_path_append_item(path, 0xc, 0);
83
84 uint8_t report_id;
85
86 int rc = usb_hid_parse_report(hid_dev->report, buffer, buffer_size,
87 &report_id);
88 usb_hid_report_path_set_report_id(path, report_id);
89
90 usb_hid_report_field_t *field = usb_hid_report_get_sibling(
91 hid_dev->report, NULL, path, USB_HID_PATH_COMPARE_END ,
92 USB_HID_REPORT_TYPE_INPUT);
93
94 while (field != NULL) {
95 usb_log_debug("KEY VALUE(%X) USAGE(%X)\n", field->value,
96 field->usage);
97 }
98
99
100 usb_hid_report_path_free(path);
101
102 if (rc != EOK) {
103 usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
104 "%s\n", str_error(rc));
105 }
106
107 return true;
108}
109
110/**
111 * @}
112 */
Note: See TracBrowser for help on using the repository browser.