libretro: try to prevent bad builds
[pcsx_rearmed.git] / plugins / dfinput / main.c
CommitLineData
4c08b9e7 1/*
2 * (C) GraÅžvydas "notaz" Ignotas, 2011
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
003cfc63 11#ifndef _WIN32
12#define CALLBACK
13#else
14#define WIN32_LEAN_AND_MEAN
15#include <windows.h>
16#endif
17
4c08b9e7 18#include "main.h"
19
20unsigned char CurPad, CurByte, CurCmd, CmdLen;
21
22/* since this is not a proper plugin, so we'll hook emu internals in a hackish way like this */
23extern void *PAD1_startPoll, *PAD1_poll;
24extern void *PAD2_startPoll, *PAD2_poll;
003cfc63 25extern unsigned char CALLBACK PAD1__startPoll(int pad);
26extern unsigned char CALLBACK PAD2__startPoll(int pad);
27extern unsigned char CALLBACK PAD1__poll(unsigned char value);
28extern unsigned char CALLBACK PAD2__poll(unsigned char value);
4c08b9e7 29
30static int old_controller_type1 = -1, old_controller_type2 = -1;
31
32#define select_pad(n) \
33 if (pad.controllerType != old_controller_type##n) \
34 { \
35 switch (pad.controllerType) \
36 { \
37 case PSE_PAD_TYPE_ANALOGPAD: \
38 PAD##n##_startPoll = PADstartPoll_pad; \
39 PAD##n##_poll = PADpoll_pad; \
40 pad_init(); \
41 break; \
42 case PSE_PAD_TYPE_GUNCON: \
43 PAD##n##_startPoll = PADstartPoll_guncon; \
44 PAD##n##_poll = PADpoll_guncon; \
45 guncon_init(); \
46 break; \
e8d96071 47 case PSE_PAD_TYPE_NEGCON: \
4c08b9e7 48 case PSE_PAD_TYPE_GUN: \
49 default: \
50 PAD##n##_startPoll = PAD##n##__startPoll; \
51 PAD##n##_poll = PAD##n##__poll; \
52 break; \
53 } \
54 }
55
e8d96071 56
4c08b9e7 57void dfinput_activate(void)
58{
59 PadDataS pad;
60
73d32d69 61 pad.portMultitap = -1;
62 pad.requestPadIndex = 0;
4c08b9e7 63 PAD1_readPort1(&pad);
64 select_pad(1);
65
73d32d69 66 pad.requestPadIndex = 1;
4c08b9e7 67 PAD2_readPort2(&pad);
68 select_pad(2);
69}