usb_template_kbd.c (246122) | usb_template_kbd.c (246123) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_kbd.c 246122 2013-01-30 15:26:04Z hselasky $ */ | 1/* $FreeBSD: head/sys/dev/usb/template/usb_template_kbd.c 246123 2013-01-30 15:46:26Z hselasky $ */ |
2/*- 3 * Copyright (c) 2010 Hans Petter Selasky. 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 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 37 unchanged lines hidden (view full) --- 47#include <sys/sx.h> 48#include <sys/unistd.h> 49#include <sys/callout.h> 50#include <sys/malloc.h> 51#include <sys/priv.h> 52 53#include <dev/usb/usb.h> 54#include <dev/usb/usbdi.h> | 2/*- 3 * Copyright (c) 2010 Hans Petter Selasky. 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 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 37 unchanged lines hidden (view full) --- 47#include <sys/sx.h> 48#include <sys/unistd.h> 49#include <sys/callout.h> 50#include <sys/malloc.h> 51#include <sys/priv.h> 52 53#include <dev/usb/usb.h> 54#include <dev/usb/usbdi.h> |
55#include <dev/usb/usb_core.h> |
|
55#include <dev/usb/usb_cdc.h> 56 57#include <dev/usb/template/usb_template.h> 58#endif /* USB_GLOBAL_INCLUDE_FILE */ 59 60enum { 61 INDEX_LANG, 62 INDEX_KEYBOARD, 63 INDEX_PRODUCT, 64 INDEX_MAX, 65}; 66 | 56#include <dev/usb/usb_cdc.h> 57 58#include <dev/usb/template/usb_template.h> 59#endif /* USB_GLOBAL_INCLUDE_FILE */ 60 61enum { 62 INDEX_LANG, 63 INDEX_KEYBOARD, 64 INDEX_PRODUCT, 65 INDEX_MAX, 66}; 67 |
67#define STRING_LANG \ 68 0x09, 0x04, /* American English */ 69 | |
70#define STRING_PRODUCT \ 71 'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \ 72 'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \ 73 'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, 74 75#define STRING_KEYBOARD \ 76 'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \ 77 'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0, 78 79/* make the real string descriptors */ 80 | 68#define STRING_PRODUCT \ 69 'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \ 70 'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \ 71 'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, 72 73#define STRING_KEYBOARD \ 74 'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \ 75 'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0, 76 77/* make the real string descriptors */ 78 |
81USB_MAKE_STRING_DESC(STRING_LANG, string_lang); | |
82USB_MAKE_STRING_DESC(STRING_KEYBOARD, string_keyboard); 83USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product); 84 85/* prototypes */ 86 87static const struct usb_temp_packet_size keyboard_intr_mps = { 88 .mps[USB_SPEED_LOW] = 16, 89 .mps[USB_SPEED_FULL] = 16, --- 113 unchanged lines hidden (view full) --- 203 * Return values: 204 * NULL: Failure. No such string. 205 * Else: Success. Pointer to string descriptor is returned. 206 *------------------------------------------------------------------------*/ 207static const void * 208keyboard_get_string_desc(uint16_t lang_id, uint8_t string_index) 209{ 210 static const void *ptr[INDEX_MAX] = { | 79USB_MAKE_STRING_DESC(STRING_KEYBOARD, string_keyboard); 80USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product); 81 82/* prototypes */ 83 84static const struct usb_temp_packet_size keyboard_intr_mps = { 85 .mps[USB_SPEED_LOW] = 16, 86 .mps[USB_SPEED_FULL] = 16, --- 113 unchanged lines hidden (view full) --- 200 * Return values: 201 * NULL: Failure. No such string. 202 * Else: Success. Pointer to string descriptor is returned. 203 *------------------------------------------------------------------------*/ 204static const void * 205keyboard_get_string_desc(uint16_t lang_id, uint8_t string_index) 206{ 207 static const void *ptr[INDEX_MAX] = { |
211 [INDEX_LANG] = &string_lang, | 208 [INDEX_LANG] = &usb_string_lang_en, |
212 [INDEX_KEYBOARD] = &string_keyboard, 213 [INDEX_PRODUCT] = &string_product, 214 }; 215 216 if (string_index == 0) { | 209 [INDEX_KEYBOARD] = &string_keyboard, 210 [INDEX_PRODUCT] = &string_product, 211 }; 212 213 if (string_index == 0) { |
217 return (&string_lang); | 214 return (&usb_string_lang_en); |
218 } 219 if (lang_id != 0x0409) { 220 return (NULL); 221 } 222 if (string_index < INDEX_MAX) { 223 return (ptr[string_index]); 224 } 225 return (NULL); 226} | 215 } 216 if (lang_id != 0x0409) { 217 return (NULL); 218 } 219 if (string_index < INDEX_MAX) { 220 return (ptr[string_index]); 221 } 222 return (NULL); 223} |