-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathusb_gamepad_reader.v
67 lines (56 loc) · 1.54 KB
/
usb_gamepad_reader.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
`default_nettype none
module usb_gamepad_reader #(
parameter GAMEPAD = "BUFFALO"
) (
input clk,
input reset,
input usb_dif,
inout usb_dp,
inout usb_dn,
output [11:0] usb_btn
);
localparam C_report_bytes = 8;
wire [C_report_bytes*8-1:0] S_report;
wire S_report_valid;
wire [7:0] usb_buttons;
usbh_host_hid #(
.C_usb_speed(0),
.C_report_length(C_report_bytes),
.C_report_length_strict(0)
) us2_hid_host (
.clk(clk),
.bus_reset(reset),
.usb_dif(usb_dif),
.usb_dp(usb_dp),
.usb_dn(usb_dn),
.hid_report(S_report),
.hid_valid(S_report_valid)
);
generate
if (GAMEPAD == "BUFFALO") begin
usbh_report_decoder_buffalo usbh_report_decoder(
.i_clk(clk),
.i_report(S_report),
.i_report_valid(S_report_valid),
.o_btn(usb_btn)
);
end
if (GAMEPAD == "KEYPAD") begin
usbh_report_decoder_keypad usbh_report_decoder(
.i_clk(clk),
.i_report(S_report),
.i_report_valid(S_report_valid),
.o_btn(usb_btn)
);
end
if (GAMEPAD == "WINGMAN") begin
usbh_report_decoder_wingman usbh_report_decoder(
.i_clk(clk),
.i_report(S_report),
.i_report_valid(S_report_valid),
.o_btn(usb_btn)
);
end
// (...more gamepads)
endgenerate
endmodule