def initialize( joystick_id, hat, direction )
unless joystick_id.kind_of?(Fixnum) and joystick_id >= 0
raise ArgumentError, "joystick_id must be an integer >= 0"
end
@joystick_id = joystick_id
unless hat.kind_of?(Fixnum) and hat >= 0
raise ArgumentError, "hat must be an integer >= 0"
end
@hat = hat
unless @@direction_map.keys.include? direction
raise ArgumentError,
"invalid direction '%s'. "%[direction.inspect] +\
"Check the docs for valid directions."
end
@direction = direction
@horizontal, @vertical = @@direction_map[direction]
end