Class: ProconBypassMan::DeviceConnection::OutputReportSubCommandTable
- Inherits:
-
Object
- Object
- ProconBypassMan::DeviceConnection::OutputReportSubCommandTable
show all
- Defined in:
- lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb
Defined Under Namespace
Classes: HIDSubCommandResponse
Constant Summary
collapse
- IGNORE_SUB_COMMANDS =
{
"48-01" => true,
"04-00" => true,
"10-28" => true, }
- SPECIAL_SUB_COMMANDS =
[
"01",
"02",
"03",
"30",
"38", "40",
"48",
]
- EXPECTED_SUB_COMMANDS =
[
"01-04",
"02-",
"04-00",
"08-00",
"10-00",
"10-50",
"10-80",
"10-98",
"10-10",
"30-",
"40-",
"48-", ]
Instance Method Summary
collapse
Constructor Details
Returns a new instance of OutputReportSubCommandTable.
55
56
57
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 55
def initialize
@table = {}
end
|
Instance Method Details
#completed? ⇒ Boolean
127
128
129
130
131
132
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 127
def completed?
EXPECTED_SUB_COMMANDS.all? do |key|
sub_command, sub_command_arg = key.split("-")
has_value?(sub_command: sub_command, sub_command_arg: sub_command_arg)
end
end
|
#has_key?(sub_command:, sub_command_arg:) ⇒ Boolean
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 85
def has_key?(sub_command: , sub_command_arg: )
if IGNORE_SUB_COMMANDS["#{sub_command}-#{sub_command_arg}"]
return true
end
case sub_command
when *SPECIAL_SUB_COMMANDS
@table.key?(sub_command)
else
response = HIDSubCommandResponse.new(sub_command: sub_command, sub_command_arg: sub_command_arg)
@table.key?(response.sub_command_with_arg)
end
end
|
#has_unreceived_command? ⇒ Boolean
112
113
114
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 112
def has_unreceived_command?
!@table.values.all?(&:itself)
end
|
#has_value?(sub_command:, sub_command_arg:) ⇒ Boolean
102
103
104
105
106
107
108
109
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 102
def has_value?(sub_command: , sub_command_arg: )
if IGNORE_SUB_COMMANDS["#{sub_command}-#{sub_command_arg}"]
return true
end
response = HIDSubCommandResponse.new(sub_command: sub_command, sub_command_arg: sub_command_arg)
!!@table[response.sub_command_with_arg]
end
|
#mark_as_receive(sub_command:, sub_command_arg:) ⇒ void
This method returns an undefined value.
75
76
77
78
79
80
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 75
def mark_as_receive(sub_command: , sub_command_arg: )
response = HIDSubCommandResponse.new(sub_command: sub_command, sub_command_arg: sub_command_arg)
if @table.key?(response.sub_command_with_arg)
@table[response.sub_command_with_arg] = true
end
end
|
#mask_as_send(sub_command:, sub_command_arg:) ⇒ void
This method returns an undefined value.
62
63
64
65
66
67
68
69
70
|
# File 'lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb', line 62
def mask_as_send(sub_command: , sub_command_arg: )
case sub_command
when *SPECIAL_SUB_COMMANDS
@table[sub_command] = false
else
response = HIDSubCommandResponse.new(sub_command: sub_command, sub_command_arg: sub_command_arg)
@table[response.sub_command_with_arg] = false
end
end
|
#unreceived_sub_command_with_arg ⇒ String, NilClass