7 #include "../include/tscope5/joystick.h"
8 #include "../include/tscope5/timer.h"
9 #include "../include/tscope5/joystick_internal.h"
10 #include "../include/tscope5/system_internal.h"
34 ts5_check_joystick(
"ts5_define_joystick_key");
35 ts5_log(TS5_LOGLEVEL_3,
"ts5_define_joystick_key(%d,%d)\n", device, key);
37 if (device<1 || device>_ts5_status.timer_status.num_joystick) {
38 ts5_fatal(
"ts5_define_joystick_key: device argument is %d, number of joysticks is %d\n",
39 device, _ts5_status.timer_status.num_joystick);
43 ts5_fatal(
"ts5_define_joystick_key: key argument is 0, response keys are numbered from 1\n");
46 if (abs(key)>_ts5_status.timer_status.joystick[device-1].num_buttons) {
47 ts5_fatal(
"ts5_define_joystick_key: key argument is %d, number of joystick buttons for device",
48 " %d is %d\n", key, device, _ts5_status.timer_status.joystick[device-1].num_buttons);
51 if (key>0 && _ts5_status.timer_status.joystick[device-1].button_press_defined[key-1]!=0) {
52 ts5_fatal(
"ts5_define_joystick_key: key press %d is already defined\n", key);
55 if (key<0 && _ts5_status.timer_status.joystick[device-1].button_release_defined[-key-1]!=0) {
56 ts5_fatal(
"ts5_define_joystick_key: key release %d is already defined\n", key);
59 _ts5_status.timer_status.joystick_is_response_device = 1;
60 _ts5_status.timer_status.num_defined_buttons++;
61 _ts5_status.timer_status.num_active_buttons++;
62 _ts5_status.timer_status.joystick[device-1].num_defined_buttons++;
63 _ts5_status.timer_status.joystick[device-1].num_active_buttons++;
66 _ts5_status.timer_status.joystick[device-1].button_press_defined[key-1] =
67 _ts5_status.timer_status.num_defined_buttons;
69 _ts5_status.timer_status.joystick[device-1].button_press_active[key-1] =
70 _ts5_status.timer_status.num_defined_buttons;
73 _ts5_status.timer_status.joystick[device-1].button_release_defined[-key-1] =
74 _ts5_status.timer_status.num_defined_buttons;
76 _ts5_status.timer_status.joystick[device-1].button_release_active[-key-1] =
77 _ts5_status.timer_status.num_defined_buttons;
80 return _ts5_status.timer_status.num_defined_buttons;