initial neGcon controller support
[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
e8d96071 18#include <stdio.h>
19#include <string.h>
20
4c08b9e7 21#include "main.h"
22
23unsigned char CurPad, CurByte, CurCmd, CmdLen;
24
25/* since this is not a proper plugin, so we'll hook emu internals in a hackish way like this */
26extern void *PAD1_startPoll, *PAD1_poll;
27extern void *PAD2_startPoll, *PAD2_poll;
003cfc63 28extern unsigned char CALLBACK PAD1__startPoll(int pad);
29extern unsigned char CALLBACK PAD2__startPoll(int pad);
30extern unsigned char CALLBACK PAD1__poll(unsigned char value);
31extern unsigned char CALLBACK PAD2__poll(unsigned char value);
4c08b9e7 32
33static int old_controller_type1 = -1, old_controller_type2 = -1;
34
35#define select_pad(n) \
36 if (pad.controllerType != old_controller_type##n) \
37 { \
38 switch (pad.controllerType) \
39 { \
40 case PSE_PAD_TYPE_ANALOGPAD: \
41 PAD##n##_startPoll = PADstartPoll_pad; \
42 PAD##n##_poll = PADpoll_pad; \
43 pad_init(); \
44 break; \
45 case PSE_PAD_TYPE_GUNCON: \
46 PAD##n##_startPoll = PADstartPoll_guncon; \
47 PAD##n##_poll = PADpoll_guncon; \
48 guncon_init(); \
49 break; \
e8d96071 50 case PSE_PAD_TYPE_NEGCON: \
4c08b9e7 51 case PSE_PAD_TYPE_GUN: \
52 default: \
53 PAD##n##_startPoll = PAD##n##__startPoll; \
54 PAD##n##_poll = PAD##n##__poll; \
55 break; \
56 } \
57 }
58
e8d96071 59// case PSE_PAD_TYPE_NEGCON: \
60// PAD##n##_startPoll = PADstartPoll_negcon; \
61// PAD##n##_poll = PADpoll_negcon; \
62// negcon_init(); \
63// break; \
64
4c08b9e7 65void dfinput_activate(void)
66{
67 PadDataS pad;
e8d96071 68 int i;
4c08b9e7 69
70 PAD1_readPort1(&pad);
71 select_pad(1);
72
73 PAD2_readPort2(&pad);
74 select_pad(2);
75}