1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus - game_controller.h * |
3 | * Mupen64Plus homepage: https://mupen64plus.org/ * |
4 | * Copyright (C) 2014 Bobby Smiles * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * |
10 | * * |
11 | * This program is distributed in the hope that it will be useful, * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * |
15 | * * |
16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the * |
18 | * Free Software Foundation, Inc., * |
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
21 | |
22 | #ifndef M64P_DEVICE_SI_GAME_CONTROLLER_H |
23 | #define M64P_DEVICE_SI_GAME_CONTROLLER_H |
24 | |
25 | #include "backends/api/joybus.h" |
26 | |
27 | #include <stddef.h> |
28 | #include <stdint.h> |
29 | |
30 | struct game_controller; |
31 | struct controller_input_backend_interface; |
32 | |
33 | struct game_controller_flavor |
34 | { |
35 | const char* name; |
36 | uint16_t type; |
37 | |
38 | /* controller reset procedure */ |
39 | void (*reset)(struct game_controller* cont); |
40 | }; |
41 | |
42 | struct pak_interface |
43 | { |
44 | const char* name; |
45 | void (*plug)(void* pak); |
46 | void (*unplug)(void* pak); |
47 | void (*read)(void* pak, uint16_t address, uint8_t* data, size_t size); |
48 | void (*write)(void* pak, uint16_t address, const uint8_t* data, size_t size); |
49 | }; |
50 | |
51 | struct game_controller |
52 | { |
53 | uint8_t status; |
54 | |
55 | const struct game_controller_flavor* flavor; |
56 | |
57 | void* cin; |
58 | const struct controller_input_backend_interface* icin; |
59 | |
60 | void* pak; |
61 | const struct pak_interface* ipak; |
62 | }; |
63 | |
64 | void init_game_controller(struct game_controller* cont, |
65 | const struct game_controller_flavor* flavor, |
66 | void* cin, const struct controller_input_backend_interface* icin, |
67 | void* pak, const struct pak_interface* ipak); |
68 | |
69 | |
70 | void change_pak(struct game_controller* cont, |
71 | void* pak, const struct pak_interface* ipak); |
72 | |
73 | /* Controller Joybus interface */ |
74 | extern const struct joybus_device_interface |
75 | g_ijoybus_device_controller; |
76 | |
77 | /* Controller flavors */ |
78 | extern const struct game_controller_flavor g_standard_controller_flavor; |
79 | extern const struct game_controller_flavor g_mouse_controller_flavor; |
80 | |
81 | #endif |
82 | |