Skip to content

Instantly share code, notes, and snippets.

@tpimh
Last active January 19, 2016 18:33
Show Gist options
  • Save tpimh/16aa19fdeb441e66ad9a to your computer and use it in GitHub Desktop.
Save tpimh/16aa19fdeb441e66ad9a to your computer and use it in GitHub Desktop.
[CCode (lower_case_cprefix = "Gamepad_", cheader_filename = "gamepad/Gamepad.h")]
namespace Gamepad {
[CCode (cname = "struct Gamepad_device", free_function = "")]
[Compact]
public class Device {
[CCode (cname = "deviceID")]
public uint device_id;
public string description;
[CCode (cname = "vendorID")]
public int vendor_id;
[CCode (cname = "productID")]
public int product_id;
[CCode (cname = "numAxes")]
public uint num_axes;
[CCode (cname = "numButtons")]
public uint num_buttons;
[CCode (cname = "axisStates", array_length_cname = "numAxes", array_length_type = "uint")]
public float[] axis_states;
[CCode (cname = "buttonStates", array_length_cname = "numButtons", array_length_type = "uint")]
public bool[] button_states;
}
public static void init();
public static void shutdown();
[CCode (cname = "Gamepad_numDevices")]
public static uint num_devices();
[CCode (cname = "Gamepad_deviceAtIndex")]
public Device device_at_index(uint device_index);
[CCode (cname = "Gamepad_detectDevices")]
public void detect_devices();
[CCode (cname = "Gamepad_processEvents")]
public void process_events();
public delegate void DeviceAttachFunc(Device device);
public delegate void DeviceRemoveFunc(Device device);
public delegate void ButtonDownFunc(Device device, uint button_id, double timestamp);
public delegate void ButtonUpFunc(Device device, uint button_id, double timestamp);
public delegate void AxisMoveFunc(Device device, uint axis_id, float value, float last_value, double timestamp);
[CCode (cname = "Gamepad_deviceAttachFunc")]
public void set_device_attach_func(DeviceAttachFunc d);
[CCode (cname = "Gamepad_deviceRemoveFunc")]
public void set_device_remove_func(DeviceRemoveFunc d);
[CCode (cname = "Gamepad_buttonDownFunc")]
public void set_button_down_func(ButtonDownFunc d);
[CCode (cname = "Gamepad_buttonUpFunc")]
public void set_button_up_func(ButtonUpFunc d);
[CCode (cname = "Gamepad_axisMoveFunc")]
public void set_axis_move_func(AxisMoveFunc d);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment