USB HID driver
[USB]

USB driver for HID devices. More...


Files

file  conv.c
 USB scancode parser.
file  conv.h
 USB scancode parser.
file  hiddev.c
 USB HID driver API.
file  hiddev.h
 USB HID driver API.
file  hidreq.c
 HID class-specific requests.
file  kbddev.c
 USB HID keyboard device structure and API.
file  kbddev.h
 USB HID keyboard device structure and API.
file  kbdrepeat.c
 USB HID keyboard autorepeat facilities.
file  kbdrepeat.h
 USB HID keyboard autorepeat facilities.
file  keymap.c
 UUSB multimedia key to keycode mapping.
file  keymap.h
 USB multimedia key to keycode mapping.
file  layout.h
 Keyboard layout.
file  main.c
 Main routines of USB HID driver.
file  main.c
 Main routines of USB KBD driver.
file  mousedev.c
 USB Mouse driver API.
file  mousedev.h
 USB Mouse driver API.
file  multimedia.c
 USB Keyboard multimedia keys subdriver.
file  multimedia.h
 USB Keyboard multimedia keys subdriver.
file  subdrivers.c
 USB HID subdriver mappings.
file  subdrivers.h
 USB HID subdriver mappings.
file  usbhid.c
 USB HID driver API.
file  usbhid.h
 USB HID driver API.

Data Structures

struct  layout_op_t
struct  usb_hid_dev
 Structure for holding general HID device data. More...
struct  usb_hid_subdriver
struct  usb_hid_subdriver_mapping
 Structure representing the mapping between device requirements and the subdriver supposed to handle this device. More...
struct  usb_hid_subdriver_usage
struct  usb_kbd_repeat_t
 Structure for keeping information needed for auto-repeat of keys. More...
struct  usb_kbd_t
 USB/HID keyboard device type. More...
struct  usb_mouse_t
 Container for USB mouse device. More...
struct  usb_multimedia_t
 Logitech UltraX device type. More...

Defines

#define NAME   "multimedia-keys"
#define NAME   "mouse"
#define NAME   "usbhid"
#define NAME   "usbkbd"
#define NUM_LAYOUTS   3

Typedefs

typedef usb_hid_dev usb_hid_dev_t
 Structure for holding general HID device data.
typedef void(*) usb_hid_driver_deinit_t (struct usb_hid_dev *, void *data)
typedef int(*) usb_hid_driver_init_t (struct usb_hid_dev *, void **data)
typedef int(*) usb_hid_driver_poll_ended_t (struct usb_hid_dev *, void *data, bool reason)
typedef bool(*) usb_hid_driver_poll_t (struct usb_hid_dev *, void *data)
typedef usb_hid_subdriver_mapping usb_hid_subdriver_mapping_t
 Structure representing the mapping between device requirements and the subdriver supposed to handle this device.

Enumerations

enum  
enum  
enum  
enum  usb_kbd_flags

Functions

static void default_connection_handler (ddf_fun_t *fun, ipc_callid_t icallid, ipc_call_t *icall)
 Default handler for IPC methods not handled by DDF.
int main (int argc, char *argv[])
 Main entry point.
static int usb_generic_get_report_descriptor (ddf_fun_t *fun, uint8_t *desc, size_t size, size_t *actual_size)
static size_t usb_generic_get_report_descriptor_length (ddf_fun_t *fun)
static int usb_generic_hid_client_connected (ddf_fun_t *fun)
static int usb_generic_hid_create_function (usb_hid_dev_t *hid_dev)
static int usb_generic_hid_get_event (ddf_fun_t *fun, uint8_t *buffer, size_t size, size_t *act_size, int *event_nr, unsigned int flags)
static size_t usb_generic_hid_get_event_length (ddf_fun_t *fun)
int usb_generic_hid_init (usb_hid_dev_t *hid_dev, void **data)
bool usb_generic_hid_polling_callback (usb_hid_dev_t *hid_dev, void *data)
static int usb_hid_add_device (usb_device_t *dev)
 Callback for passing a new device to the driver.
static int usb_hid_check_pipes (usb_hid_dev_t *hid_dev, usb_device_t *dev)
static int usb_hid_find_subdrivers (usb_hid_dev_t *hid_dev)
void usb_hid_free (usb_hid_dev_t **hid_dev)
static bool usb_hid_ids_match (usb_hid_dev_t *hid_dev, const usb_hid_subdriver_mapping_t *mapping)
int usb_hid_init (usb_hid_dev_t *hid_dev, usb_device_t *dev)
static int usb_hid_init_report (usb_hid_dev_t *hid_dev)
usb_hid_dev_tusb_hid_new (void)
void usb_hid_new_report (usb_hid_dev_t *hid_dev)
static bool usb_hid_path_matches (usb_hid_dev_t *hid_dev, const usb_hid_subdriver_mapping_t *mapping)
bool usb_hid_polling_callback (usb_device_t *dev, uint8_t *buffer, size_t buffer_size, void *arg)
void usb_hid_polling_ended_callback (usb_device_t *dev, bool reason, void *arg)
int usb_hid_report_number (usb_hid_dev_t *hid_dev)
static int usb_hid_save_subdrivers (usb_hid_dev_t *hid_dev, const usb_hid_subdriver_t **subdrivers, int count)
static int usb_hid_set_boot_kbd_subdriver (usb_hid_dev_t *hid_dev)
static int usb_hid_set_boot_mouse_subdriver (usb_hid_dev_t *hid_dev)
static int usb_hid_set_generic_hid_subdriver (usb_hid_dev_t *hid_dev)
static int usb_hid_try_add_device (usb_device_t *dev)
 Function for adding a new device of type USB/HID/keyboard.
static int usb_kbd_add_device (usb_device_t *dev)
 Callback for passing a new device to the driver.
static void usb_kbd_check_key_changes (usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
 Checks if some keys were pressed or released and generates key events.
static int usb_kbd_create_function (usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
void usb_kbd_deinit (usb_hid_dev_t *hid_dev, void *data)
void usb_kbd_free (usb_kbd_t **kbd_dev)
 Properly destroys the USB/HID keyboard structure.
int usb_kbd_init (usb_hid_dev_t *hid_dev, void **data)
 Initialization of the USB/HID keyboard structure.
int usb_kbd_is_initialized (const usb_kbd_t *kbd_dev)
static int usb_kbd_is_lock (unsigned int key_code)
int usb_kbd_is_ready_to_destroy (const usb_kbd_t *kbd_dev)
static void usb_kbd_mark_unusable (usb_kbd_t *kbd_dev)
static usb_kbd_tusb_kbd_new (void)
 Creates a new USB/HID keyboard structure.
bool usb_kbd_polling_callback (usb_hid_dev_t *hid_dev, void *data)
static void usb_kbd_process_data (usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
 Processes data received from the device in form of report.
void usb_kbd_push_ev (usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev, int type, unsigned int key)
 Processes key events.
int usb_kbd_repeat_fibril (void *arg)
 Main routine to be executed by a fibril for handling auto-repeat.
static void usb_kbd_repeat_loop (usb_kbd_t *kbd)
 Main loop handling the auto-repeat of keys.
void usb_kbd_repeat_start (usb_kbd_t *kbd, unsigned int key)
 Start repeating particular key.
void usb_kbd_repeat_stop (usb_kbd_t *kbd, unsigned int key)
 Stop repeating particular key.
int usb_kbd_set_boot_protocol (usb_hid_dev_t *hid_dev)
static void usb_kbd_set_led (usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
 Handles turning of LED lights on and off.
static int usb_kbd_try_add_device (usb_device_t *dev)
 Function for adding a new device of type USB/HID/keyboard.
static int usb_mouse_create_function (usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
void usb_mouse_deinit (usb_hid_dev_t *hid_dev, void *data)
static void usb_mouse_free (usb_mouse_t **mouse_dev)
int usb_mouse_init (usb_hid_dev_t *hid_dev, void **data)
static usb_mouse_tusb_mouse_new (void)
bool usb_mouse_polling_callback (usb_hid_dev_t *hid_dev, void *data)
static bool usb_mouse_process_report (usb_hid_dev_t *hid_dev, usb_mouse_t *mouse_dev)
static void usb_mouse_send_wheel (const usb_mouse_t *mouse_dev, int wheel)
int usb_mouse_set_boot_protocol (usb_hid_dev_t *hid_dev)
static int usb_multimedia_create_function (usb_hid_dev_t *hid_dev, usb_multimedia_t *multim_dev)
void usb_multimedia_deinit (struct usb_hid_dev *hid_dev, void *data)
static void usb_multimedia_free (usb_multimedia_t **multim_dev)
int usb_multimedia_init (struct usb_hid_dev *hid_dev, void **data)
unsigned int usb_multimedia_map_usage (int usage)
 Translates USB HID Usages from the Consumer Page into HelenOS keycodes.
bool usb_multimedia_polling_callback (struct usb_hid_dev *hid_dev, void *data)
static void usb_multimedia_push_ev (usb_hid_dev_t *hid_dev, usb_multimedia_t *multim_dev, int type, unsigned int key)
 Processes key events.
unsigned int usbhid_parse_scancode (int scancode)
 Translate USB HID key codes (from HID Usage Tables) to generic key codes recognized by HelenOS.
int usbhid_req_get_idle (usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration)
 Send Get Idle request to the HID device.
int usbhid_req_get_protocol (usb_pipe_t *ctrl_pipe, int iface_no, usb_hid_protocol_t *protocol)
 Send Get Protocol request to the HID device.
int usbhid_req_get_report (usb_pipe_t *ctrl_pipe, int iface_no, usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size, size_t *actual_size)
 Send Get Report request to the HID device.
int usbhid_req_set_idle (usb_pipe_t *ctrl_pipe, int iface_no, uint8_t duration)
 Send Set Idle request to the HID device.
int usbhid_req_set_protocol (usb_pipe_t *ctrl_pipe, int iface_no, usb_hid_protocol_t protocol)
 Send Set Protocol request to the HID device.
int usbhid_req_set_report (usb_pipe_t *ctrl_pipe, int iface_no, usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size)
 Send Set Report request to the HID device.

Variables

static int active_layout = 0
static unsigned int CHECK_DELAY = 10000
 Delay between auto-repeat state checks when no key is being repeated.
layout_op_t cz_op
static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK
 Default modifiers when the keyboard is initialized.
static const unsigned int DEFAULT_DELAY_BEFORE_FIRST_REPEAT = 500 * 1000
 Delay before a pressed key starts auto-repeating.
static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000
 Delay between two repeats of a pressed key when auto-repeating.
static const uint8_t ERROR_ROLLOVER = 1
const char * HID_GENERIC_CLASS_NAME
const char * HID_GENERIC_CLASS_NAME = "hid"
const char * HID_GENERIC_FUN_NAME
const char * HID_GENERIC_FUN_NAME = "hid"
const char * HID_KBD_CLASS_NAME
const char * HID_KBD_CLASS_NAME = "keyboard"
const char * HID_KBD_FUN_NAME
const char * HID_KBD_FUN_NAME = "keyboard"
const char * HID_MOUSE_CLASS_NAME
const char * HID_MOUSE_CLASS_NAME = "mouse"
const char * HID_MOUSE_FUN_NAME
const char * HID_MOUSE_FUN_NAME = "mouse"
const char * HID_MOUSE_WHEEL_CLASS_NAME = "keyboard"
const char * HID_MOUSE_WHEEL_FUN_NAME = "mouse-wheel"
static const uint8_t IDLE_RATE = 0
 Default idle rate for mouses.
static const uint8_t IDLE_RATE = 0
 Default idle rate for keyboards.
static layout_op_tlayout [NUM_LAYOUTS]
 Keyboard layout map.
static usb_hid_subdriver_usage_t multim_key_path []
static ddf_dev_ops_t multimedia_ops
static usb_hid_subdriver_usage_t path_kbd []
static usb_hid_subdriver_usage_t path_mouse []
static int scanmap_simple [255]
 Mapping between USB HID key codes (from HID Usage Tables) and corresponding HelenOS key codes.
layout_op_t us_dvorak_op
layout_op_t us_qwerty_op
static ddf_dev_ops_t usb_generic_hid_ops
static usbhid_iface_t usb_generic_iface
static usb_driver_t usb_hid_driver
static usb_driver_ops_t usb_hid_driver_ops
usb_endpoint_description_tusb_hid_endpoints [USB_HID_POLL_EP_COUNT+1]
usb_endpoint_description_tusb_hid_endpoints [USB_HID_POLL_EP_COUNT+1]
usb_endpoint_description_t usb_hid_generic_poll_endpoint_description
usb_endpoint_description_t usb_hid_generic_poll_endpoint_description
usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description
usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description
 Keyboard polling endpoint description for boot protocol class.
static int usb_hid_keymap_consumer [0x29c]
 Mapping between USB HID multimedia usages (from HID Usage Tables) and corresponding HelenOS key codes.
static const int USB_HID_MAX_SUBDRIVERS = 10
usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description
usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description
const usb_hid_subdriver_mapping_t usb_hid_subdrivers []
const usb_hid_subdriver_mapping_t usb_hid_subdrivers []
static const uint8_t USB_KBD_BOOT_REPORT_DESCRIPTOR [USB_KBD_BOOT_REPORT_DESCRIPTOR_SIZE]
static usb_driver_t usb_kbd_driver
static usb_driver_ops_t usb_kbd_driver_ops
static const uint8_t USB_MOUSE_BOOT_REPORT_DESCRIPTOR [USB_MOUSE_BOOT_REPORT_DESCRIPTOR_SIZE]
static const size_t USB_MOUSE_BUTTON_COUNT = 3

Detailed Description

USB driver for HID devices.


Typedef Documentation

typedef struct usb_hid_subdriver_mapping usb_hid_subdriver_mapping_t

Structure representing the mapping between device requirements and the subdriver supposed to handle this device.

By filling in this structure and adding it to the usb_hid_subdrivers array, a new subdriver mapping will be created and used by the HID driver when it searches for appropriate subdrivers for a device.


Function Documentation

static void default_connection_handler ( ddf_fun_t fun,
ipc_callid_t  icallid,
ipc_call_t icall 
) [static]

Default handler for IPC methods not handled by DDF.

Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it assumes the caller is the console and thus it stores IPC phone to it for later use by the driver to notify about key events.

Parameters:
fun Device function handling the call.
icallid Call id.
icall Call data.

Definition at line 183 of file kbddev.c.

int main ( int  argc,
char *  argv[] 
)

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 233 of file main.c.

static int usb_generic_hid_create_function ( usb_hid_dev_t hid_dev  )  [static]

Definition at line 192 of file hiddev.c.

static int usb_generic_hid_get_event ( ddf_fun_t fun,
uint8_t *  buffer,
size_t  size,
size_t act_size,
int *  event_nr,
unsigned int  flags 
) [static]

Definition at line 109 of file hiddev.c.

static int usb_hid_add_device ( usb_device_t dev  )  [static]

Callback for passing a new device to the driver.

Note:
Currently, only boot-protocol keyboards are supported by this driver.
Parameters:
dev Structure representing the new device.
Return values:
EOK if successful.
EREFUSED if the device is not supported.

Definition at line 152 of file main.c.

bool usb_hid_polling_callback ( usb_device_t dev,
uint8_t *  buffer,
size_t  buffer_size,
void *  arg 
)

Definition at line 561 of file usbhid.c.

static int usb_hid_try_add_device ( usb_device_t dev  )  [static]

Function for adding a new device of type USB/HID/keyboard.

This functions initializes required structures from the device's descriptors and starts new fibril for polling the keyboard for events and another one for handling auto-repeat of keys.

During initialization, the keyboard is switched into boot protocol, the idle rate is set to 0 (infinity), resulting in the keyboard only reporting event when a key is pressed or released. Finally, the LED lights are turned on according to the default setup of lock keys.

Note:
By default, the keyboards is initialized with Num Lock turned on and other locks turned off.

Currently supports only boot-protocol keyboards.

Parameters:
dev Device to add.
Return values:
EOK if successful.
ENOMEM if there
Returns:
Other error code inherited from one of functions usb_kbd_init(), ddf_fun_bind() and ddf_fun_add_to_class().

Definition at line 75 of file main.c.

static int usb_kbd_add_device ( usb_device_t dev  )  [static]

Callback for passing a new device to the driver.

Note:
Currently, only boot-protocol keyboards are supported by this driver.
Parameters:
dev Structure representing the new device.
Return values:
EOK if successful.
EREFUSED if the device is not supported.

Definition at line 190 of file main.c.

static void usb_kbd_check_key_changes ( usb_hid_dev_t hid_dev,
usb_kbd_t kbd_dev 
) [static]

Checks if some keys were pressed or released and generates key events.

An event is created only when key is pressed or released. Besides handling the events (usb_kbd_push_ev()), the auto-repeat fibril is notified about key presses and releases (see usb_kbd_repeat_start() and usb_kbd_repeat_stop()).

Parameters:
kbd_dev Keyboard device structure.
key_codes Parsed keyboard report - codes of currently pressed keys according to HID Usage Tables.
count Number of key codes in report (size of the report).
See also:
usb_kbd_push_ev(), usb_kbd_repeat_start(), usb_kbd_repeat_stop()

Definition at line 430 of file kbddev.c.

void usb_kbd_free ( usb_kbd_t **  kbd_dev  ) 

Properly destroys the USB/HID keyboard structure.

Parameters:
kbd_dev Pointer to the structure to be destroyed.

Definition at line 887 of file kbddev.c.

int usb_kbd_init ( usb_hid_dev_t hid_dev,
void **  data 
)

Initialization of the USB/HID keyboard structure.

This functions initializes required structures from the device's descriptors.

During initialization, the keyboard is switched into boot protocol, the idle rate is set to 0 (infinity), resulting in the keyboard only reporting event when a key is pressed or released. Finally, the LED lights are turned on according to the default setup of lock keys.

Note:
By default, the keyboards is initialized with Num Lock turned on and other locks turned off.
Parameters:
kbd_dev Keyboard device structure to be initialized.
dev DDF device structure of the keyboard.
Return values:
EOK if successful.
EINVAL if some parameter is not given.
Returns:
Other value inherited from function usbhid_dev_init().

Definition at line 698 of file kbddev.c.

static usb_kbd_t* usb_kbd_new ( void   )  [static]

Creates a new USB/HID keyboard structure.

The structure returned by this function is not initialized. Use usb_kbd_init() to initialize it prior to polling.

Returns:
New uninitialized structure for representing a USB/HID keyboard or NULL if not successful (memory error).

Definition at line 610 of file kbddev.c.

static void usb_kbd_process_data ( usb_hid_dev_t hid_dev,
usb_kbd_t kbd_dev 
) [static]

Processes data received from the device in form of report.

This function uses the HID report parser to translate the data received from the device into generic USB HID key codes and into generic modifiers bitmap. The parser then calls the given callback (usb_kbd_process_keycodes()).

Note:
Currently, only the boot protocol is supported.
Parameters:
kbd_dev Keyboard device structure (must be initialized).
buffer Data from the keyboard (i.e. the report).
actual_size Size of the data from keyboard (report size) in bytes.
See also:
usb_kbd_process_keycodes(), usb_hid_boot_keyboard_input_report(), usb_hid_parse_report().

Definition at line 531 of file kbddev.c.

void usb_kbd_push_ev ( usb_hid_dev_t hid_dev,
usb_kbd_t kbd_dev,
int  type,
unsigned int  key 
)

Processes key events.

Note:
This function was copied from AT keyboard driver and modified to suit USB keyboard.

Lock keys are not sent to the console, as they are completely handled in the driver. It may, however, be required later that the driver sends also these keys to application (otherwise it cannot use those keys at all).

Parameters:
kbd_dev Keyboard device structure.
type Type of the event (press / release). Recognized values: KEY_PRESS, KEY_RELEASE
key Key code of the key according to HID Usage Tables.

Definition at line 306 of file kbddev.c.

int usb_kbd_repeat_fibril ( void *  arg  ) 

Main routine to be executed by a fibril for handling auto-repeat.

Starts the loop for checking changes in auto-repeat.

Parameters:
arg User-specified argument. Expects pointer to the keyboard device structure representing the keyboard.
Return values:
EOK if the routine has finished.
EINVAL if no argument is supplied.

Definition at line 130 of file kbdrepeat.c.

static void usb_kbd_repeat_loop ( usb_kbd_t kbd  )  [static]

Main loop handling the auto-repeat of keys.

This functions periodically checks if there is some key to be auto-repeated.

If a new key is to be repeated, it uses the delay before first repeat stored in the keyboard structure to wait until the key has to start repeating.

If the same key is still pressed, it uses the delay between repeats stored in the keyboard structure to wait until the key should be repeated.

If the currently repeated key is not pressed any more ( usb_kbd_repeat_stop() was called), it stops repeating it and starts checking again.

Note:
For accessing the keyboard device auto-repeat information a fibril mutex (repeat_mtx) from the kbd structure is used.
Parameters:
kbd Keyboard device structure.

Definition at line 72 of file kbdrepeat.c.

void usb_kbd_repeat_start ( usb_kbd_t kbd,
unsigned int  key 
)

Start repeating particular key.

Note:
Only one key is repeated at any time, so calling this function effectively cancels auto-repeat of the current repeated key (if any) and 'schedules' another key for auto-repeat.
Parameters:
kbd Keyboard device structure.
key Key to start repeating.

Definition at line 157 of file kbdrepeat.c.

void usb_kbd_repeat_stop ( usb_kbd_t kbd,
unsigned int  key 
)

Stop repeating particular key.

Note:
Only one key is repeated at any time, but this function may be called even with key that is not currently repeated (in that case nothing happens).
Parameters:
kbd Keyboard device structure.
key Key to stop repeating.

Definition at line 175 of file kbdrepeat.c.

static void usb_kbd_set_led ( usb_hid_dev_t hid_dev,
usb_kbd_t kbd_dev 
) [static]

Handles turning of LED lights on and off.

In case of USB keyboards, the LEDs are handled in the driver, not in the device. When there should be a change (lock key was pressed), the driver uses a Set_Report request sent to the device to set the state of the LEDs.

This functions sets the LED lights according to current settings of modifiers kept in the keyboard device structure.

Parameters:
kbd_dev Keyboard device structure.

Definition at line 232 of file kbddev.c.

static int usb_kbd_try_add_device ( usb_device_t dev  )  [static]

Function for adding a new device of type USB/HID/keyboard.

This functions initializes required structures from the device's descriptors and starts new fibril for polling the keyboard for events and another one for handling auto-repeat of keys.

During initialization, the keyboard is switched into boot protocol, the idle rate is set to 0 (infinity), resulting in the keyboard only reporting event when a key is pressed or released. Finally, the LED lights are turned on according to the default setup of lock keys.

Note:
By default, the keyboards is initialized with Num Lock turned on and other locks turned off.

Currently supports only boot-protocol keyboards.

Parameters:
dev Device to add.
Return values:
EOK if successful.
ENOMEM if there
Returns:
Other error code inherited from one of functions usb_kbd_init(), ddf_fun_bind() and ddf_fun_add_to_class().
See also:
usb_kbd_fibril(), usb_kbd_repeat_fibril()

Definition at line 77 of file main.c.

int usb_multimedia_init ( struct usb_hid_dev hid_dev,
void **  data 
)

Definition at line 221 of file multimedia.c.

unsigned int usb_multimedia_map_usage ( int  usage  ) 

Translates USB HID Usages from the Consumer Page into HelenOS keycodes.

Parameters:
usage USB HID Consumer Page Usage number.
Return values:
HelenOS key code corresponding to the given USB Consumer Page Usage.

Definition at line 77 of file keymap.c.

bool usb_multimedia_polling_callback ( struct usb_hid_dev hid_dev,
void *  data 
)

Definition at line 271 of file multimedia.c.

static void usb_multimedia_push_ev ( usb_hid_dev_t hid_dev,
usb_multimedia_t multim_dev,
int  type,
unsigned int  key 
) [static]

Processes key events.

Note:
This function was copied from AT keyboard driver and modified to suit USB keyboard.

Lock keys are not sent to the console, as they are completely handled in the driver. It may, however, be required later that the driver sends also these keys to application (otherwise it cannot use those keys at all).

Parameters:
hid_dev 
lgtch_dev 
type Type of the event (press / release). Recognized values: KEY_PRESS, KEY_RELEASE
key Key code of the key according to HID Usage Tables.

Definition at line 139 of file multimedia.c.

unsigned int usbhid_parse_scancode ( int  scancode  ) 

Translate USB HID key codes (from HID Usage Tables) to generic key codes recognized by HelenOS.

Parameters:
scancode USB HID key code (from HID Usage Tables).
Return values:
HelenOS key code corresponding to the given USB HID key code.

Definition at line 178 of file conv.c.

int usbhid_req_get_idle ( usb_pipe_t ctrl_pipe,
int  iface_no,
uint8_t *  duration 
)

Send Get Idle request to the HID device.

Parameters:
[in] hid_dev HID device to send the request to.
[out] duration Duration value (multiplicate by 4 to get real duration in miliseconds).
Return values:
EOK if successful.
EINVAL if no HID device is given.
Returns:
Other value inherited from one of functions usb_pipe_start_session(), usb_pipe_end_session(), usb_control_request_set().

Definition at line 326 of file hidreq.c.

int usbhid_req_get_protocol ( usb_pipe_t ctrl_pipe,
int  iface_no,
usb_hid_protocol_t protocol 
)

Send Get Protocol request to the HID device.

Parameters:
[in] hid_dev HID device to send the request to.
[out] protocol Current protocol of the device.
Return values:
EOK if successful.
EINVAL if no HID device is given.
Returns:
Other value inherited from function usb_control_request_set().

Definition at line 264 of file hidreq.c.

int usbhid_req_get_report ( usb_pipe_t ctrl_pipe,
int  iface_no,
usb_hid_report_type_t  type,
uint8_t *  buffer,
size_t  buf_size,
size_t actual_size 
)

Send Get Report request to the HID device.

Parameters:
[in] hid_dev HID device to send the request to.
[in] type Type of the report.
[in] out] buffer Buffer for the report data.
[in] buf_size Size of the buffer (in bytes).
[out] actual_size Actual size of report received from the device (in bytes).
Return values:
EOK if successful.
EINVAL if no HID device is given.
Returns:
Other value inherited from function usb_control_request_set().

Definition at line 212 of file hidreq.c.

int usbhid_req_set_idle ( usb_pipe_t ctrl_pipe,
int  iface_no,
uint8_t  duration 
)

Send Set Idle request to the HID device.

Parameters:
hid_dev HID device to send the request to.
duration Duration value (is multiplicated by 4 by the device to get real duration in miliseconds).
Return values:
EOK if successful.
EINVAL if no HID device is given.
Returns:
Other value inherited from function usb_control_request_set().

Definition at line 159 of file hidreq.c.

int usbhid_req_set_protocol ( usb_pipe_t ctrl_pipe,
int  iface_no,
usb_hid_protocol_t  protocol 
)

Send Set Protocol request to the HID device.

Parameters:
hid_dev HID device to send the request to.
protocol Protocol to set.
Return values:
EOK if successful.
EINVAL if no HID device is given.
Returns:
Other value inherited from function usb_control_request_set().

Definition at line 110 of file hidreq.c.

int usbhid_req_set_report ( usb_pipe_t ctrl_pipe,
int  iface_no,
usb_hid_report_type_t  type,
uint8_t *  buffer,
size_t  buf_size 
)

Send Set Report request to the HID device.

Parameters:
hid_dev HID device to send the request to.
type Type of the report.
buffer Report data.
buf_size Report data size (in bytes).
Return values:
EOK if successful.
EINVAL if no HID device is given.
Returns:
Other value inherited from function usb_control_request_set().

Definition at line 60 of file hidreq.c.


Variable Documentation

int usb_hid_keymap_consumer[0x29c] [static]

Initial value:

 {
        [0xb5] = 0,       
        [0xb6] = 0,       
        [0xb7] = 0,       
        [0xb8] = 0,       
        [0xcd] = 0,   
        [0xe2] = 0,   
        [0xe9] = 0,   
        [0xea] = 0,   
        [0x183] = 0,      
        [0x18a] = 0,      
        [0x192] = 0,      
        [0x221] = 0,      
        [0x223] = 0,      
        [0x224] = 0,      
        [0x225] = 0,      
        [0x226] = 0,      
        [0x227] = 0,  
        [0x22a] = 0   
}
Mapping between USB HID multimedia usages (from HID Usage Tables) and corresponding HelenOS key codes.

Currently only Usages used by Logitech UltraX keyboard are present. All other should result in 0.

Definition at line 49 of file keymap.c.


Generated on Thu Jun 2 07:45:56 2011 for HelenOS/USB by  doxygen 1.4.7