4c08b9e7 |
1 | /* |
f3943713 |
2 | * (C) Gražvydas "notaz" Ignotas, 2011 |
4c08b9e7 |
3 | * |
4 | * This work is licensed under the terms of any of these licenses |
5 | * (at your option): |
6 | * - GNU GPL, version 2 or later. |
7 | * - GNU LGPL, version 2.1 or later. |
8 | * See the COPYING file in the top-level directory. |
9 | */ |
10 | |
11 | #include "main.h" |
12 | |
13 | unsigned char CurPad, CurByte, CurCmd, CmdLen; |
14 | |
15 | /* since this is not a proper plugin, so we'll hook emu internals in a hackish way like this */ |
16 | extern void *PAD1_startPoll, *PAD1_poll; |
17 | extern void *PAD2_startPoll, *PAD2_poll; |
003cfc63 |
18 | extern unsigned char CALLBACK PAD1__startPoll(int pad); |
19 | extern unsigned char CALLBACK PAD2__startPoll(int pad); |
20 | extern unsigned char CALLBACK PAD1__poll(unsigned char value); |
21 | extern unsigned char CALLBACK PAD2__poll(unsigned char value); |
4c08b9e7 |
22 | |
46ea5a4e |
23 | #ifndef HAVE_LIBRETRO |
24 | |
4c08b9e7 |
25 | static int old_controller_type1 = -1, old_controller_type2 = -1; |
26 | |
27 | #define select_pad(n) \ |
28 | if (pad.controllerType != old_controller_type##n) \ |
29 | { \ |
30 | switch (pad.controllerType) \ |
31 | { \ |
32 | case PSE_PAD_TYPE_ANALOGPAD: \ |
33 | PAD##n##_startPoll = PADstartPoll_pad; \ |
34 | PAD##n##_poll = PADpoll_pad; \ |
35 | pad_init(); \ |
36 | break; \ |
37 | case PSE_PAD_TYPE_GUNCON: \ |
46ea5a4e |
38 | /* Removed for new Guncon functionality, may have been required for very old touchscreen support */ \ |
39 | /* PAD##n##_startPoll = PADstartPoll_guncon; */ \ |
40 | /* PAD##n##_poll = PADpoll_guncon; */ \ |
41 | /* guncon_init(); */ \ |
42 | /* break; */ \ |
43 | case PSE_PAD_TYPE_NEGCON: \ |
4c08b9e7 |
44 | case PSE_PAD_TYPE_GUN: \ |
45 | default: \ |
46 | PAD##n##_startPoll = PAD##n##__startPoll; \ |
47 | PAD##n##_poll = PAD##n##__poll; \ |
48 | break; \ |
49 | } \ |
50 | } |
46ea5a4e |
51 | #endif /* HAVE_LIBRETRO */ |
4c08b9e7 |
52 | |
e8d96071 |
53 | |
4c08b9e7 |
54 | void dfinput_activate(void) |
55 | { |
f40e483e |
56 | #ifndef HAVE_LIBRETRO |
4c08b9e7 |
57 | PadDataS pad; |
58 | |
73d32d69 |
59 | pad.portMultitap = -1; |
60 | pad.requestPadIndex = 0; |
4c08b9e7 |
61 | PAD1_readPort1(&pad); |
62 | select_pad(1); |
63 | |
73d32d69 |
64 | pad.requestPadIndex = 1; |
4c08b9e7 |
65 | PAD2_readPort2(&pad); |
66 | select_pad(2); |
f40e483e |
67 | #endif |
4c08b9e7 |
68 | } |