x52pro-linux  0.2.1
Saitek X52/X52Pro drivers for Linux/Unix
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 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 struct libx52_device;
36 
47 
52 typedef enum {
55 
58 
62 
67 typedef enum {
70 
74 
79 typedef enum {
82 
85 
89 
94 typedef enum {
97 
99  LIBX52_LED_A = 0x02,
100 
102  LIBX52_LED_B = 0x04,
103 
105  LIBX52_LED_D = 0x06,
106 
108  LIBX52_LED_E = 0x08,
109 
112 
115 
118 
121 
124 
127 } libx52_led_id;
128 
136 typedef enum {
139 
145 
148 
151 
155 
163 typedef enum {
166 
169 
172 
175 
178 
181 
184 
187 
190 
193 
196 
199 
202 
205 
208 
211 
214 
216 
226 typedef enum {
229 
231 
280 int libx52_init(libx52_device ** dev);
281 
292 void libx52_exit(libx52_device *dev);
293 
322 int libx52_connect(libx52_device *dev);
323 
336 
357 
396 int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length);
397 
422  libx52_led_id led,
423  libx52_led_state state);
424 
461 int libx52_set_clock(libx52_device *x52, time_t time, int local);
462 
494  libx52_clock_id clock,
495  int offset);
496 
518  libx52_clock_id clock,
519  libx52_clock_format format);
520 
536 int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute);
537 
553 int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy);
554 
568 
592 int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness);
593 
607 int libx52_set_shift(libx52_device *x52, uint8_t state);
608 
621 int libx52_set_blink(libx52_device *x52, uint8_t state);
622 
644 int libx52_update(libx52_device *x52);
645 
661 int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value);
662 
677 
686 const char * libx52_strerror(libx52_error_code error);
687 
690 #ifdef __cplusplus
691 }
692 #endif
693 
694 #endif /* !defined LIBX52_H */
libx52_set_text
int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length)
Set the text on an MFD line.
libx52_strerror
const char * libx52_strerror(libx52_error_code error)
Return a string representation of the error code.
libx52_exit
void libx52_exit(libx52_device *dev)
Exit the library and free up any resources used.
libx52_feature
libx52_feature
Feature support for libx52.
Definition: libx52.h:226
LIBX52_ERROR_INIT_FAILURE
@ LIBX52_ERROR_INIT_FAILURE
Definition: libx52.h:168
LIBX52_ERROR_NOT_FOUND
@ LIBX52_ERROR_NOT_FOUND
Definition: libx52.h:198
libx52_date_format
libx52_date_format
Supported date formats.
Definition: libx52.h:79
LIBX52_LED_E
@ LIBX52_LED_E
Definition: libx52.h:108
LIBX52_DATE_FORMAT_DDMMYY
@ LIBX52_DATE_FORMAT_DDMMYY
Definition: libx52.h:81
LIBX52_CLOCK_1
@ LIBX52_CLOCK_1
Definition: libx52.h:54
LIBX52_ERROR_BUSY
@ LIBX52_ERROR_BUSY
Definition: libx52.h:201
LIBX52_LED_A
@ LIBX52_LED_A
Definition: libx52.h:99
LIBX52_ERROR_OUT_OF_MEMORY
@ LIBX52_ERROR_OUT_OF_MEMORY
Definition: libx52.h:171
libx52_set_clock_timezone
int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int offset)
Set the timezone for the secondary and tertiary clocks.
libx52_connect
int libx52_connect(libx52_device *dev)
Connect to the X52 device.
LIBX52_DATE_FORMAT_MMDDYY
@ LIBX52_DATE_FORMAT_MMDDYY
Definition: libx52.h:84
libx52_vendor_command
int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
Write a raw vendor control packet.
libx52_is_connected
bool libx52_is_connected(libx52_device *dev)
Check if joystick is connected.
libx52_set_date
int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy)
Set the date.
LIBX52_LED_B
@ LIBX52_LED_B
Definition: libx52.h:102
LIBX52_LED_T2
@ LIBX52_LED_T2
Definition: libx52.h:114
libx52_led_id
libx52_led_id
Supported LED identifiers.
Definition: libx52.h:94
libx52_set_clock_format
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_LED_STATE_ON
@ LIBX52_LED_STATE_ON
Definition: libx52.h:144
LIBX52_ERROR_OVERFLOW
@ LIBX52_ERROR_OVERFLOW
Definition: libx52.h:207
LIBX52_LED_STATE_GREEN
@ LIBX52_LED_STATE_GREEN
Definition: libx52.h:153
LIBX52_LED_D
@ LIBX52_LED_D
Definition: libx52.h:105
libx52_update
int libx52_update(libx52_device *x52)
Update the X52.
LIBX52_ERROR_OUT_OF_RANGE
@ LIBX52_ERROR_OUT_OF_RANGE
Definition: libx52.h:183
libx52_set_time
int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute)
Set the hour and minute on clock 1.
libx52_set_shift
int libx52_set_shift(libx52_device *x52, uint8_t state)
Set the state of the shift indicator.
libx52_led_state
libx52_led_state
Supported LED states.
Definition: libx52.h:136
LIBX52_LED_T3
@ LIBX52_LED_T3
Definition: libx52.h:117
libx52_device
struct libx52_device libx52_device
Device context structure used by libx52.
Definition: libx52.h:46
libx52_error_code
libx52_error_code
LibX52 Error codes.
Definition: libx52.h:163
LIBX52_LED_THROTTLE
@ LIBX52_LED_THROTTLE
Definition: libx52.h:126
LIBX52_CLOCK_2
@ LIBX52_CLOCK_2
Definition: libx52.h:57
libx52_set_date_format
int libx52_set_date_format(libx52_device *x52, libx52_date_format format)
Set the date format for the MFD date display.
LIBX52_CLOCK_3
@ LIBX52_CLOCK_3
Definition: libx52.h:60
LIBX52_LED_T1
@ LIBX52_LED_T1
Definition: libx52.h:111
LIBX52_SUCCESS
@ LIBX52_SUCCESS
Definition: libx52.h:165
libx52_check_feature
int libx52_check_feature(libx52_device *x52, libx52_feature feature)
Check if the device supports the given feature.
LIBX52_ERROR_PIPE
@ LIBX52_ERROR_PIPE
Definition: libx52.h:210
libx52_disconnect
int libx52_disconnect(libx52_device *dev)
Disconnect from the X52 device.
LIBX52_CLOCK_FORMAT_24HR
@ LIBX52_CLOCK_FORMAT_24HR
Definition: libx52.h:72
libx52_set_clock
int libx52_set_clock(libx52_device *x52, time_t time, int local)
Set the clock.
LIBX52_LED_STATE_OFF
@ LIBX52_LED_STATE_OFF
Definition: libx52.h:138
LIBX52_LED_FIRE
@ LIBX52_LED_FIRE
Definition: libx52.h:96
LIBX52_ERROR_PERM
@ LIBX52_ERROR_PERM
Definition: libx52.h:192
libx52_set_blink
int libx52_set_blink(libx52_device *x52, uint8_t state)
Set the blinking state.
LIBX52_CLOCK_FORMAT_12HR
@ LIBX52_CLOCK_FORMAT_12HR
Definition: libx52.h:69
LIBX52_ERROR_TIMEOUT
@ LIBX52_ERROR_TIMEOUT
Definition: libx52.h:204
LIBX52_DATE_FORMAT_YYMMDD
@ LIBX52_DATE_FORMAT_YYMMDD
Definition: libx52.h:87
LIBX52_ERROR_INTERRUPTED
@ LIBX52_ERROR_INTERRUPTED
Definition: libx52.h:213
LIBX52_ERROR_INVALID_PARAM
@ LIBX52_ERROR_INVALID_PARAM
Definition: libx52.h:174
libx52_init
int libx52_init(libx52_device **dev)
Initialize the X52 library.
LIBX52_LED_CLUTCH
@ LIBX52_LED_CLUTCH
Definition: libx52.h:123
LIBX52_LED_STATE_RED
@ LIBX52_LED_STATE_RED
Definition: libx52.h:147
LIBX52_LED_STATE_AMBER
@ LIBX52_LED_STATE_AMBER
Definition: libx52.h:150
LIBX52_LED_POV
@ LIBX52_LED_POV
Definition: libx52.h:120
LIBX52_ERROR_NOT_SUPPORTED
@ LIBX52_ERROR_NOT_SUPPORTED
Definition: libx52.h:177
LIBX52_ERROR_TRY_AGAIN
@ LIBX52_ERROR_TRY_AGAIN
Definition: libx52.h:180
LIBX52_FEATURE_LED
@ LIBX52_FEATURE_LED
Definition: libx52.h:228
LIBX52_ERROR_IO
@ LIBX52_ERROR_IO
Definition: libx52.h:189
libx52_set_brightness
int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness)
Set the MFD or LED brightness.
LIBX52_ERROR_USB_FAILURE
@ LIBX52_ERROR_USB_FAILURE
Definition: libx52.h:186
libx52_clock_id
libx52_clock_id
List of supported clocks on the MFD.
Definition: libx52.h:52
libx52_clock_format
libx52_clock_format
Supported clock formats.
Definition: libx52.h:67
libx52_set_led_state
int libx52_set_led_state(libx52_device *x52, libx52_led_id led, libx52_led_state state)
Set the LED state.
LIBX52_ERROR_NO_DEVICE
@ LIBX52_ERROR_NO_DEVICE
Definition: libx52.h:195