libx52 0.3.3
Saitek X52/X52Pro drivers for Linux/Unix
Loading...
Searching...
No Matches
libx52.h
Go to the documentation of this file.
1/*
2 * Saitek X52 Pro MFD & LED driver
3 *
4 * Copyright (C) 2012-2020 Nirenjan Krishnan (nirenjan@nirenjan.org)
5 *
6 * SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
7 */
8
20#ifndef LIBX52_H
21#define LIBX52_H
22
23#include <time.h>
24#include <stdint.h>
25#include <stdbool.h>
26
28#ifndef LIBX52_API
29# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
30# define LIBX52_API __attribute__((visibility("default")))
31# elif defined(_WIN32)
32# define LIBX52_API __declspec(dllexport)
33# else
34# define LIBX52_API
35# endif
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
46struct libx52_device;
47
58
73
85
100
105typedef enum {
108
111
114
117
120
123
126
129
132
135
139
166
226
240
290
301
331
344
365
404LIBX52_API int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length);
405
430 libx52_led_id led,
431 libx52_led_state state);
432
469LIBX52_API int libx52_set_clock(libx52_device *x52, time_t time, int local);
470
502 libx52_clock_id clock,
503 int offset);
504
526 libx52_clock_id clock,
527 libx52_clock_format format);
528
544LIBX52_API int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute);
545
561LIBX52_API int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy);
562
576
600LIBX52_API int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness);
601
616
630
653
669LIBX52_API int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value);
670
685
705
715
725
735
745
755
758#ifdef __cplusplus
759}
760#endif
761
762#endif /* !defined LIBX52_H */
libx52_clock_id
List of supported clocks on the MFD.
Definition libx52.h:63
libx52_clock_format
Supported clock formats.
Definition libx52.h:78
libx52_date_format
Supported date formats.
Definition libx52.h:90
LIBX52_API int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute)
Set the hour and minute on clock 1.
LIBX52_API int libx52_set_date_format(libx52_device *x52, libx52_date_format format)
Set the date format for the MFD date display.
LIBX52_API int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int offset)
Set the timezone for the secondary and tertiary clocks.
LIBX52_API int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy)
Set the date.
LIBX52_API int libx52_set_clock_format(libx52_device *x52, libx52_clock_id clock, libx52_clock_format format)
Set whether the clock is displayed in 12 hour or 24 hour format.
LIBX52_API int libx52_set_clock(libx52_device *x52, time_t time, int local)
Set the clock.
@ LIBX52_CLOCK_3
Definition libx52.h:71
@ LIBX52_CLOCK_1
Definition libx52.h:65
@ LIBX52_CLOCK_2
Definition libx52.h:68
@ LIBX52_CLOCK_FORMAT_24HR
Definition libx52.h:83
@ LIBX52_CLOCK_FORMAT_12HR
Definition libx52.h:80
@ LIBX52_DATE_FORMAT_DDMMYY
Definition libx52.h:92
@ LIBX52_DATE_FORMAT_YYMMDD
Definition libx52.h:98
@ LIBX52_DATE_FORMAT_MMDDYY
Definition libx52.h:95
LIBX52_API bool libx52_is_connected(libx52_device *dev)
Check if joystick is connected.
LIBX52_API int libx52_connect(libx52_device *dev)
Connect to the X52 device.
LIBX52_API int libx52_disconnect(libx52_device *dev)
Disconnect from the X52 device.
LIBX52_API int libx52_init(libx52_device **dev)
Initialize the X52 library.
LIBX52_API void libx52_exit(libx52_device *dev)
Exit the library and free up any resources used.
struct libx52_device libx52_device
Device context structure used by libx52.
Definition libx52.h:57
LIBX52_API int libx52_set_blink(libx52_device *x52, uint8_t state)
Set the blinking state.
LIBX52_API int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length)
Set the text on an MFD line.
libx52_led_state
Supported LED states.
Definition libx52.h:147
LIBX52_API int libx52_set_shift(libx52_device *x52, uint8_t state)
Set the state of the shift indicator.
LIBX52_API int libx52_set_led_state(libx52_device *x52, libx52_led_id led, libx52_led_state state)
Set the LED state.
libx52_led_id
Supported LED identifiers.
Definition libx52.h:105
LIBX52_API int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness)
Set the MFD or LED brightness.
@ LIBX52_LED_STATE_OFF
Definition libx52.h:149
@ LIBX52_LED_STATE_GREEN
Definition libx52.h:164
@ LIBX52_LED_STATE_ON
Definition libx52.h:155
@ LIBX52_LED_STATE_RED
Definition libx52.h:158
@ LIBX52_LED_STATE_AMBER
Definition libx52.h:161
@ LIBX52_LED_POV
Definition libx52.h:131
@ LIBX52_LED_T3
Definition libx52.h:128
@ LIBX52_LED_D
Definition libx52.h:116
@ LIBX52_LED_T2
Definition libx52.h:125
@ LIBX52_LED_CLUTCH
Definition libx52.h:134
@ LIBX52_LED_A
Definition libx52.h:110
@ LIBX52_LED_B
Definition libx52.h:113
@ LIBX52_LED_E
Definition libx52.h:119
@ LIBX52_LED_T1
Definition libx52.h:122
@ LIBX52_LED_FIRE
Definition libx52.h:107
@ LIBX52_LED_THROTTLE
Definition libx52.h:137
LIBX52_API int libx52_update(libx52_device *x52)
Update the X52.
libx52_error_code
LibX52 Error codes.
Definition libx52.h:174
libx52_feature
Feature support for libx52.
Definition libx52.h:236
LIBX52_API int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
Write a raw vendor control packet.
LIBX52_API int libx52_check_feature(libx52_device *x52, libx52_feature feature)
Check if the device supports the given feature.
@ LIBX52_ERROR_INVALID_PARAM
Definition libx52.h:185
@ LIBX52_ERROR_INTERRUPTED
Definition libx52.h:224
@ LIBX52_ERROR_IO
Definition libx52.h:200
@ LIBX52_ERROR_INIT_FAILURE
Definition libx52.h:179
@ LIBX52_ERROR_NOT_FOUND
Definition libx52.h:209
@ LIBX52_ERROR_TIMEOUT
Definition libx52.h:215
@ LIBX52_ERROR_USB_FAILURE
Definition libx52.h:197
@ LIBX52_SUCCESS
Definition libx52.h:176
@ LIBX52_ERROR_NOT_SUPPORTED
Definition libx52.h:188
@ LIBX52_ERROR_TRY_AGAIN
Definition libx52.h:191
@ LIBX52_ERROR_OUT_OF_RANGE
Definition libx52.h:194
@ LIBX52_ERROR_OVERFLOW
Definition libx52.h:218
@ LIBX52_ERROR_PERM
Definition libx52.h:203
@ LIBX52_ERROR_PIPE
Definition libx52.h:221
@ LIBX52_ERROR_NO_DEVICE
Definition libx52.h:206
@ LIBX52_ERROR_OUT_OF_MEMORY
Definition libx52.h:182
@ LIBX52_ERROR_BUSY
Definition libx52.h:212
@ LIBX52_FEATURE_LED
Definition libx52.h:238
LIBX52_API const char * libx52_strerror(libx52_error_code error)
Return a string representation of the error code.
LIBX52_API const char * libx52_date_format_to_str(libx52_date_format format)
Returns a string representation of the date format.
LIBX52_API const char * libx52_led_state_to_str(libx52_led_state state)
Returns a string representation of the LED state.
LIBX52_API const char * libx52_clock_id_to_str(libx52_clock_id id)
Returns a string representation of the clock ID.
LIBX52_API const char * libx52_clock_format_to_str(libx52_clock_format format)
Returns a string representation of the clock format.
LIBX52_API const char * libx52_led_id_to_str(libx52_led_id id)
Returns a string representation of the LED.
#define LIBX52_API
Definition libx52.h:34