#ifndef JOYHELP_H_INCLUDED
#define JOYHELP_H_INCLUDED

// needed for HUG_SLIDER, used below
#include "usb.h"

// number of entries in supported_axes_usage[] - callers indexing it by a
// device-supplied HID usage code must check the index against this first
#define SUPPORTED_AXES_USAGE_COUNT (HUG_SLIDER + 1)

extern const uint32_t supported_axes_usage[SUPPORTED_AXES_USAGE_COUNT];
extern const char *axes_names[];

struct hid_item *get_axis_item_by_type(uint32_t slot, uint32_t type);
int stick_has_axis_type(struct joydata_struct *j, uint32_t type);
struct joydata_struct *get_stick(uint32_t id);
struct axisdata_struct *get_stick_axis(struct joydata_struct *j, uint32_t type);
struct joydata_struct *get_stick(uint32_t id);

// this was static
struct hid_item *itemdup(struct hid_item *s);

uint32_t next_available_joystick_slot(void);
void clean_joystick_data(void);
void clean_joystick_data_item(uint32_t i);

int32_t round_up_down(float n);

// Shared slot validation - used by both the *USBJoystick_* command layer
// (c.cmdmap, c.cmdshow) and the native SWI layer (c.joyapi, c.cmdmap's
// swi_joystick_* wrappers) so the two never drift apart. "slot" = a
// device's own internal id (0..JOY_MAX-1), never to be confused with an
// axis/button index within a device.
_kernel_oserror *validate_joystick_slot(const char *caller, uint32_t slot);
_kernel_oserror *validate_joystick_slot_active(const char *caller, uint32_t slot);

#endif
