14 #include "../include/tscope5/joystick_internal.h"
15 #include "../include/tscope5/system_internal.h"
16 #include "../include/tscope5/timer_internal.h"
32 ts5_log(TS5_LOGLEVEL_6,
"%s: ts5_check_joystick\n", calling_function);
56 ts5_log(TS5_LOGLEVEL_1,
"%s: Installing Tscope5 joystick\n",
59 if (!al_install_joystick()) {
60 ts5_fatal(
"%s: could not install Tscope5 joystick\n",
64 al_register_event_source(_ts5_data.timer.response_queue,
65 al_get_joystick_event_source());
67 _ts5_status.timer.num_joysticks = al_get_num_joysticks();
68 _ts5_status.timer.joystick =
69 (TS5_JOYSTICK_STATUS *)al_malloc(
sizeof(TS5_JOYSTICK_STATUS)*
70 _ts5_status.timer.num_joysticks);
73 for (i=0; i<_ts5_status.timer.num_joysticks; i++) {
75 ALLEGRO_JOYSTICK *joy = al_get_joystick(i);
77 _ts5_status.timer.joystick[i].num_buttons =
78 al_get_joystick_num_buttons(joy);
80 _ts5_status.timer.joystick[i].num_defined_buttons = 0;
81 _ts5_status.timer.joystick[i].num_active_buttons = 0;
83 _ts5_status.timer.joystick[i].button_press_defined =
84 (
int *)al_malloc(
sizeof(
int)
85 * _ts5_status.timer.joystick[i].num_buttons);
87 _ts5_status.timer.joystick[i].button_press_active =
88 (
int *)al_malloc(
sizeof(
int)
89 * _ts5_status.timer.joystick[i].num_buttons);
91 _ts5_status.timer.joystick[i].button_release_defined =
92 (
int *)al_malloc(
sizeof(
int)
93 * _ts5_status.timer.joystick[i].num_buttons);
95 _ts5_status.timer.joystick[i].button_release_active =
96 (
int *)al_malloc(
sizeof(
int)
97 * _ts5_status.timer.joystick[i].num_buttons);
100 for (j=0; j<_ts5_status.timer.joystick[i].num_buttons; j++) {
101 _ts5_status.timer.joystick[i].button_press_defined[j] = 0;
102 _ts5_status.timer.joystick[i].button_press_active[j] = 0;
103 _ts5_status.timer.joystick[i].button_release_defined[j] = 0;
104 _ts5_status.timer.joystick[i].button_release_active[j] = 0;
122 ts5_log(TS5_LOGLEVEL_1,
"Uninstalling Tscope5 joystick\n");
125 for (i=0; i<_ts5_status.timer.num_joysticks; i++) {
127 al_free(_ts5_status.timer.joystick[i].button_press_defined);
128 _ts5_status.timer.joystick[i].button_press_defined = NULL;
130 al_free(_ts5_status.timer.joystick[i].button_press_active);
131 _ts5_status.timer.joystick[i].button_press_active = NULL;
133 al_free(_ts5_status.timer.joystick[i].button_release_defined);
134 _ts5_status.timer.joystick[i].button_release_defined = NULL;
136 al_free(_ts5_status.timer.joystick[i].button_release_active);
137 _ts5_status.timer.joystick[i].button_release_active = NULL;
140 al_free(_ts5_status.timer.joystick);
141 _ts5_status.timer.joystick=NULL;
143 _ts5_status.timer.num_joysticks = 0;
144 _ts5_status.timer.joystick_is_response_device = 0;
146 al_unregister_event_source(_ts5_data.timer.response_queue,
147 al_get_joystick_event_source());
150 al_uninstall_joystick();
void ts5_install_joystick(char *calling_function)
Install the joystick subsystem.
int _ts5_is_timer_installed
Is the timer subsystem installed?
void ts5_check_joystick(char *calling_function)
Do some checks at the start of each joystick function.
int _ts5_is_joystick_installed
Is the joystick subsystem installed?
void ts5_install_timer(char *calling_function)
Install the timer subsystem.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
void ts5_uninstall_joystick()
Uninstall the joystick subsystem.
void ts5_fatal(const char *format,...)
Exit safely with an error message.