libstratcom  1.1.0
A cross-platform library for interfacing with the Microsoft SideWinder Strategic Commander
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Pages
Data Structures | Macros | Typedefs | Enumerations
stratcom.h File Reference

Main Header File. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  stratcom_input_state
 Combined state of all buttons and axes on the device. More...
 
struct  stratcom_input_event_button
 Button event. More...
 
struct  stratcom_input_event_slider
 Slider event. More...
 
struct  stratcom_input_event_axis
 Axis event. More...
 
struct  stratcom_input_event
 Input event structure. More...
 
union  stratcom_input_event::event_desc_T
 The input event union. More...
 

Typedefs

typedef struct stratcom_device_ stratcom_device
 Opaque device structure. More...
 

Enumerations

enum  stratcom_return { STRATCOM_RET_SUCCESS = 0, STRATCOM_RET_ERROR = (-1), STRATCOM_RET_NO_DATA = (-2) }
 Return type. More...
 
Identifiers.

Identifiers are types used for identifying certain parts of the device, such as buttons or LEDs.

enum  stratcom_button {
  STRATCOM_BUTTON_1 = 0x0001, STRATCOM_BUTTON_2 = 0x0002, STRATCOM_BUTTON_3 = 0x0004, STRATCOM_BUTTON_4 = 0x0008,
  STRATCOM_BUTTON_5 = 0x0010, STRATCOM_BUTTON_6 = 0x0020, STRATCOM_BUTTON_PLUS = 0x0040, STRATCOM_BUTTON_MINUS = 0x0080,
  STRATCOM_BUTTON_SHIFT1 = 0x0100, STRATCOM_BUTTON_SHIFT2 = 0x0200, STRATCOM_BUTTON_SHIFT3 = 0x0400, STRATCOM_BUTTON_REC = 0x0800,
  STRATCOM_BUTTON_NONE = 0x0
}
 Button Identifiers. More...
 
enum  stratcom_button_led {
  STRATCOM_LEDBUTTON_1 = 0x0001, STRATCOM_LEDBUTTON_2 = 0x0004, STRATCOM_LEDBUTTON_3 = 0x0010, STRATCOM_LEDBUTTON_4 = 0x0040,
  STRATCOM_LEDBUTTON_5 = 0x0100, STRATCOM_LEDBUTTON_6 = 0x0400, STRATCOM_LEDBUTTON_REC = 0x1000, STRATCOM_LEDBUTTON_ALL = 0x1555,
  STRATCOM_LEDBUTTON_NONE = 0x0
}
 Button LED Identifiers. More...
 
enum  stratcom_axis { STRATCOM_AXIS_X, STRATCOM_AXIS_Y, STRATCOM_AXIS_Z }
 Axis Identifier. More...
 

Functions

Initialization and Shutdown.
LIBSTRATCOM_API stratcom_return stratcom_init ()
 Initialize the libstratcom library. More...
 
LIBSTRATCOM_API void stratcom_shutdown ()
 Finalize the libstratcom library. More...
 
LIBSTRATCOM_API stratcom_devicestratcom_open_device ()
 Open a Strategic Commander device for use with the library. More...
 
LIBSTRATCOM_API stratcom_devicestratcom_open_device_on_path (char const *device_path)
 Open a Strategic Commander device on a certain HID device path. More...
 
LIBSTRATCOM_API void stratcom_close_device (stratcom_device *device)
 Close a device. More...
 
Button LEDs.

Use these functions to interact with the LEDs on the device.

Note that the stratcom_device object maintains a cached state of which LEDs are currently lit and what the blink intervals are. This is referred to as the internal state. This is in contrast to the physical state which is the actual state of the Strategic Commander device.

It is possible for the internal and the physical state to diverge, for example if a function call fails to execute successfully or if an internal state change is not flushed to the device. The user can recover from this divergence by either attempting to write the internal state to the device, or by reading the physical state from the device, which will overwrite the internal state.

LIBSTRATCOM_API stratcom_led_state stratcom_get_button_led_state (stratcom_device *device, stratcom_button_led led)
 Retrieve the current state of a specific LED. More...
 
LIBSTRATCOM_API stratcom_return stratcom_set_button_led_state (stratcom_device *device, stratcom_button_led led, stratcom_led_state state)
 Set the state of a specific LED. More...
 
LIBSTRATCOM_API void stratcom_set_button_led_state_without_flushing (stratcom_device *device, stratcom_button_led led, stratcom_led_state state)
 Set the state of a specific LED in the internal state. More...
 
LIBSTRATCOM_API stratcom_return stratcom_flush_button_led_state (stratcom_device *device)
 Flush the current internal LED state to the physical device. More...
 
LIBSTRATCOM_API int stratcom_led_state_has_unflushed_changes (stratcom_device *device)
 Check whether the internal LED state contains unflushed changes. More...
 
LIBSTRATCOM_API void stratcom_get_led_blink_interval (stratcom_device *device, uint8_t *out_on_time, uint8_t *out_off_time)
 Retrieve the current blink intervals from the internal state. More...
 
LIBSTRATCOM_API stratcom_return stratcom_set_led_blink_interval (stratcom_device *device, uint8_t on_time, uint8_t off_time)
 Set the blink intervals for blinking LEDs. More...
 
LIBSTRATCOM_API stratcom_return stratcom_read_button_led_state (stratcom_device *device)
 Read the button led state from the physical device. More...
 
LIBSTRATCOM_API stratcom_return stratcom_read_led_blink_intervals (stratcom_device *device)
 Read the led blink intervals from the physical device. More...
 
LIBSTRATCOM_API stratcom_button_led stratcom_get_led_for_button (stratcom_button button)
 Obtain the matching LED for a given button. More...
 
Device Input.

Use these functions to obtain the input state of the device, such as which buttons are currently pressed.

Input state is read from the Strategic Commander by reading input reports. Each action on the physical device (like pressing a button, or moving the axis or slider) will cause an input report to be generated. In case of no input, the read functions may block. Input reports that are not read immediately will be buffered by the HID layer and returned upon the next read. Thus, multiple read operations might be required to arrive at the latest input state.

A return code of STRATCOM_RET_ERROR by one of these functions usually indicates that the physical device was unplugged by the user.

While these functions allow to query the current state of the device (that is, answer questions like "Is Button 1 currently pressed?"), they do not generate input events (that is, answer questions like "Which Button has been pressed by the user?"). If you are more interested in the second kind of question, be sure to check out the section on Input Events below.

LIBSTRATCOM_API stratcom_return stratcom_read_input (stratcom_device *device)
 Wait for a new input report and read it from the physical device to update the internal input state. More...
 
LIBSTRATCOM_API stratcom_return stratcom_read_input_with_timeout (stratcom_device *device, int timeout_milliseconds)
 Wait for a new input report and read it from the physical device to update the internal input state. More...
 
LIBSTRATCOM_API stratcom_return stratcom_read_input_non_blocking (stratcom_device *device)
 Read a new input report from the physical device to update the internal input state, if available. More...
 
LIBSTRATCOM_API
stratcom_input_state 
stratcom_get_input_state (stratcom_device *device)
 Retrieve a copy of the internal input state. More...
 
LIBSTRATCOM_API int stratcom_is_button_pressed (stratcom_device *device, stratcom_button button)
 Check the state of a single button in the internal input state. More...
 
LIBSTRATCOM_API stratcom_axis_word stratcom_get_axis_value (stratcom_device *device, stratcom_axis axis)
 Get the value of a particular axis in the internal input state. More...
 
LIBSTRATCOM_API
stratcom_slider_state 
stratcom_get_slider_state (stratcom_device *device)
 Get the position of the slider in the internal input state. More...
 
Iterating Button Identifiers.

Use these functions if you need to iterate over all the buttons in a loop.

LIBSTRATCOM_API stratcom_button stratcom_iterate_buttons_range_begin ()
 The beginning of the button range.
 
LIBSTRATCOM_API stratcom_button stratcom_iterate_buttons_range_end ()
 The end of the button range.
 
LIBSTRATCOM_API stratcom_button stratcom_iterate_buttons_range_increment (stratcom_button button)
 Increment a button range iterator.
 

State.

State types are used for modeling the current state of a certain part of the device for input, such as whether button is pressed or where an axis is positioned.

enum  stratcom_led_state { STRATCOM_LED_ON, STRATCOM_LED_OFF, STRATCOM_LED_BLINK }
 LED State. More...
 
enum  stratcom_slider_state { STRATCOM_SLIDER_UNKNOWN = 0, STRATCOM_SLIDER_1, STRATCOM_SLIDER_2, STRATCOM_SLIDER_3 }
 Slider State. More...
 
typedef uint16_t stratcom_button_word
 Button Word. More...
 
typedef int16_t stratcom_axis_word
 Axis Word. More...
 

Input Events.

Use these functions to generate a list of input events from two input states retrieved from stratcom_get_input_state().

Instead of comparing input states manually, these functions generate a linked list of stratcom_input_event values, representing the changes between the two input states.

enum  stratcom_input_event_type { STRATCOM_INPUT_EVENT_BUTTON, STRATCOM_INPUT_EVENT_SLIDER, STRATCOM_INPUT_EVENT_AXIS }
 Different input types that can form a stratcom_input_event. More...
 
LIBSTRATCOM_API
stratcom_input_event
stratcom_create_input_events_from_states (stratcom_input_state *old_state, stratcom_input_state *new_state)
 Generate a linked list of input events, describing the changes between two input states. More...
 
LIBSTRATCOM_API
stratcom_input_event
stratcom_append_input_events_from_states (stratcom_input_event *events, stratcom_input_state *old_state, stratcom_input_state *new_state)
 Append input events created from two input states to an existing list. More...
 
LIBSTRATCOM_API void stratcom_free_input_events (stratcom_input_event *events)
 Free a list of input events. More...
 

Detailed Description

Main Header File.

libstratcom - A Library for interacting with Microsoft SideWinder Strategic Commander

Author
Andreas Weis der_g.nosp@m.hulb.nosp@m.us@gh.nosp@m.ulbu.nosp@m.s-inc.nosp@m..de

Typedef Documentation

typedef int16_t stratcom_axis_word

Axis Word.

Represents the state of a single axis. Values range from -512 to +511 where 0 is the axis center.

typedef uint16_t stratcom_button_word

Button Word.

A bitwise combination of stratcom_button flags indicating the state of all buttons on the device. If a bit is set, it means that the corresponding button is pressed.

typedef struct stratcom_device_ stratcom_device

Opaque device structure.

Maintains the internal state for interacting with the device.

Enumeration Type Documentation

Axis Identifier.

This type is used for querying the state of one of the three device axes.

See also
stratcom_get_axis_value()
Enumerator
STRATCOM_AXIS_X 

Horizontal X-axis.

STRATCOM_AXIS_Y 

Vertical Y-axis.

STRATCOM_AXIS_Z 

Rotational Z-axis.

Button Identifiers.

This type is used for querying the state of a button. Iterating over all button identifiers can be achieved with the stratcom_iterate_buttons_range* functions.

See also
stratcom_is_button_pressed(), stratcom_iterate_buttons_range_begin(), stratcom_iterate_buttons_range_end(), stratcom_iterate_buttons_range_increment()
Enumerator
STRATCOM_BUTTON_1 

The button labeled '1'.

STRATCOM_BUTTON_2 

The button labeled '2'.

STRATCOM_BUTTON_3 

The button labeled '3'.

STRATCOM_BUTTON_4 

The button labeled '4'.

STRATCOM_BUTTON_5 

The button labeled '5'.

STRATCOM_BUTTON_6 

The button labeled '6'.

STRATCOM_BUTTON_PLUS 

The button labeled '+'.

STRATCOM_BUTTON_MINUS 

The button labeled '-'.

STRATCOM_BUTTON_SHIFT1 

The top shift button.

STRATCOM_BUTTON_SHIFT2 

The middle shift button.

STRATCOM_BUTTON_SHIFT3 

The lower shift button.

STRATCOM_BUTTON_REC 

The button labeled 'REC'.

STRATCOM_BUTTON_NONE 

Refers to no button.

Button LED Identifiers.

This type is used for setting or querying the state of the button LEDs. You can obtain the matching LED identifier from a given stratcom_button by calling stratcom_get_led_for_button().

See also
stratcom_get_button_led_state(), stratcom_set_button_led_state(), stratcom_get_led_for_button()
Enumerator
STRATCOM_LEDBUTTON_1 

The LED of the button labeled '1'.

STRATCOM_LEDBUTTON_2 

The LED of the button labeled '2'.

STRATCOM_LEDBUTTON_3 

The LED of the button labeled '3'.

STRATCOM_LEDBUTTON_4 

The LED of the button labeled '4'.

STRATCOM_LEDBUTTON_5 

The LED of the button labeled '5'.

STRATCOM_LEDBUTTON_6 

The LED of the button labeled '6'.

STRATCOM_LEDBUTTON_REC 

The LED of the button labeled 'REC'.

STRATCOM_LEDBUTTON_ALL 

Addresses all LEDs at once.

STRATCOM_LEDBUTTON_NONE 

Addresses nothing.

Different input types that can form a stratcom_input_event.

Enumerator
STRATCOM_INPUT_EVENT_BUTTON 

Button event.

See also
stratcom_input_event_button
STRATCOM_INPUT_EVENT_SLIDER 

Slider event.

See also
stratcom_input_event_slider
STRATCOM_INPUT_EVENT_AXIS 

Axis event.

See also
stratcom_input_event_axis

LED State.

Enumerator
STRATCOM_LED_ON 

LED is constantly lit.

STRATCOM_LED_OFF 

LED is constantly dark.

STRATCOM_LED_BLINK 

LED is blinking.

Return type.

This return type is used on functions that can fail to indicate runtime errors.

Enumerator
STRATCOM_RET_SUCCESS 

The function completed successfully.

STRATCOM_RET_ERROR 

An error occured while executing.

STRATCOM_RET_NO_DATA 

A read operation returned without reading any new data.

Slider State.

The slider may rest in one of three positions. For cases where the state of the slider cannot be determined we use STRATCOM_SLIDER_UNKNOWN.

Enumerator
STRATCOM_SLIDER_UNKNOWN 

Slider position is unknown.

STRATCOM_SLIDER_1 

Slider set to the position marked with one circle.

STRATCOM_SLIDER_2 

Slider set to the position marked with two circles.

STRATCOM_SLIDER_3 

Slider set to the position marked with three circles.

Function Documentation

LIBSTRATCOM_API stratcom_input_event* stratcom_append_input_events_from_states ( stratcom_input_event events,
stratcom_input_state old_state,
stratcom_input_state new_state 
)

Append input events created from two input states to an existing list.

Parameters
[in,out]eventsA non-empty list of input events, retrieved from stratcom_create_input_events_from_states().
[in]old_stateAn older input state.
[in]new_stateA newer input state.
Returns
Pointer to the first new element in the input list. You do not have to free those elements seperately. Simply call stratcom_free_input_events() on the original events pointer to free the whole list.
See also
stratcom_create_input_events_from_states(), stratcom_free_input_events(), stratcom_get_input_state()
LIBSTRATCOM_API void stratcom_close_device ( stratcom_device device)

Close a device.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
See also
stratcom_open_device(), stratcom_open_device_on_path()
LIBSTRATCOM_API stratcom_input_event* stratcom_create_input_events_from_states ( stratcom_input_state old_state,
stratcom_input_state new_state 
)

Generate a linked list of input events, describing the changes between two input states.

Parameters
[in]old_stateAn older input state.
[in]new_stateA newer input state.
Returns
Pointer to a linked list of input events. This must be freed by calling stratcom_free_input_events().
See also
stratcom_free_input_events(), stratcom_get_input_state()
LIBSTRATCOM_API stratcom_return stratcom_flush_button_led_state ( stratcom_device device)

Flush the current internal LED state to the physical device.

This will send a feature report to the device to update the state of the button LEDs. In case of successful execution, all button LEDs will light up according to the internal state.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_set_button_led_state_without_flushing(), stratcom_led_state_has_unflushed_changes()
LIBSTRATCOM_API void stratcom_free_input_events ( stratcom_input_event events)

Free a list of input events.

Parameters
[in]eventsAn input event list obtained from stratcom_create_input_events_from_states().
See also
stratcom_create_input_events_from_states()
LIBSTRATCOM_API stratcom_axis_word stratcom_get_axis_value ( stratcom_device device,
stratcom_axis  axis 
)

Get the value of a particular axis in the internal input state.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]axisThe axis which is to be queried.
Returns
The current position for the axis stored in the internal input state.
LIBSTRATCOM_API stratcom_led_state stratcom_get_button_led_state ( stratcom_device device,
stratcom_button_led  led 
)

Retrieve the current state of a specific LED.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]ledThe button LED which is to be queried.
Returns
State of the queried LED.
Note
The state returned by this function represents the internal state of the stratcom_device object, which might diverge from the actual state of the physical device (for example after setting the led state without flushing the changes to the device). To force the internal state to synchronize with the physical device, call either stratcom_flush_button_led_state() or stratcom_read_button_led_state().
See also
stratcom_set_button_led_state()
LIBSTRATCOM_API stratcom_input_state stratcom_get_input_state ( stratcom_device device)

Retrieve a copy of the internal input state.

The input state contains state information for all the buttons, axes and sliders of the device. This function does not read any data from the physical device. Use stratcom_read_input() for that.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
A copy of the internal input state.
Note
Usually you do not want to inspect the input state directly. Instead, you can generate a list of input events by calling stratcom_create_input_events_from_states(), which are more convenient to process.
See also
stratcom_read_input(), stratcom_create_input_events_from_states()
LIBSTRATCOM_API void stratcom_get_led_blink_interval ( stratcom_device device,
uint8_t *  out_on_time,
uint8_t *  out_off_time 
)

Retrieve the current blink intervals from the internal state.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[out]out_on_timeTime that the LED is lit when blinking.
[out]out_off_timeTime that the LED is dark when blinking.
See also
stratcom_set_led_blink_interval(), stratcom_read_led_blink_intervals()
LIBSTRATCOM_API stratcom_button_led stratcom_get_led_for_button ( stratcom_button  button)

Obtain the matching LED for a given button.

Parameters
[in]buttonButton of which to retrieve the LED.
Returns
The corresponding LED of the button. STRATCOM_LEDBUTTON_NONE if the button does not have a LED.
LIBSTRATCOM_API stratcom_slider_state stratcom_get_slider_state ( stratcom_device device)

Get the position of the slider in the internal input state.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
The current position of the slider in the internal input state.
LIBSTRATCOM_API stratcom_return stratcom_init ( )

Initialize the libstratcom library.

Call this function once per process before invoking any other function of the library. Call stratcom_shutdown() before exiting your program to free the static data allocated by this function.

Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_shutdown()
LIBSTRATCOM_API int stratcom_is_button_pressed ( stratcom_device device,
stratcom_button  button 
)

Check the state of a single button in the internal input state.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]buttonThe button which is to be queried.
Returns
1 if the button is marked as pressed in the internal input state, 0 otherwise.
See also
stratcom_read_input()
LIBSTRATCOM_API int stratcom_led_state_has_unflushed_changes ( stratcom_device device)

Check whether the internal LED state contains unflushed changes.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
1 if the internal state contains unflushed changes, 0 otherwise.
Note
This function does not query the physical device for its state. It simply accounts for changes made through stratcom_set_button_led_state_without_flushing() that have not been flushed.
See also
stratcom_set_button_led_state_without_flushing(), stratcom_flush_button_led_state()
LIBSTRATCOM_API stratcom_device* stratcom_open_device ( )

Open a Strategic Commander device for use with the library.

This function will automatically attempt to open the first device with matching HID vendor and product ids. Usually this just works. In case you need more control over which device is opened (for instance when having more than one device attached to the same machine), use stratcom_open_device_on_path() instead.

Returns
Pointer to a device struct on success, which can be freed by calling stratcom_close_device(). NULL in case of error.
Note
The Strategic Commander is identified as the first device with an HID Vendor Id of 0x045e and a Product Id of 0x0033.
The internal state of the LEDs and LED blink intervals are set to match the state of the physical device. The input state however is left uninitialized and must be queried manually by calling one of the stratcom_read_input* functions.
See also
stratcom_open_device_on_path(), stratcom_close_device()
LIBSTRATCOM_API stratcom_device* stratcom_open_device_on_path ( char const *  device_path)

Open a Strategic Commander device on a certain HID device path.

Parameters
[in]device_pathThe HID path of the device to open.
Returns
Pointer to a device struct on success, which can be freed by calling stratcom_close_device(). NULL in case of error.
Note
The internal state of the LEDs and LED blink intervals are set to match the state of the physical device. The input state however is left uninitialized and must be queried manually by calling one of the stratcom_read_input* functions.
See also
stratcom_close_device()
LIBSTRATCOM_API stratcom_return stratcom_read_button_led_state ( stratcom_device device)

Read the button led state from the physical device.

Upon successful execution, this function will overwrite the internal led state with the values obtained from the physical device. This function will cause a feature report to be read from the device.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_get_button_led_state()
LIBSTRATCOM_API stratcom_return stratcom_read_input ( stratcom_device device)

Wait for a new input report and read it from the physical device to update the internal input state.

This function will block until the user performs an action on the Strategic Commander that generates an input event. Upon returning, the internal input state will have been updated according to that input report.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_read_input_with_timeout(), stratcom_read_input_non_blocking()
LIBSTRATCOM_API stratcom_return stratcom_read_input_non_blocking ( stratcom_device device)

Read a new input report from the physical device to update the internal input state, if available.

Unlike stratcom_read_input(), this function will always return immediately. If an input report is available upon invocation, it will be read and the internal state will be updated accordingly. Otherwise this function does nothing.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
STRATCOM_RET_SUCCESS if an input report was read, STRATCOM_RET_ERROR on error, STRATCOM_RET_NO_DATA if no input report was available for reading.
See also
stratcom_read_input(), stratcom_read_input_with_timeout()
LIBSTRATCOM_API stratcom_return stratcom_read_input_with_timeout ( stratcom_device device,
int  timeout_milliseconds 
)

Wait for a new input report and read it from the physical device to update the internal input state.

This function works exactly like stratcom_read_input(), except if no input report becomes available within a certain timeframe, it will return without reading anything.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]timeout_millisecondsTime in milliseconds that the function will wait for an input report to become available before returning.
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error, STRATCOM_RET_NO_DATA on timeout.
See also
stratcom_read_input(), stratcom_read_input_non_blocking()
LIBSTRATCOM_API stratcom_return stratcom_read_led_blink_intervals ( stratcom_device device)

Read the led blink intervals from the physical device.

Upon successful execution, this function will overwrite the internal state blink intervals with the values obtained from the physical device. This function will cause a feature report to be read from the device.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_get_button_led_state()
LIBSTRATCOM_API stratcom_return stratcom_set_button_led_state ( stratcom_device device,
stratcom_button_led  led,
stratcom_led_state  state 
)

Set the state of a specific LED.

This function changes the state of an LED in both the internal state and flushes the internal state to the physical device. This will result in sending a feature report to the device. When setting multiple LEDs at once, consider using stratcom_set_button_led_state_without_flushing() and stratcom_flush_button_led_state() instead, to avoid having to send multiple feature reports in a row. Note though, that setting STRATCOM_LEDBUTTON_ALL with this function will also only send a single feature report.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]ledThe button LED which is to be changed.
[in]stateRequested new state of the LED.
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_set_button_led_state_without_flushing(), stratcom_flush_button_led_state(), stratcom_get_button_led_state()
LIBSTRATCOM_API void stratcom_set_button_led_state_without_flushing ( stratcom_device device,
stratcom_button_led  led,
stratcom_led_state  state 
)

Set the state of a specific LED in the internal state.

This function changes the state of an LED in the internal state only. To apply the change made by this function to the physical device you have to flush the changes by calling either stratcom_flush_button_led_state() or stratcom_set_button_led_state().

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]ledThe button LED which is to be changed.
[in]stateRequested new state of the LED.
See also
stratcom_set_button_led_state(), stratcom_flush_button_led_state(), stratcom_led_state_has_unflushed_changes(), stratcom_get_button_led_state()
LIBSTRATCOM_API stratcom_return stratcom_set_led_blink_interval ( stratcom_device device,
uint8_t  on_time,
uint8_t  off_time 
)

Set the blink intervals for blinking LEDs.

This function will send a feature report to update the blink state on the physical device. The blink intervals are the same for all buttons.

Parameters
[in]deviceA device structure returned from stratcom_open_device() or stratcom_open_device_on_path().
[in]on_timeTime that the LED is lit when blinking.
[in]off_timeTime that the LED is dark when blinking.
Returns
STRATCOM_RET_SUCCESS on success, STRATCOM_RET_ERROR on error.
See also
stratcom_get_led_blink_interval(), stratcom_read_led_blink_intervals()
LIBSTRATCOM_API void stratcom_shutdown ( )

Finalize the libstratcom library.

This function frees all static data allocated by stratcom_init(). Call it once at the end of the program to prevent memory leaks.

See also
stratcom_init()