View | Details | Raw Unified | Return to bug 222646 | Differences between
and this patch

Collapse All | Expand All

(-)w/sys/dev/usb/input/ukbd.c (-1 / +27 lines)
Lines 158-163 struct ukbd_softc { Link Here
158
	struct hid_location sc_loc_numlock;
158
	struct hid_location sc_loc_numlock;
159
	struct hid_location sc_loc_capslock;
159
	struct hid_location sc_loc_capslock;
160
	struct hid_location sc_loc_scrolllock;
160
	struct hid_location sc_loc_scrolllock;
161
	struct hid_location sc_loc_consumer_ctl;
161
	struct usb_callout sc_callout;
162
	struct usb_callout sc_callout;
162
	struct ukbd_data sc_ndata;
163
	struct ukbd_data sc_ndata;
163
	struct ukbd_data sc_odata;
164
	struct ukbd_data sc_odata;
Lines 187-193 struct ukbd_softc { Link Here
187
#define	UKBD_FLAG_ATTACHED	0x00000010
188
#define	UKBD_FLAG_ATTACHED	0x00000010
188
#define	UKBD_FLAG_GONE		0x00000020
189
#define	UKBD_FLAG_GONE		0x00000020
189
190
190
#define	UKBD_FLAG_HID_MASK	0x003fffc0
191
#define	UKBD_FLAG_HID_MASK	0x007fffc0
191
#define	UKBD_FLAG_APPLE_EJECT	0x00000040
192
#define	UKBD_FLAG_APPLE_EJECT	0x00000040
192
#define	UKBD_FLAG_APPLE_FN	0x00000080
193
#define	UKBD_FLAG_APPLE_FN	0x00000080
193
#define	UKBD_FLAG_APPLE_SWAP	0x00000100
194
#define	UKBD_FLAG_APPLE_SWAP	0x00000100
Lines 203-208 struct ukbd_softc { Link Here
203
#define	UKBD_FLAG_NUMLOCK	0x00080000
204
#define	UKBD_FLAG_NUMLOCK	0x00080000
204
#define	UKBD_FLAG_CAPSLOCK	0x00100000
205
#define	UKBD_FLAG_CAPSLOCK	0x00100000
205
#define	UKBD_FLAG_SCROLLLOCK 	0x00200000
206
#define	UKBD_FLAG_SCROLLLOCK 	0x00200000
207
#define	UKBD_FLAG_CONSUMERCTL 	0x00400000
206
208
207
	int	sc_mode;		/* input mode (K_XLATE,K_RAW,K_CODE) */
209
	int	sc_mode;		/* input mode (K_XLATE,K_RAW,K_CODE) */
208
	int	sc_state;		/* shift/lock key state */
210
	int	sc_state;		/* shift/lock key state */
Lines 234-239 struct ukbd_softc { Link Here
234
	uint8_t sc_id_capslock;
236
	uint8_t sc_id_capslock;
235
	uint8_t sc_id_scrolllock;
237
	uint8_t sc_id_scrolllock;
236
	uint8_t sc_id_events;
238
	uint8_t sc_id_events;
239
	uint8_t sc_id_consumer_ctl;
237
	uint8_t sc_kbd_id;
240
	uint8_t sc_kbd_id;
238
241
239
	uint8_t sc_buffer[UKBD_BUFFER_SIZE];
242
	uint8_t sc_buffer[UKBD_BUFFER_SIZE];
Lines 834-839 ukbd_intr_callback(struct usb_xfer *xfer, usb_error_t error) Link Here
834
			}
837
			}
835
		}
838
		}
836
839
840
		if ((sc->sc_flags & UKBD_FLAG_CONSUMERCTL) &&
841
		    (id == sc->sc_id_consumer_ctl)) {
842
			i = sc->sc_loc_consumer_ctl.count;
843
			if (i > UKBD_NKEYCODE)
844
				i = UKBD_NKEYCODE;
845
			if (i > len)
846
				i = len;
847
			while (i--) {
848
				sc->sc_ndata.keycode[i] = hid_consumerctl_to_scancode(
849
					hid_get_data(sc->sc_buffer + i, len - i,
850
					    &sc->sc_loc_consumer_ctl));
851
			}
852
		}
853
837
		ukbd_interrupt(sc);
854
		ukbd_interrupt(sc);
838
855
839
		if (ukbd_any_key_pressed(sc) != 0) {
856
		if (ukbd_any_key_pressed(sc) != 0) {
Lines 1198-1203 ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len) Link Here
1198
			sc->sc_flags |= UKBD_FLAG_SCROLLLOCK;
1215
			sc->sc_flags |= UKBD_FLAG_SCROLLLOCK;
1199
		DPRINTFN(1, "Found keyboard scrolllock\n");
1216
		DPRINTFN(1, "Found keyboard scrolllock\n");
1200
	}
1217
	}
1218
1219
	/* figure out consumer control (multimedia keys) on keyboard */
1220
	if (hid_locate(ptr, len,
1221
	    HID_USAGE2(HUP_CONSUMER, 0x01),
1222
	    hid_input, 0, &sc->sc_loc_consumer_ctl, &flags,
1223
	    &sc->sc_id_consumer_ctl)) {
1224
		sc->sc_flags |= UKBD_FLAG_CONSUMERCTL;
1225
		DPRINTFN(1, "Found keyboard consumer control\n");
1226
	}
1201
}
1227
}
1202
1228
1203
static int
1229
static int
(-)w/sys/dev/usb/usbhid.h (+19 lines)
Lines 269-273 usb_error_t usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx, Link Here
269
int32_t	hid_item_resolution(struct hid_item *hi);
269
int32_t	hid_item_resolution(struct hid_item *hi);
270
int	hid_is_mouse(const void *d_ptr, uint16_t d_len);
270
int	hid_is_mouse(const void *d_ptr, uint16_t d_len);
271
int	hid_is_keyboard(const void *d_ptr, uint16_t d_len);
271
int	hid_is_keyboard(const void *d_ptr, uint16_t d_len);
272
273
/* Converts a HID Consumer Control action into a keyboard scancode */
274
static inline uint8_t
275
hid_consumerctl_to_scancode(int data) {
276
	switch (data) {
277
	case 0xcd: return 0xe8; // Play/Pause
278
	case 0xb7: return 0xe9; // Stop (Music)
279
	case 0xb6: return 0xea; // Previous Song
280
	case 0xb5: return 0xeb; // Next Song
281
	case 0xe9: return 0xed; // Volume Up
282
	case 0xea: return 0xee; // Volume Down
283
	case 0xe2: return 0xef; // Mute
284
	case 0x224: return 0xf1; // Back
285
	case 0x225: return 0xf2; // Forward
286
	case 0x226: return 0xf3; // Stop (Browser)
287
	default: return 0;
288
	}
289
}
290
272
#endif					/* _KERNEL */
291
#endif					/* _KERNEL */
273
#endif					/* _USB_HID_H_ */
292
#endif					/* _USB_HID_H_ */

Return to bug 222646