Debian Codegraph @

src/cdogs/events.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4 Copyright (c) 2013-2017, 2020-2021 Cong Xu
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
27 */
28 #pragma once
29
30 #include <SDL_events.h>
31
32 #include "joystick.h"
33 #include "keyboard.h"
34 #include "mouse.h"
35 #include "player.h"
36
37 typedef struct
38 {
39 keyboard_t keyboard;
40 CArray joysticks;
41 Mouse mouse;
42 // Filename received via drag and drop
43 char *DropFile;
44
45 bool HasResolutionChanged;
46 bool HasQuit;
47 bool HasLostFocus;
48 int DemoQuitTimer;
49 } EventHandlers;
50
51 extern EventHandlers gEventHandlers;
52
53 void EventInit(EventHandlers *handlers);
54 void EventTerminate(EventHandlers *handlers);
55 void EventReset(EventHandlers *handlers);
56
57 void EventPoll(
58 EventHandlers *handlers, const Uint32 ticks, int (*onEvent)(SDL_Event *));
59
60 int GetOnePlayerCmd(
61 EventHandlers *handlers, const bool isPressed, const input_device_e device,
62 const int deviceIndex);
63 int GetGameCmd(EventHandlers *handlers, const PlayerData *playerData);
64 int GetKeyboardCmd(
65 keyboard_t *keyboard, const int kbIndex, const bool isPressed);
66 SDL_Scancode GetKey(EventHandlers *handlers);
67 // Wait until there is a key press or text input
68 SDL_Scancode EventWaitKeyOrText(EventHandlers *handlers);
69 typedef enum
70 {
71 EVENT_WAIT_CONTINUE,
72 EVENT_WAIT_OK,
73 EVENT_WAIT_CANCEL
74 } EventWaitResult;
75 EventWaitResult EventWaitForAnyKeyOrButton(void);
76 void GetPlayerCmds(EventHandlers *handlers, int (*cmds)[MAX_LOCAL_PLAYERS]);
77 int GetMenuCmd(EventHandlers *handlers, const bool useMouse);
78 void InputGetButtonNameColor(
79 const input_device_e d, const int dIndex, const int cmd, char *buf,
80 color_t *color);
81 #define InputGetButtonName(_d, _dIndex, _cmd, _buf) \
82 InputGetButtonNameColor(_d, _dIndex, _cmd, _buf, NULL)
83 // Return a string that shows the direction controls for an input device
84 void InputGetDirectionNames(
85 char *buf, const input_device_e d, const int dIndex);
86 bool InputHasGrenadeButton(const input_device_e d, const int dIndex);
87
88 bool EventIsEscape(
89 EventHandlers *handlers, const int cmds[MAX_LOCAL_PLAYERS],
90 const int menuCmd);