16 #include "../include/tscope5/joystick.h"
17 #include "../include/tscope5/timer.h"
18 #include "../include/tscope5/joystick_internal.h"
19 #include "../include/tscope5/system_internal.h"
44 ts5_log(TS5_LOGLEVEL_3,
"ts5_define_joystick_button(%d,%d)\n", device, button);
46 if (device<1 || device>_ts5_status.timer.num_joysticks) {
47 ts5_fatal(
"%s: %s %d, %s %d\n",
"ts5_define_joystick_button",
48 "device argument is", device,
49 "number of joysticks is",
50 _ts5_status.timer.num_joysticks);
54 ts5_fatal(
"%s: %s\n",
"ts5_define_joystick_button",
55 "button argument is 0, response buttons are numbered from 1");
58 if (abs(button)>_ts5_status.timer.joystick[device-1].num_buttons) {
59 ts5_fatal(
"%s: %s %d, %s %d is %d\n",
"ts5_define_joystick_button",
60 "button argument is", button,
61 "number of joystick buttons for device", device,
62 _ts5_status.timer.joystick[device-1].num_buttons);
65 if (button>0 && _ts5_status.timer.joystick[device-1]
66 .button_press_defined[button-1]!=0) {
67 ts5_fatal(
"%s: %s %d %s\n",
"ts5_define_joystick_button",
68 "button press", button,
"is already defined");
71 if (button<0 && _ts5_status.timer.joystick[device-1]
72 .button_release_defined[-button-1]!=0) {
73 ts5_fatal(
"%s: %s %d %s\n",
"ts5_define_joystick_button",
74 "button release", button,
"is already defined");
77 _ts5_status.timer.joystick_is_response_device = 1;
78 _ts5_status.timer.num_defined_buttons++;
79 _ts5_status.timer.num_active_buttons++;
80 _ts5_status.timer.joystick[device-1].num_defined_buttons++;
81 _ts5_status.timer.joystick[device-1].num_active_buttons++;
84 _ts5_status.timer.joystick[device-1]
85 .button_press_defined[button-1] =
86 _ts5_status.timer.num_defined_buttons;
88 _ts5_status.timer.joystick[device-1]
89 .button_press_active[button-1] =
90 _ts5_status.timer.num_defined_buttons;
93 _ts5_status.timer.joystick[device-1]
94 .button_release_defined[-button-1] =
95 _ts5_status.timer.num_defined_buttons;
97 _ts5_status.timer.joystick[device-1]
98 .button_release_active[-button-1] =
99 _ts5_status.timer.num_defined_buttons;
102 return _ts5_status.timer.num_defined_buttons;
114 ts5_log(TS5_LOGLEVEL_4,
"ts5_get_num_joysticks()\n");
116 return _ts5_status.timer.num_joysticks;
130 ts5_log(TS5_LOGLEVEL_4,
"ts5_get_num_joystick_buttons(%d)\n", device);
132 return _ts5_status.timer.joystick[device-1].num_buttons;
void ts5_check_joystick(char *calling_function)
Do some checks at the start of each joystick function.
int ts5_define_joystick_button(int device, int button)
Define a joystick button as a response button.
int ts5_get_num_joysticks()
Get the number of joysticks that are connected to the system.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
int ts5_get_num_joystick_buttons(int device)
Get the number of buttons available on a joystick.
void ts5_fatal(const char *format,...)
Exit safely with an error message.