diff options
Diffstat (limited to 'pcr')
-rw-r--r-- | pcr/reicast-git/PKGBUILD | 38 | ||||
-rw-r--r-- | pcr/reicast-git/enable_multiplayer_support.patch | 37 | ||||
-rw-r--r-- | pcr/reicast-git/multiplayer-config.patch | 16 | ||||
-rw-r--r-- | pcr/reicast-git/multiplayer-unstable.patch | 450 | ||||
-rw-r--r-- | pcr/reicast-git/multiplayer.patch | 1211 | ||||
-rw-r--r-- | pcr/reicast-git/multiplayer_new.patch | 1133 |
6 files changed, 34 insertions, 2851 deletions
diff --git a/pcr/reicast-git/PKGBUILD b/pcr/reicast-git/PKGBUILD index 6b646a466..60c2fbf93 100644 --- a/pcr/reicast-git/PKGBUILD +++ b/pcr/reicast-git/PKGBUILD @@ -4,7 +4,7 @@ _pkgname=reicast pkgname=${_pkgname}-git -pkgver=r1695.0a1689c +pkgver=r1703.a5b7011 pkgrel=1 pkgdesc="A multiplatform Sega Dreamcast emulator" arch=('i686' 'x86_64' 'armv7h') @@ -15,35 +15,29 @@ conflicts=("${_pkgname}") makedepends=('git') depends=('libgl' 'alsa-plugins' 'libpulse' 'python-evdev') # 'sdl2') source=(${_pkgname}-${pkgver}::"git+https://github.com/${_pkgname}/${_pkgname}-emulator.git" - 'enable_multiplayer_support.patch' 'fix-dyna-constprop.patch' 'futuristic-memops.patch' 'generalize-mappings.patch' 'loop-tracing.patch' 'loungekatt_rm-nonfree-fp.patch' - 'multiplayer.patch' - 'multiplayer-unstable.patch' 'refactor-rend-stuff.patch' 'sdl-opengl.patch' 'sh-block-graphs.patch' - 'multiplayer_new.patch' 'fix-android-translations.patch' - 'purupuru.patch') + 'purupuru.patch' + 'multiplayer-config.patch') sha256sums=('SKIP' - '12bfc58e12b3ee79b0c82159cdc70c76a4b6804f5c6986853156602bb0e6beb0' 'c14287cf2b2289b9de28cedeee06fcb89ca40da50e34607780dce55d7d8e5fd6' 'ce3fe9f10555c473cafbf4e85724ebe7a8535a1fa3bfae3c9bc0fe518024f71e' '4c0227db07dc9fa4713694bc438345261e401e0b10c89b25a3c1d20ac9acd9b9' 'af47982ca67babb18a96014643c2394b45316f474c3b07b4e38079f780606fce' '4a6025daded179e88174057affadbcfd539d919c35c36945aa3273fab0b0cb49' - '09097f59200daaa919fee6f50473f4295a7de6702f40ad5e2648d12c9478a080' - '7c0e2a158d7d37ddbf99a40d11a0a889e55c1e85f9c17a2602e5a2bc809ff4ac' 'aead8326ac6815b555be03030ffbdc8f6ced625c980e77eca89e570591c5eb34' 'cf386ebaeafce046a1fc971a5b140bb6a1245840ad2c2a341541327ed6f5606c' '94694d1b615facb39b5ee92ed90c6cefc77fab23fb97f2fcc82e0aa6e1cb14c5' - '51681ec7f90d3b23f57e2946097798266b709570f5c8567a5742873cb14bda64' 'a651fd92d1bfbef0a1ca524c54b2a59a8a45c53ef76a1fe53d36d87abef93a85' - '02b01a8b1a33aa543213371ec6022559c1eebbeb2d6a20173995ee618d7396a1') + '02b01a8b1a33aa543213371ec6022559c1eebbeb2d6a20173995ee618d7396a1' + '9ad37cfed1de29a754388f8655dd58d98a3459d5f65475c8d000d92cabb96e43') pkgver() { cd "${srcdir}/${_pkgname}-${pkgver}" @@ -53,13 +47,17 @@ pkgver() { prepare() { cd "${srcdir}/${_pkgname}-${pkgver}" + # Fix GCC 6.1 errors + sed -i 's|g++|g++ -std=gnu++98| + ' shell/linux/Makefile +# sed -i 's|[#]include[ ][<]stdint[.]h[>]|#include <stdint.h>\n#include <iostream>| +# ' core/deps/libelf/elf32.cpp +# sed -i 's||| +# ' core/linux-dist/evdev.cpp + # Remove nonfree fp.h header rm -v core/deps/libpng/fp.h - # Add Multiplayer support - patch -Np1 -i "$srcdir"/enable_multiplayer_support.patch -# patch -Np1 -i "$srcdir"/multiplayer_new.patch - # Add extra patches patch -Np1 -i "$srcdir"/fix-dyna-constprop.patch patch -Np1 -i "$srcdir"/futuristic-memops.patch @@ -71,9 +69,12 @@ prepare() { patch -Np1 -i "$srcdir"/sh-block-graphs.patch patch -Np1 -i "$srcdir"/fix-android-translations.patch - # Enable Purupuru Pack (rumble support) + # Enable PurupuruPack support (rumble) patch -Np1 -i "$srcdir"/purupuru.patch + # Enable Multiplayer config support + patch -Np1 -i "$srcdir"/multiplayer-config.patch + # Add experimental shadow support: http://github.com/reicast-emulator/issues/94 sed -i 's|//DrawModVols|DrawModVols|' core/rend/gles/gldraw.cpp @@ -96,10 +97,7 @@ build() { # Enable Purupuru Pack (rumble support) sed -i 's|SegaVMU[,]i[,]1|PurupuruPack,i,1|' ${_pkgname}-${pkgver}/core/hw/maple/maple_cfg.cpp make -C ${_pkgname}-${pkgver}/shell/linux platform=x64 PREFIX=/usr DESTDIR="$srcdir"/purupuru-dir install - # Error in platform=lincpp: - # ../../core/linux-dist/evdev.cpp:287:65: required from here - # /usr/include/c++/5.2.0/tuple:1172:70: error: use of deleted function 'EvdevControllerMapping::EvdevControllerMapping()' - # second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...) + # Disabled, due is unsupported code with gnu++11 or gnu++98 # mkdir -vm 0755 "$srcdir"/pkgbuild-cpp-dir # make -C ${_pkgname}-${pkgver}/shell/linux platform=lincpp PREFIX=/usr DESTDIR="$srcdir"/pkgbuild-cpp-dir install elif [ $CARCH == i686 ]; then diff --git a/pcr/reicast-git/enable_multiplayer_support.patch b/pcr/reicast-git/enable_multiplayer_support.patch deleted file mode 100644 index 57794d1eb..000000000 --- a/pcr/reicast-git/enable_multiplayer_support.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff -Nur a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp ---- a/core/hw/maple/maple_cfg.cpp 2015-08-27 12:17:34.718561243 -0300 -+++ b/core/hw/maple/maple_cfg.cpp 2015-08-27 15:57:10.233166402 -0300 -@@ -22,10 +22,12 @@ - */ - void UpdateInputState(u32 port); - --extern u16 kcode[4]; --extern u32 vks[4]; --extern s8 joyx[4],joyy[4]; --extern u8 rt[4],lt[4]; -+#define NUM_PORTS 4 -+ -+extern u16 kcode[NUM_PORTS]; -+extern u32 vks[NUM_PORTS]; -+extern s8 joyx[NUM_PORTS],joyy[NUM_PORTS]; -+extern u8 rt[NUM_PORTS],lt[NUM_PORTS]; - - u8 GetBtFromSgn(s8 val) - { -@@ -69,10 +71,13 @@ - void mcfg_CreateDevices() - { - #if DC_PLATFORM == DC_PLATFORM_DREAMCAST -- mcfg_Create(MDT_SegaController,0,5); -+ for (int i = 0; i < NUM_PORTS; i++) -+ { -+ mcfg_Create(MDT_SegaController,i,5); - -- mcfg_Create(MDT_SegaVMU,0,0); -- mcfg_Create(MDT_SegaVMU,0,1); -+ mcfg_Create(MDT_SegaVMU,i,0); -+ mcfg_Create(MDT_SegaVMU,i,1); -+ } - #else - mcfg_Create(MDT_NaomiJamma, 0, 5); - #endif diff --git a/pcr/reicast-git/multiplayer-config.patch b/pcr/reicast-git/multiplayer-config.patch new file mode 100644 index 000000000..bf0273e2b --- /dev/null +++ b/pcr/reicast-git/multiplayer-config.patch @@ -0,0 +1,16 @@ +diff -Nur a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp +--- a/core/hw/maple/maple_cfg.cpp 2016-05-16 10:10:44.233725925 -0300 ++++ b/core/hw/maple/maple_cfg.cpp 2016-05-16 12:33:19.695805628 -0300 +@@ -78,10 +78,9 @@ + + for (int i = 0; i < numberOfControl; i++){ + mcfg_Create(MDT_SegaController, i, 5); ++ mcfg_Create(MDT_SegaVMU,i,0); ++ mcfg_Create(MDT_SegaVMU,i,1); + } +- +- mcfg_Create(MDT_SegaVMU,0,0); +- mcfg_Create(MDT_SegaVMU,0,1); + #else + mcfg_Create(MDT_NaomiJamma, 0, 5); + #endif diff --git a/pcr/reicast-git/multiplayer-unstable.patch b/pcr/reicast-git/multiplayer-unstable.patch deleted file mode 100644 index cc4e11906..000000000 --- a/pcr/reicast-git/multiplayer-unstable.patch +++ /dev/null @@ -1,450 +0,0 @@ -diff -Nur a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp ---- a/core/hw/maple/maple_cfg.cpp 2015-10-06 21:43:53.027336293 -0300 -+++ b/core/hw/maple/maple_cfg.cpp 2015-10-06 22:08:18.378992677 -0300 -@@ -3,6 +3,7 @@ - #include "maple_helper.h" - #include "maple_devs.h" - #include "maple_cfg.h" -+#include "maple_controller.h" - - #define HAS_VMU - /* -@@ -22,11 +23,6 @@ - */ - void UpdateInputState(u32 port); - --extern u16 kcode[4]; --extern u32 vks[4]; --extern s8 joyx[4],joyy[4]; --extern u8 rt[4],lt[4]; -- - u8 GetBtFromSgn(s8 val) - { - return val+128; -@@ -45,11 +41,11 @@ - { - UpdateInputState(dev->bus_id); - -- pjs->kcode=kcode[dev->bus_id] | 0xF901; -- pjs->joy[PJAI_X1]=GetBtFromSgn(joyx[dev->bus_id]); -- pjs->joy[PJAI_Y1]=GetBtFromSgn(joyy[dev->bus_id]); -- pjs->trigger[PJTI_R]=rt[dev->bus_id]; -- pjs->trigger[PJTI_L]=lt[dev->bus_id]; -+ pjs->kcode = maple_controller[dev->bus_id].buttons | 0xF901; -+ pjs->joy[PJAI_X1] = GetBtFromSgn(maple_controller[dev->bus_id].stick_x); -+ pjs->joy[PJAI_Y1] = GetBtFromSgn(maple_controller[dev->bus_id].stick_y); -+ pjs->trigger[PJTI_R] = maple_controller[dev->bus_id].trigger_right; -+ pjs->trigger[PJTI_L] = maple_controller[dev->bus_id].trigger_left; - } - void SetImage(void* img) - { -@@ -68,14 +64,19 @@ - - void mcfg_CreateDevices() - { --#if DC_PLATFORM == DC_PLATFORM_DREAMCAST -- mcfg_Create(MDT_SegaController,0,5); -- -- mcfg_Create(MDT_SegaVMU,0,0); -- mcfg_Create(MDT_SegaVMU,0,1); --#else -- mcfg_Create(MDT_NaomiJamma, 0, 5); --#endif -+ for(int port = 0; port < MAPLE_NUM_PORTS; port++) -+ { -+ if(maple_controller[port].enabled) -+ { -+ #if DC_PLATFORM == DC_PLATFORM_DREAMCAST -+ mcfg_Create(MDT_SegaController, port, 5); -+ mcfg_Create(MDT_SegaVMU, port, 0); -+ mcfg_Create(MDT_SegaVMU, port, 1); -+ #else -+ mcfg_Create(MDT_NaomiJamma, port, 5); -+ #endif -+ } -+ } - } - - void mcfg_DestroyDevices() -diff -Nur a/core/hw/maple/maple_controller.cpp b/core/hw/maple/maple_controller.cpp ---- a/core/hw/maple/maple_controller.cpp 1969-12-31 21:00:00.000000000 -0300 -+++ b/core/hw/maple/maple_controller.cpp 2015-10-06 22:08:18.378992677 -0300 -@@ -0,0 +1,8 @@ -+#include "hw/maple/maple_controller.h" -+ -+MapleController maple_controller[MAPLE_NUM_PORTS] = { -+ { 1 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 } -+}; -diff -Nur a/core/hw/maple/maple_controller.h b/core/hw/maple/maple_controller.h ---- a/core/hw/maple/maple_controller.h 1969-12-31 21:00:00.000000000 -0300 -+++ b/core/hw/maple/maple_controller.h 2015-10-06 22:08:18.378992677 -0300 -@@ -0,0 +1,42 @@ -+#pragma once -+#include "types.h" -+ -+// If you change the value of MAPLE_NUM_PORTS, please note that you need to change the initializers in maple_controller.cpp as well -+#define MAPLE_NUM_PORTS 4 -+ -+struct MapleController -+{ -+ bool enabled; -+ u16 buttons; -+ u8 trigger_left; -+ u8 trigger_right; -+ s8 stick_x; -+ s8 stick_y; -+}; -+ -+extern MapleController maple_controller[MAPLE_NUM_PORTS]; -+ -+enum DreamcastControllerCodes -+{ -+ DC_BTN_C = 1, -+ DC_BTN_B = 1<<1, -+ DC_BTN_A = 1<<2, -+ DC_BTN_START = 1<<3, -+ DC_BTN_DPAD_UP = 1<<4, -+ DC_BTN_DPAD_DOWN = 1<<5, -+ DC_BTN_DPAD_LEFT = 1<<6, -+ DC_BTN_DPAD_RIGHT = 1<<7, -+ DC_BTN_Z = 1<<8, -+ DC_BTN_Y = 1<<9, -+ DC_BTN_X = 1<<10, -+ DC_BTN_D = 1<<11, -+ DC_BTN_DPAD2_UP = 1<<12, -+ DC_BTN_DPAD2_DOWN = 1<<13, -+ DC_BTN_DPAD2_LEFT = 1<<14, -+ DC_BTN_DPAD2_RIGHT = 1<<15, -+ -+ DC_AXIS_LT = 0X10000, -+ DC_AXIS_RT = 0X10001, -+ DC_AXIS_X = 0X20000, -+ DC_AXIS_Y = 0X20001 -+}; -diff -Nur a/core/linux-dist/x11.cpp b/core/linux-dist/x11.cpp ---- a/core/linux-dist/x11.cpp 2015-10-06 22:04:14.520204440 -0300 -+++ b/core/linux-dist/x11.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -82,11 +82,11 @@ - int dc_key = x11_keymap[e.xkey.keycode]; - if (e.type == KeyPress) - { -- kcode[0] &= ~dc_key; -+ maple_controller[0].buttons &= ~dc_key; - } - else - { -- kcode[0] |= dc_key; -+ maple_controller[0].buttons |= dc_key; - } - } - //printf("KEY: %d -> %d: %d\n",e.xkey.keycode, dc_key, x11_dc_buttons ); -diff -Nur a/core/nacl/nacl.cpp b/core/nacl/nacl.cpp ---- a/core/nacl/nacl.cpp 2015-10-06 22:07:39.028703879 -0300 -+++ b/core/nacl/nacl.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -15,6 +15,7 @@ - #include "ppapi/utility/completion_callback_factory.h" - - #include "types.h" -+#include "hw/maple/maple_controller.h" - - #include <GLES2/gl2.h> - -@@ -234,12 +235,6 @@ - } - } // namespace pp - -- --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - int get_mic_data(u8* buffer) { return 0; } - int push_vmu_screen(u8* buffer) { return 0; } - -diff -Nur a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp ---- a/core/rend/gles/gles.cpp 2015-10-06 22:07:39.029703886 -0300 -+++ b/core/rend/gles/gles.cpp 2015-10-06 22:08:18.382992707 -0300 -@@ -1833,7 +1810,7 @@ - } - - bool do_swp=false; -- //if (kcode[0]&(1<<9)) -+ //if (maple_controller[0].buttons&(1<<9)) - { - - -diff -Nur a/core/windows/winmain.cpp b/core/windows/winmain.cpp ---- a/core/windows/winmain.cpp 2015-10-06 22:07:39.030703893 -0300 -+++ b/core/windows/winmain.cpp 2015-10-06 22:08:18.383992714 -0300 -@@ -1,5 +1,6 @@ - #include "oslib\oslib.h" - #include "oslib\audiostream.h" -+#include "hw\maple\maple_controller.h" - #include "imgread\common.h" - - #define _WIN32_WINNT 0x0500 -@@ -173,66 +174,46 @@ - return MessageBox(NULL,temp,VER_SHORTNAME,type | MB_TASKMODAL); - } - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; --#define key_CONT_C (1 << 0) --#define key_CONT_B (1 << 1) --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_UP (1 << 4) --#define key_CONT_DPAD_DOWN (1 << 5) --#define key_CONT_DPAD_LEFT (1 << 6) --#define key_CONT_DPAD_RIGHT (1 << 7) --#define key_CONT_Z (1 << 8) --#define key_CONT_Y (1 << 9) --#define key_CONT_X (1 << 10) --#define key_CONT_D (1 << 11) --#define key_CONT_DPAD2_UP (1 << 12) --#define key_CONT_DPAD2_DOWN (1 << 13) --#define key_CONT_DPAD2_LEFT (1 << 14) --#define key_CONT_DPAD2_RIGHT (1 << 15) - void UpdateInputState(u32 port) - { -- //joyx[port]=pad.Lx; -- //joyy[port]=pad.Ly; -- lt[port]=GetAsyncKeyState('A')?255:0; -- rt[port]=GetAsyncKeyState('S')?255:0; -+ //maple_controller[port].stick_x = pad.Lx; -+ //maple_controller[port].stick_y = pad.Ly; -+ maple_controller[port].trigger_left = GetAsyncKeyState('A') ? 255 : 0; -+ maple_controller[port].trigger_right = GetAsyncKeyState('S') ? 255 : 0; - -- joyx[port]=joyy[port]=0; -+ maple_controller[port].stick_x = maple_controller[port].stick_y = 0; - - if (GetAsyncKeyState('J')) -- joyx[port]-=126; -+ maple_controller[port].stick_x -= 126; - if (GetAsyncKeyState('L')) -- joyx[port]+=126; -+ maple_controller[port].stick_x += 126; - - if (GetAsyncKeyState('I')) -- joyy[port]-=126; -+ maple_controller[port].stick_y -= 126; - if (GetAsyncKeyState('K')) -- joyy[port]+=126; -+ maple_controller[port].stick_y += 126; - -- kcode[port]=0xFFFF; -+ maple_controller[port].buttons = 0xFFFF; - if (GetAsyncKeyState('V')) -- kcode[port]&=~key_CONT_A; -+ maple_controller[port].buttons &= ~DC_BTN_A; - if (GetAsyncKeyState('C')) -- kcode[port]&=~key_CONT_B; -+ maple_controller[port].buttons &= ~DC_BTN_B; - if (GetAsyncKeyState('X')) -- kcode[port]&=~key_CONT_Y; -+ maple_controller[port].buttons &= ~DC_BTN_Y; - if (GetAsyncKeyState('Z')) -- kcode[port]&=~key_CONT_X; -+ maple_controller[port].buttons &= ~DC_BTN_X; - - if (GetAsyncKeyState(VK_SHIFT)) -- kcode[port]&=~key_CONT_START; -+ maple_controller[port].buttons &= ~DC_BTN_START; - - if (GetAsyncKeyState(VK_UP)) -- kcode[port]&=~key_CONT_DPAD_UP; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_UP; - if (GetAsyncKeyState(VK_DOWN)) -- kcode[port]&=~key_CONT_DPAD_DOWN; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_DOWN; - if (GetAsyncKeyState(VK_LEFT)) -- kcode[port]&=~key_CONT_DPAD_LEFT; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_LEFT; - if (GetAsyncKeyState(VK_RIGHT)) -- kcode[port]&=~key_CONT_DPAD_RIGHT; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_RIGHT; - - if (GetAsyncKeyState(VK_F1)) - settings.pvr.ta_skip = 100; -diff -Nur a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp ---- a/shell/android/jni/src/Android.cpp 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/android/jni/src/Android.cpp 2015-10-06 22:08:18.383992714 -0300 -@@ -16,6 +16,7 @@ - #include "rend/TexCache.h" - #include "hw/maple/maple_devs.h" - #include "hw/maple/maple_if.h" -+#include "hw/maple/maple_controller.h" - #include "oslib/audiobackend_android.h" - - #include "util.h" -@@ -175,10 +176,6 @@ - // Additonal controllers 2, 3 and 4 connected ? - static bool add_controllers[3] = { false, false, false }; - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; - float vjoy_pos[14][8]; - - extern bool print_stats; -@@ -211,7 +208,7 @@ - } - - // Add additonal controllers -- for (int i = 0; i < 3; i++) -+ for (int i = 0; i < (MAPLE_NUM_PORTS - 1); i++) - { - if (add_controllers[i]) - mcfg_Create(MDT_SegaController,i+1,5); -@@ -443,13 +440,13 @@ - jint *jx_body = env->GetIntArrayElements(jx, 0); - jint *jy_body = env->GetIntArrayElements(jy, 0); - -- for(int i = 0; i < 4; i++) -+ for(int i = 0; i < MAPLE_NUM_PORTS; i++) - { -- kcode[i] = k_code_body[i]; -- lt[i] = l_t_body[i]; -- rt[i] = r_t_body[i]; -- joyx[i] = jx_body[i]; -- joyy[i] = jy_body[i]; -+ maple_controller[i].buttons = k_code_body[i]; -+ maple_controller[i].trigger_left = l_t_body[i]; -+ maple_controller[i].trigger_right = r_t_body[i]; -+ maple_controller[i].stick_x = jx_body[i]; -+ maple_controller[i].stick_y = jy_body[i]; - } - - env->ReleaseIntArrayElements(k_code, k_code_body, 0); -diff -Nur a/shell/apple/emulator-ios/emulator/ios_main.mm b/shell/apple/emulator-ios/emulator/ios_main.mm ---- a/shell/apple/emulator-ios/emulator/ios_main.mm 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/apple/emulator-ios/emulator/ios_main.mm 2015-10-06 22:08:18.383992714 -0300 -@@ -20,6 +20,7 @@ - #include <sys/mman.h> - #include <sys/time.h> - #include "hw/sh4/dyna/blockmanager.h" -+#include "hw/maple/maple_controller.h" - #include <unistd.h> - - -@@ -55,11 +56,6 @@ - int dc_init(int argc,wchar* argv[]); - void dc_run(); - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - extern "C" int reicast_main(int argc, wchar* argv[]) - { - //if (argc==2) -diff -Nur a/shell/apple/emulator-osx/emulator-osx/osx-main.mm b/shell/apple/emulator-osx/emulator-osx/osx-main.mm ---- a/shell/apple/emulator-osx/emulator-osx/osx-main.mm 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/apple/emulator-osx/emulator-osx/osx-main.mm 2015-10-06 22:08:18.383992714 -0300 -@@ -8,6 +8,7 @@ - #import <Carbon/Carbon.h> - - #include "types.h" -+#include "hw/maple/maple_controller.h" - #include <sys/stat.h> - - #include <OpenGL/gl3.h> -@@ -38,11 +39,6 @@ - return 0; - } - --u16 kcode[4] = { 0xFFFF }; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - int get_mic_data(u8* buffer) { return 0; } - int push_vmu_screen(u8* buffer) { return 0; } - -@@ -131,35 +127,11 @@ - gles_init(); - } - --enum DCPad { -- Btn_C = 1, -- Btn_B = 1<<1, -- Btn_A = 1<<2, -- Btn_Start = 1<<3, -- DPad_Up = 1<<4, -- DPad_Down = 1<<5, -- DPad_Left = 1<<6, -- DPad_Right = 1<<7, -- Btn_Z = 1<<8, -- Btn_Y = 1<<9, -- Btn_X = 1<<10, -- Btn_D = 1<<11, -- DPad2_Up = 1<<12, -- DPad2_Down = 1<<13, -- DPad2_Left = 1<<14, -- DPad2_Right = 1<<15, -- -- Axis_LT= 0x10000, -- Axis_RT= 0x10001, -- Axis_X= 0x20000, -- Axis_Y= 0x20001, --}; -- - void handle_key(int dckey, int state) { - if (state) -- kcode[0] &= ~dckey; -+ maple_controller[0].buttons &= ~dckey; - else -- kcode[0] |= dckey; -+ maple_controller[0].buttons |= dckey; - } - - void handle_trig(u8* dckey, int state) { -@@ -172,18 +144,18 @@ - extern "C" void emu_key_input(char* keyt, int state) { - int key = keyt[0]; - switch(key) { -- case 'z': handle_key(Btn_X, state); break; -- case 'x': handle_key(Btn_Y, state); break; -- case 'c': handle_key(Btn_B, state); break; -- case 'v': handle_key(Btn_A, state); break; -+ case 'z': handle_key(DC_BTN_X, state); break; -+ case 'x': handle_key(DC_BTN_Y, state); break; -+ case 'c': handle_key(DC_BTN_B, state); break; -+ case 'v': handle_key(DC_BTN_A, state); break; - - case 'a': handle_trig(lt, state); break; - case 's': handle_trig(rt, state); break; - -- case 'j': handle_key(DPad_Left, state); break; -- case 'k': handle_key(DPad_Down, state); break; -- case 'l': handle_key(DPad_Right, state); break; -- case 'i': handle_key(DPad_Up, state); break; -- case 0xa: handle_key(Btn_Start, state); break; -+ case 'j': handle_key(DC_BTN_DPAD_LEFT, state); break; -+ case 'k': handle_key(DC_BTN_DPAD_DOWN, state); break; -+ case 'l': handle_key(DC_BTN_DPAD_RIGHT, state); break; -+ case 'i': handle_key(DC_BTN_DPAD_UP, state); break; -+ case 0xa: handle_key(DC_BTN_START, state); break; - } - } -\ No newline at end of file -diff -Nur a/shell/reicast.vcxproj b/shell/reicast.vcxproj ---- a/shell/reicast.vcxproj 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/reicast.vcxproj 2015-10-06 22:08:18.383992714 -0300 -@@ -92,6 +92,7 @@ - <ClCompile Include="..\core\hw\holly\sb_dma.cpp" /> - <ClCompile Include="..\core\hw\holly\sb_mem.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_cfg.cpp" /> -+ <ClCompile Include="..\core\hw\maple\maple_controller.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_devs.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_helper.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_if.cpp" /> diff --git a/pcr/reicast-git/multiplayer.patch b/pcr/reicast-git/multiplayer.patch deleted file mode 100644 index 19ee3c869..000000000 --- a/pcr/reicast-git/multiplayer.patch +++ /dev/null @@ -1,1211 +0,0 @@ -diff -Nur a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp ---- a/core/hw/maple/maple_cfg.cpp 2015-10-06 21:43:53.027336293 -0300 -+++ b/core/hw/maple/maple_cfg.cpp 2015-10-06 22:08:18.378992677 -0300 -@@ -3,6 +3,7 @@ - #include "maple_helper.h" - #include "maple_devs.h" - #include "maple_cfg.h" -+#include "maple_controller.h" - - #define HAS_VMU - /* -@@ -22,11 +23,6 @@ - */ - void UpdateInputState(u32 port); - --extern u16 kcode[4]; --extern u32 vks[4]; --extern s8 joyx[4],joyy[4]; --extern u8 rt[4],lt[4]; -- - u8 GetBtFromSgn(s8 val) - { - return val+128; -@@ -45,11 +41,11 @@ - { - UpdateInputState(dev->bus_id); - -- pjs->kcode=kcode[dev->bus_id] | 0xF901; -- pjs->joy[PJAI_X1]=GetBtFromSgn(joyx[dev->bus_id]); -- pjs->joy[PJAI_Y1]=GetBtFromSgn(joyy[dev->bus_id]); -- pjs->trigger[PJTI_R]=rt[dev->bus_id]; -- pjs->trigger[PJTI_L]=lt[dev->bus_id]; -+ pjs->kcode = maple_controller[dev->bus_id].buttons | 0xF901; -+ pjs->joy[PJAI_X1] = GetBtFromSgn(maple_controller[dev->bus_id].stick_x); -+ pjs->joy[PJAI_Y1] = GetBtFromSgn(maple_controller[dev->bus_id].stick_y); -+ pjs->trigger[PJTI_R] = maple_controller[dev->bus_id].trigger_right; -+ pjs->trigger[PJTI_L] = maple_controller[dev->bus_id].trigger_left; - } - void SetImage(void* img) - { -@@ -68,14 +64,19 @@ - - void mcfg_CreateDevices() - { --#if DC_PLATFORM == DC_PLATFORM_DREAMCAST -- mcfg_Create(MDT_SegaController,0,5); -- -- mcfg_Create(MDT_SegaVMU,0,0); -- mcfg_Create(MDT_SegaVMU,0,1); --#else -- mcfg_Create(MDT_NaomiJamma, 0, 5); --#endif -+ for(int port = 0; port < MAPLE_NUM_PORTS; port++) -+ { -+ if(maple_controller[port].enabled) -+ { -+ #if DC_PLATFORM == DC_PLATFORM_DREAMCAST -+ mcfg_Create(MDT_SegaController, port, 5); -+ mcfg_Create(MDT_SegaVMU, port, 0); -+ mcfg_Create(MDT_SegaVMU, port, 1); -+ #else -+ mcfg_Create(MDT_NaomiJamma, port, 5); -+ #endif -+ } -+ } - } - - void mcfg_DestroyDevices() -diff -Nur a/core/hw/maple/maple_controller.cpp b/core/hw/maple/maple_controller.cpp ---- a/core/hw/maple/maple_controller.cpp 1969-12-31 21:00:00.000000000 -0300 -+++ b/core/hw/maple/maple_controller.cpp 2015-10-06 22:08:18.378992677 -0300 -@@ -0,0 +1,8 @@ -+#include "hw/maple/maple_controller.h" -+ -+MapleController maple_controller[MAPLE_NUM_PORTS] = { -+ { 1 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 } -+}; -diff -Nur a/core/hw/maple/maple_controller.h b/core/hw/maple/maple_controller.h ---- a/core/hw/maple/maple_controller.h 1969-12-31 21:00:00.000000000 -0300 -+++ b/core/hw/maple/maple_controller.h 2015-10-06 22:08:18.378992677 -0300 -@@ -0,0 +1,42 @@ -+#pragma once -+#include "types.h" -+ -+// If you change the value of MAPLE_NUM_PORTS, please note that you need to change the initializers in maple_controller.cpp as well -+#define MAPLE_NUM_PORTS 4 -+ -+struct MapleController -+{ -+ bool enabled; -+ u16 buttons; -+ u8 trigger_left; -+ u8 trigger_right; -+ s8 stick_x; -+ s8 stick_y; -+}; -+ -+extern MapleController maple_controller[MAPLE_NUM_PORTS]; -+ -+enum DreamcastControllerCodes -+{ -+ DC_BTN_C = 1, -+ DC_BTN_B = 1<<1, -+ DC_BTN_A = 1<<2, -+ DC_BTN_START = 1<<3, -+ DC_BTN_DPAD_UP = 1<<4, -+ DC_BTN_DPAD_DOWN = 1<<5, -+ DC_BTN_DPAD_LEFT = 1<<6, -+ DC_BTN_DPAD_RIGHT = 1<<7, -+ DC_BTN_Z = 1<<8, -+ DC_BTN_Y = 1<<9, -+ DC_BTN_X = 1<<10, -+ DC_BTN_D = 1<<11, -+ DC_BTN_DPAD2_UP = 1<<12, -+ DC_BTN_DPAD2_DOWN = 1<<13, -+ DC_BTN_DPAD2_LEFT = 1<<14, -+ DC_BTN_DPAD2_RIGHT = 1<<15, -+ -+ DC_AXIS_LT = 0X10000, -+ DC_AXIS_RT = 0X10001, -+ DC_AXIS_X = 0X20000, -+ DC_AXIS_Y = 0X20001 -+}; -diff -Nur a/core/linux-dist/evdev.cpp b/core/linux-dist/evdev.cpp ---- a/core/linux-dist/evdev.cpp 2015-10-06 22:07:39.028703879 -0300 -+++ b/core/linux-dist/evdev.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -314,43 +314,43 @@ - { - case EV_KEY: - if (ie.code == controller->mapping->Btn_A) { -- SET_FLAG(kcode[port], DC_BTN_A, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_A, ie.value); - } else if (ie.code == controller->mapping->Btn_B) { -- SET_FLAG(kcode[port], DC_BTN_B, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_B, ie.value); - } else if (ie.code == controller->mapping->Btn_C) { -- SET_FLAG(kcode[port], DC_BTN_C, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_C, ie.value); - } else if (ie.code == controller->mapping->Btn_D) { -- SET_FLAG(kcode[port], DC_BTN_D, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_D, ie.value); - } else if (ie.code == controller->mapping->Btn_X) { -- SET_FLAG(kcode[port], DC_BTN_X, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_X, ie.value); - } else if (ie.code == controller->mapping->Btn_Y) { -- SET_FLAG(kcode[port], DC_BTN_Y, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_Y, ie.value); - } else if (ie.code == controller->mapping->Btn_Z) { -- SET_FLAG(kcode[port], DC_BTN_Z, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_Z, ie.value); - } else if (ie.code == controller->mapping->Btn_Start) { -- SET_FLAG(kcode[port], DC_BTN_START, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_START, ie.value); - } else if (ie.code == controller->mapping->Btn_Escape) { - die("death by escape key"); - } else if (ie.code == controller->mapping->Btn_DPad_Left) { -- SET_FLAG(kcode[port], DC_DPAD_LEFT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad_Right) { -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad_Up) { -- SET_FLAG(kcode[port], DC_DPAD_UP, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad_Down) { -- SET_FLAG(kcode[port], DC_DPAD_DOWN, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Left) { -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Right) { -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Up) { -- SET_FLAG(kcode[port], DC_DPAD2_UP, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Down) { -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, ie.value); - } else if (ie.code == controller->mapping->Btn_Trigger_Left) { -- lt[port] = (ie.value ? 255 : 0); -+ maple_controller[port].trigger_left = (ie.value ? 255 : 0); - } else if (ie.code == controller->mapping->Btn_Trigger_Right) { -- rt[port] = (ie.value ? 255 : 0); -+ maple_controller[port].trigger_right = (ie.value ? 255 : 0); - } - break; - case EV_ABS: -@@ -359,16 +359,16 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD_LEFT, 1); -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, 1); - break; - } - } -@@ -377,16 +377,16 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD_UP, 1); -- SET_FLAG(kcode[port], DC_DPAD_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD_DOWN, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, 1); - break; - } - } -@@ -395,16 +395,16 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, 1); -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, 1); - break; - } - } -@@ -413,34 +413,34 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD2_UP, 1); -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD2_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD2_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, 1); - break; - } - } - else if (ie.code == controller->mapping->Axis_Analog_X) - { -- joyx[port] = (controller->data_x.convert(ie.value) + 128); -+ maple_controller[port].stick_x = (controller->data_x.convert(ie.value) + 128); - } - else if (ie.code == controller->mapping->Axis_Analog_Y) - { -- joyy[port] = (controller->data_y.convert(ie.value) + 128); -+ maple_controller[port].stick_y = (controller->data_y.convert(ie.value) + 128); - } - else if (ie.code == controller->mapping->Axis_Trigger_Left) - { -- lt[port] = controller->data_trigger_left.convert(ie.value); -+ maple_controller[port].trigger_left = controller->data_trigger_left.convert(ie.value); - } - else if (ie.code == controller->mapping->Axis_Trigger_Right) - { -- rt[port] = controller->data_trigger_right.convert(ie.value); -+ maple_controller[port].trigger_right = controller->data_trigger_right.convert(ie.value); - } - break; - } -diff -Nur a/core/linux-dist/joystick.cpp b/core/linux-dist/joystick.cpp ---- a/core/linux-dist/joystick.cpp 2015-10-06 21:43:53.042336401 -0300 -+++ b/core/linux-dist/joystick.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -5,14 +5,14 @@ - #include "linux-dist/joystick.h" - - #if defined(USE_JOYSTICK) -- const u32 joystick_map_btn_usb[JOYSTICK_MAP_SIZE] = { DC_BTN_Y, DC_BTN_B, DC_BTN_A, DC_BTN_X, 0, 0, 0, 0, 0, DC_BTN_START }; -- const u32 joystick_map_axis_usb[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, 0, 0, 0, 0, 0, 0, 0, 0 }; -+ const DreamcastControllerCodes joystick_map_btn_usb[JOYSTICK_MAP_SIZE] = { DC_BTN_Y, DC_BTN_B, DC_BTN_A, DC_BTN_X, 0, 0, 0, 0, 0, DC_BTN_START }; -+ const DreamcastControllerCodes joystick_map_axis_usb[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, 0, 0, 0, 0, 0, 0, 0, 0 }; - -- const u32 joystick_map_btn_xbox360[JOYSTICK_MAP_SIZE] = { DC_BTN_A, DC_BTN_B, DC_BTN_X, DC_BTN_Y, 0, 0, 0, DC_BTN_START, 0, 0 }; -- const u32 joystick_map_axis_xbox360[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_DPAD_LEFT, DC_DPAD_UP, 0, 0 }; -+ const DreamcastControllerCodes joystick_map_btn_xbox360[JOYSTICK_MAP_SIZE] = { DC_BTN_A, DC_BTN_B, DC_BTN_X, DC_BTN_Y, 0, 0, 0, DC_BTN_START, 0, 0 }; -+ const DreamcastControllerCodes joystick_map_axis_xbox360[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_BTN_DPAD_LEFT, DC_BTN_DPAD_UP, 0, 0 }; - -- const u32* joystick_map_btn = joystick_map_btn_usb; -- const u32* joystick_map_axis = joystick_map_axis_usb; -+ const DreamcastControllerCodes* joystick_map_btn = joystick_map_btn_usb; -+ const DreamcastControllerCodes* joystick_map_axis = joystick_map_axis_usb; - - int input_joystick_init(const char* device) - { -@@ -73,18 +73,18 @@ - - if (mt == 0) - { -- kcode[port] |= mo; -- kcode[port] |= mo*2; -+ maple_controller[port].buttons |= mo; -+ maple_controller[port].buttons |= mo*2; - if (v<-64) - { -- kcode[port] &= ~mo; -+ maple_controller[port].buttons &= ~mo; - } - else if (v>64) - { -- kcode[port] &= ~(mo*2); -+ maple_controller[port].buttons &= ~(mo*2); - } - -- //printf("Mapped to %d %d %d\n",mo,kcode[port]&mo,kcode[port]&(mo*2)); -+ //printf("Mapped to %d %d %d\n",mo,maple_controller[port].buttons&mo,maple_controller[port].buttons&(mo*2)); - } - else if (mt == 1) - { -@@ -95,11 +95,11 @@ - //printf("AXIS %d,%d Mapped to %d %d %d\n",JE.number,JE.value,mo,v,v+127); - if (mo == 0) - { -- lt[port] = (v + 127); -+ maple_controller[port].trigger_left = (v + 127); - } - else if (mo == 1) - { -- rt[port] = (v + 127); -+ maple_controller[port].trigger_right = (v + 127); - } - } - else if (mt == 2) -@@ -107,11 +107,11 @@ - // printf("AXIS %d,%d Mapped to %d %d [%d]",JE.number,JE.value,mo,v); - if (mo == 0) - { -- joyx[port] = v; -+ maple_controller[port].stick_x = v; - } - else if (mo == 1) - { -- joyy[port] = v; -+ maple_controller[port].stick_y = v; - } - } - } -@@ -129,11 +129,11 @@ - // printf("Mapped to %d\n",mo); - if (JE.value) - { -- kcode[port] &= ~mo; -+ maple_controller[port].buttons &= ~mo; - } - else - { -- kcode[port] |= mo; -+ maple_controller[port].buttons |= mo; - } - } - else if (mt == 1) -@@ -141,11 +141,11 @@ - // printf("Mapped to %d %d\n",mo,JE.value?255:0); - if (mo==0) - { -- lt[port] = JE.value ? 255 : 0; -+ maple_controller[port].trigger_left = JE.value ? 255 : 0; - } - else if (mo==1) - { -- rt[port] = JE.value ? 255 : 0; -+ maple_controller[port].trigger_right = JE.value ? 255 : 0; - } - } - } -diff -Nur a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp ---- a/core/linux-dist/main.cpp 2015-10-06 22:07:39.028703879 -0300 -+++ b/core/linux-dist/main.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -69,22 +69,11 @@ - return x11_disp; - } - --u16 kcode[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; --u8 rt[4] = {0, 0, 0, 0}; --u8 lt[4] = {0, 0, 0, 0}; --u32 vks[4]; --s8 joyx[4], joyy[4]; -- - void emit_WriteCodeCache(); - - #if defined(USE_EVDEV) - /* evdev input */ -- static EvdevController evdev_controllers[4] = { -- { -1, NULL }, -- { -1, NULL }, -- { -1, NULL }, -- { -1, NULL } -- }; -+ static EvdevController evdev_controllers[MAPLE_NUM_PORTS]; - #endif - - #if defined(USE_JOYSTICK) -@@ -95,14 +84,17 @@ - void SetupInput() - { - #if defined(USE_EVDEV) -- int evdev_device_id[4] = { -1, -1, -1, -1 }; -+ int evdev_device_id[MAPLE_NUM_PORTS]; - size_t size_needed; - int port, i; - - char* evdev_device; - -- for (port = 0; port < 4; port++) -+ for (port = 0; port < MAPLE_NUM_PORTS; port++) - { -+ evdev_controllers[port] = { -1, NULL }; -+ evdev_device_id[port] = -1; -+ - size_needed = snprintf(NULL, 0, EVDEV_DEVICE_CONFIG_KEY, port+1) + 1; - char* evdev_config_key = (char*)malloc(size_needed); - sprintf(evdev_config_key, EVDEV_DEVICE_CONFIG_KEY, port+1); -@@ -135,6 +127,7 @@ - free(evdev_config_key); - - input_evdev_init(&evdev_controllers[port], evdev_device, mapping); -+ maple_controller[port].enabled = true; - - free(evdev_device); - } -diff -Nur a/core/linux-dist/main.h b/core/linux-dist/main.h ---- a/core/linux-dist/main.h 2015-10-06 21:43:53.042336401 -0300 -+++ b/core/linux-dist/main.h 2015-10-06 22:08:18.381992699 -0300 -@@ -1,35 +1,6 @@ - #pragma once - #include "types.h" -- --extern u16 kcode[4]; --extern u32 vks[4]; --extern u8 rt[4], lt[4]; --extern s8 joyx[4], joyy[4]; -+#include "hw/maple/maple_controller.h" - - extern void* x11_win; - extern void* x11_disp; -- --enum DreamcastController --{ -- DC_BTN_C = 1, -- DC_BTN_B = 1<<1, -- DC_BTN_A = 1<<2, -- DC_BTN_START = 1<<3, -- DC_DPAD_UP = 1<<4, -- DC_DPAD_DOWN = 1<<5, -- DC_DPAD_LEFT = 1<<6, -- DC_DPAD_RIGHT = 1<<7, -- DC_BTN_Z = 1<<8, -- DC_BTN_Y = 1<<9, -- DC_BTN_X = 1<<10, -- DC_BTN_D = 1<<11, -- DC_DPAD2_UP = 1<<12, -- DC_DPAD2_DOWN = 1<<13, -- DC_DPAD2_LEFT = 1<<14, -- DC_DPAD2_RIGHT = 1<<15, -- -- DC_AXIS_LT = 0X10000, -- DC_AXIS_RT = 0X10001, -- DC_AXIS_X = 0X20000, -- DC_AXIS_Y = 0X20001, --}; -diff -Nur a/core/linux-dist/x11.cpp b/core/linux-dist/x11.cpp ---- a/core/linux-dist/x11.cpp 2015-10-06 22:04:14.520204440 -0300 -+++ b/core/linux-dist/x11.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -82,11 +82,11 @@ - int dc_key = x11_keymap[e.xkey.keycode]; - if (e.type == KeyPress) - { -- kcode[0] &= ~dc_key; -+ maple_controller[0].buttons &= ~dc_key; - } - else - { -- kcode[0] |= dc_key; -+ maple_controller[0].buttons |= dc_key; - } - } - //printf("KEY: %d -> %d: %d\n",e.xkey.keycode, dc_key, x11_dc_buttons ); -@@ -98,11 +98,11 @@ - - void input_x11_init() - { -- x11_keymap[113] = DC_DPAD_LEFT; -- x11_keymap[114] = DC_DPAD_RIGHT; -+ x11_keymap[113] = DC_BTN_DPAD_LEFT; -+ x11_keymap[114] = DC_BTN_DPAD_RIGHT; - -- x11_keymap[111] = DC_DPAD_UP; -- x11_keymap[116] = DC_DPAD_DOWN; -+ x11_keymap[111] = DC_BTN_DPAD_UP; -+ x11_keymap[116] = DC_BTN_DPAD_DOWN; - - x11_keymap[53] = DC_BTN_X; - x11_keymap[54] = DC_BTN_B; -diff -Nur a/core/nacl/nacl.cpp b/core/nacl/nacl.cpp ---- a/core/nacl/nacl.cpp 2015-10-06 22:07:39.028703879 -0300 -+++ b/core/nacl/nacl.cpp 2015-10-06 22:08:18.381992699 -0300 -@@ -15,6 +15,7 @@ - #include "ppapi/utility/completion_callback_factory.h" - - #include "types.h" -+#include "hw/maple/maple_controller.h" - - #include <GLES2/gl2.h> - -@@ -234,12 +235,6 @@ - } - } // namespace pp - -- --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - int get_mic_data(u8* buffer) { return 0; } - int push_vmu_screen(u8* buffer) { return 0; } - -diff -Nur a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp ---- a/core/rend/gles/gles.cpp 2015-10-06 22:07:39.029703886 -0300 -+++ b/core/rend/gles/gles.cpp 2015-10-06 22:08:18.382992707 -0300 -@@ -2,6 +2,7 @@ - #include "gles.h" - #include "rend/TexCache.h" - #include "cfg/cfg.h" -+#include "hw/maple/maple_controller.h" - - #ifdef TARGET_PANDORA - #include <unistd.h> -@@ -1043,28 +1044,6 @@ - //printf("%f\n",B*log(maxdev)/log(2.0)+A); - } - -- -- --extern u16 kcode[4]; --extern u8 rt[4],lt[4]; -- --#define key_CONT_C (1 << 0) --#define key_CONT_B (1 << 1) --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_UP (1 << 4) --#define key_CONT_DPAD_DOWN (1 << 5) --#define key_CONT_DPAD_LEFT (1 << 6) --#define key_CONT_DPAD_RIGHT (1 << 7) --#define key_CONT_Z (1 << 8) --#define key_CONT_Y (1 << 9) --#define key_CONT_X (1 << 10) --#define key_CONT_D (1 << 11) --#define key_CONT_DPAD2_UP (1 << 12) --#define key_CONT_DPAD2_DOWN (1 << 13) --#define key_CONT_DPAD2_LEFT (1 << 14) --#define key_CONT_DPAD2_RIGHT (1 << 15) -- - u32 osd_base; - u32 osd_count; - -@@ -1260,21 +1239,21 @@ - osd_count=0; - - #ifndef TARGET_PANDORA -- DrawButton2(vjoy_pos[0],kcode[0]&key_CONT_DPAD_LEFT); -- DrawButton2(vjoy_pos[1],kcode[0]&key_CONT_DPAD_UP); -- DrawButton2(vjoy_pos[2],kcode[0]&key_CONT_DPAD_RIGHT); -- DrawButton2(vjoy_pos[3],kcode[0]&key_CONT_DPAD_DOWN); -+ DrawButton2(vjoy_pos[0], maple_controller[0].buttons & DC_BTN_DPAD_LEFT); -+ DrawButton2(vjoy_pos[1], maple_controller[0].buttons & DC_BTN_DPAD_UP); -+ DrawButton2(vjoy_pos[2], maple_controller[0].buttons & DC_BTN_DPAD_RIGHT); -+ DrawButton2(vjoy_pos[3], maple_controller[0].buttons & DC_BTN_DPAD_DOWN); - -- DrawButton2(vjoy_pos[4],kcode[0]&key_CONT_X); -- DrawButton2(vjoy_pos[5],kcode[0]&key_CONT_Y); -- DrawButton2(vjoy_pos[6],kcode[0]&key_CONT_B); -- DrawButton2(vjoy_pos[7],kcode[0]&key_CONT_A); -+ DrawButton2(vjoy_pos[4], maple_controller[0].buttons & DC_BTN_X); -+ DrawButton2(vjoy_pos[5], maple_controller[0].buttons & DC_BTN_Y); -+ DrawButton2(vjoy_pos[6], maple_controller[0].buttons & DC_BTN_B); -+ DrawButton2(vjoy_pos[7], maple_controller[0].buttons & DC_BTN_A); - -- DrawButton2(vjoy_pos[8],kcode[0]&key_CONT_START); -+ DrawButton2(vjoy_pos[8], maple_controller[0].buttons & DC_BTN_START); - -- DrawButton(vjoy_pos[9],lt[0]); -+ DrawButton(vjoy_pos[9], maple_controller[0].trigger_left); - -- DrawButton(vjoy_pos[10],rt[0]); -+ DrawButton(vjoy_pos[10], maple_controller[0].trigger_right); - - DrawButton2(vjoy_pos[11],1); - DrawButton2(vjoy_pos[12],0); -@@ -1818,8 +1797,6 @@ - #endif - #endif - --extern u16 kcode[4]; -- - /* - bool rend_single_frame() - { -@@ -1833,7 +1810,7 @@ - } - - bool do_swp=false; -- //if (kcode[0]&(1<<9)) -+ //if (maple_controller[0].buttons&(1<<9)) - { - - -diff -Nur a/core/sdl/main.cpp b/core/sdl/main.cpp ---- a/core/sdl/main.cpp 2015-10-06 22:07:39.029703886 -0300 -+++ b/core/sdl/main.cpp 2015-10-06 22:08:18.382992707 -0300 -@@ -21,6 +21,7 @@ - #include <execinfo.h> - - #include "hw/mem/_vmem.h" -+#include "hw/maple/maple_controller.h" - - #ifdef TARGET_PANDORA - #define WINDOW_WIDTH 800 -@@ -56,42 +57,10 @@ - return MBX_OK; - } - -- -- --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - extern bool KillTex; - - extern void dc_term(); - --enum DCPad { -- Btn_C = 1, -- Btn_B = 1<<1, -- Btn_A = 1<<2, -- Btn_Start = 1<<3, -- DPad_Up = 1<<4, -- DPad_Down = 1<<5, -- DPad_Left = 1<<6, -- DPad_Right = 1<<7, -- Btn_Z = 1<<8, -- Btn_Y = 1<<9, -- Btn_X = 1<<10, -- Btn_D = 1<<11, -- DPad2_Up = 1<<12, -- DPad2_Down = 1<<13, -- DPad2_Left = 1<<14, -- DPad2_Right = 1<<15, -- -- Axis_LT= 0x10000, -- Axis_RT= 0x10001, -- Axis_X= 0x20000, -- Axis_Y= 0x20001, --}; -- -- - void emit_WriteCodeCache(); - - static SDL_Joystick *JoySDL = 0; -@@ -100,33 +69,26 @@ - - #define MAP_SIZE 32 - --const u32 JMapBtn_USB[MAP_SIZE] = -- { Btn_Y,Btn_B,Btn_A,Btn_X,0,0,0,0,0,Btn_Start }; -+const DreamcastControllerCodes JMapBtn_USB[MAP_SIZE] = -+ { DC_BTN_Y, DC_BTN_B, DC_BTN_A, DC_BTN_X, 0, 0, 0, 0, 0, DC_BTN_START }; - --const u32 JMapAxis_USB[MAP_SIZE] = -- { Axis_X,Axis_Y,0,0,0,0,0,0,0,0 }; -+const DreamcastControllerCodes JMapAxis_USB[MAP_SIZE] = -+ { DC_AXIS_X, DC_AXIS_Y, 0 ,0, 0, 0, 0, 0, 0, 0 }; - --const u32 JMapBtn_360[MAP_SIZE] = -- { Btn_A,Btn_B,Btn_X,Btn_Y,0,0,0,Btn_Start,0,0 }; -+const DreamcastControllerCodes JMapBtn_360[MAP_SIZE] = -+ { DC_BTN_A, DC_BTN_B, DC_BTN_X, DC_BTN_Y, 0, 0, 0, DC_BTN_START, 0, 0 }; - --const u32 JMapAxis_360[MAP_SIZE] = -- { Axis_X,Axis_Y,Axis_LT,0,0,Axis_RT,DPad_Left,DPad_Up,0,0 }; -+const DreamcastControllerCodes JMapAxis_360[MAP_SIZE] = -+ { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_BTN_DPAD_LEFT, DC_BTN_DPAD_UP, 0, 0 }; - --const u32* JMapBtn=JMapBtn_USB; --const u32* JMapAxis=JMapAxis_USB; -+const DreamcastControllerCodes* JMapBtn = JMapBtn_USB; -+const DreamcastControllerCodes* JMapAxis = JMapAxis_USB; - #ifdef TARGET_PANDORA - u32 JSensitivity[256]; // To have less sensitive value on nubs - #endif - - void SetupInput() - { -- for (int port=0;port<4;port++) -- { -- kcode[port]=0xFFFF; -- rt[port]=0; -- lt[port]=0; -- } -- - // Open joystick device - int numjoys = SDL_NumJoysticks(); - printf("Number of Joysticks found = %i\n", numjoys); -@@ -236,17 +198,17 @@ - { - // printf("Mapped to %d\n",mo); - if (value) -- kcode[port]&=~mo; -+ maple_controller[port].buttons &= ~mo; - else -- kcode[port]|=mo; -+ maple_controller[port].buttons |= mo; - } - else if (mt==1) - { - // printf("Mapped to %d %d\n",mo,JE.value?255:0); - if (mo==0) -- lt[port]=value?255:0; -+ maple_controller[port].trigger_left = value ? 255 : 0; - else if (mo==1) -- rt[port]=value?255:0; -+ maple_controller[port].trigger_right = value ? 255 : 0; - } - - } -@@ -266,18 +228,18 @@ - - if (mt==0) - { -- kcode[port]|=mo; -- kcode[port]|=mo*2; -+ maple_controller[port].buttons |= mo; -+ maple_controller[port].buttons |= mo*2; - if (v<-64) - { -- kcode[port]&=~mo; -+ maple_controller[port].buttons &= ~mo; - } - else if (v>64) - { -- kcode[port]&=~(mo*2); -+ maple_controller[port].buttons &= ~(mo*2); - } - -- // printf("Mapped to %d %d %d\n",mo,kcode[port]&mo,kcode[port]&(mo*2)); -+ // printf("Mapped to %d %d %d\n",mo,maple_controller[port].buttons&mo,maple_controller[port].buttons&(mo*2)); - } - else if (mt==1) - { -@@ -286,17 +248,17 @@ - // printf("AXIS %d,%d Mapped to %d %d %d\n",JE.number,JE.value,mo,v,v+127); - - if (mo==0) -- lt[port]=v+127; -+ maple_controller[port].trigger_left = v+127; - else if (mo==1) -- rt[port]=v+127; -+ maple_controller[port].trigger_right = v+127; - } - else if (mt==2) - { - // printf("AXIS %d,%d Mapped to %d %d [%d]",JE.number,JE.value,mo,v); - if (mo==0) -- joyx[port]=v; -+ maple_controller[port].stick_x = v; - else if (mo==1) -- joyy[port]=v; -+ maple_controller[port].stick_y = v; - } - } - break; -@@ -314,18 +276,18 @@ - case 0: // nothing - break; - case 1: // Up=RT, Down=LT -- if (yy<0) rt[port]=-yy; -- if (yy>0) lt[port]=yy; -+ if (yy<0) maple_controller[port].trigger_right = -yy; -+ if (yy>0) maple_controller[port].trigger_left = yy; - break; - case 2: // Left=LT, Right=RT -- if (xx<0) lt[port]=-xx; -- if (xx>0) rt[port]=xx; -+ if (xx<0) maple_controller[port].trigger_left = -xx; -+ if (xx>0) maple_controller[port].trigger_right = xx; - break; - case 3: // Nub = ABXY -- if (xx<-127) kcode[port] &= ~Btn_X; -- if (xx>127) kcode[port] &= ~Btn_B; -- if (yy<-127) kcode[port] &= ~Btn_Y; -- if (yy>127) kcode[port] &= ~Btn_A; -+ if (xx<-127) maple_controller[port].buttons &= ~DC_BTN_X; -+ if (xx>127) maple_controller[port].buttons &= ~DC_BTN_B; -+ if (yy<-127) maple_controller[port].buttons &= ~DC_BTN_Y; -+ if (yy>127) maple_controller[port].buttons &= ~DC_BTN_A; - break; - } - break; -@@ -333,16 +295,16 @@ - - } - -- if (keys[0]) { kcode[port] &= ~Btn_C; } -- if (keys[6]) { kcode[port] &= ~Btn_A; } -- if (keys[7]) { kcode[port] &= ~Btn_B; } -- if (keys[5]) { kcode[port] &= ~Btn_Y; } -- if (keys[8]) { kcode[port] &= ~Btn_X; } -- if (keys[1]) { kcode[port] &= ~DPad_Up; } -- if (keys[2]) { kcode[port] &= ~DPad_Down; } -- if (keys[3]) { kcode[port] &= ~DPad_Left; } -- if (keys[4]) { kcode[port] &= ~DPad_Right; } -- if (keys[12]){ kcode[port] &= ~Btn_Start; } -+ if (keys[0]) { maple_controller[port].buttons &= ~DC_BTN_C; } -+ if (keys[6]) { maple_controller[port].buttons &= ~DC_BTN_A; } -+ if (keys[7]) { maple_controller[port].buttons &= ~DC_BTN_B; } -+ if (keys[5]) { maple_controller[port].buttons &= ~DC_BTN_Y; } -+ if (keys[8]) { maple_controller[port].buttons &= ~DC_BTN_X; } -+ if (keys[1]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_UP; } -+ if (keys[2]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_DOWN; } -+ if (keys[3]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_LEFT; } -+ if (keys[4]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_RIGHT; } -+ if (keys[12]){ maple_controller[port].buttons &= ~DC_BTN_START; } - if (keys[9]){ - //die("death by escape key"); - //printf("death by escape key\n"); -@@ -352,8 +314,8 @@ - // is there a proper way to exit? dc_term() doesn't end the dc_run() loop it seems - die("death by escape key"); - } -- if (keys[10]) rt[port]=255; -- if (keys[11]) lt[port]=255; -+ if (keys[10]) maple_controller[port].trigger_right=255; -+ if (keys[11]) maple_controller[port].trigger_left=255; - - return true; - } -@@ -362,9 +324,9 @@ - { - static char key = 0; - -- kcode[port]=0xFFFF; -- rt[port]=0; -- lt[port]=0; -+ maple_controller[port].buttons=0xFFFF; -+ maple_controller[port].trigger_right=0; -+ maple_controller[port].trigger_left=0; - - HandleEvents(port); - } -diff -Nur a/core/windows/winmain.cpp b/core/windows/winmain.cpp ---- a/core/windows/winmain.cpp 2015-10-06 22:07:39.030703893 -0300 -+++ b/core/windows/winmain.cpp 2015-10-06 22:08:18.383992714 -0300 -@@ -1,5 +1,6 @@ - #include "oslib\oslib.h" - #include "oslib\audiostream.h" -+#include "hw\maple\maple_controller.h" - #include "imgread\common.h" - - #define _WIN32_WINNT 0x0500 -@@ -173,66 +174,46 @@ - return MessageBox(NULL,temp,VER_SHORTNAME,type | MB_TASKMODAL); - } - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; --#define key_CONT_C (1 << 0) --#define key_CONT_B (1 << 1) --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_UP (1 << 4) --#define key_CONT_DPAD_DOWN (1 << 5) --#define key_CONT_DPAD_LEFT (1 << 6) --#define key_CONT_DPAD_RIGHT (1 << 7) --#define key_CONT_Z (1 << 8) --#define key_CONT_Y (1 << 9) --#define key_CONT_X (1 << 10) --#define key_CONT_D (1 << 11) --#define key_CONT_DPAD2_UP (1 << 12) --#define key_CONT_DPAD2_DOWN (1 << 13) --#define key_CONT_DPAD2_LEFT (1 << 14) --#define key_CONT_DPAD2_RIGHT (1 << 15) - void UpdateInputState(u32 port) - { -- //joyx[port]=pad.Lx; -- //joyy[port]=pad.Ly; -- lt[port]=GetAsyncKeyState('A')?255:0; -- rt[port]=GetAsyncKeyState('S')?255:0; -+ //maple_controller[port].stick_x = pad.Lx; -+ //maple_controller[port].stick_y = pad.Ly; -+ maple_controller[port].trigger_left = GetAsyncKeyState('A') ? 255 : 0; -+ maple_controller[port].trigger_right = GetAsyncKeyState('S') ? 255 : 0; - -- joyx[port]=joyy[port]=0; -+ maple_controller[port].stick_x = maple_controller[port].stick_y = 0; - - if (GetAsyncKeyState('J')) -- joyx[port]-=126; -+ maple_controller[port].stick_x -= 126; - if (GetAsyncKeyState('L')) -- joyx[port]+=126; -+ maple_controller[port].stick_x += 126; - - if (GetAsyncKeyState('I')) -- joyy[port]-=126; -+ maple_controller[port].stick_y -= 126; - if (GetAsyncKeyState('K')) -- joyy[port]+=126; -+ maple_controller[port].stick_y += 126; - -- kcode[port]=0xFFFF; -+ maple_controller[port].buttons = 0xFFFF; - if (GetAsyncKeyState('V')) -- kcode[port]&=~key_CONT_A; -+ maple_controller[port].buttons &= ~DC_BTN_A; - if (GetAsyncKeyState('C')) -- kcode[port]&=~key_CONT_B; -+ maple_controller[port].buttons &= ~DC_BTN_B; - if (GetAsyncKeyState('X')) -- kcode[port]&=~key_CONT_Y; -+ maple_controller[port].buttons &= ~DC_BTN_Y; - if (GetAsyncKeyState('Z')) -- kcode[port]&=~key_CONT_X; -+ maple_controller[port].buttons &= ~DC_BTN_X; - - if (GetAsyncKeyState(VK_SHIFT)) -- kcode[port]&=~key_CONT_START; -+ maple_controller[port].buttons &= ~DC_BTN_START; - - if (GetAsyncKeyState(VK_UP)) -- kcode[port]&=~key_CONT_DPAD_UP; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_UP; - if (GetAsyncKeyState(VK_DOWN)) -- kcode[port]&=~key_CONT_DPAD_DOWN; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_DOWN; - if (GetAsyncKeyState(VK_LEFT)) -- kcode[port]&=~key_CONT_DPAD_LEFT; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_LEFT; - if (GetAsyncKeyState(VK_RIGHT)) -- kcode[port]&=~key_CONT_DPAD_RIGHT; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_RIGHT; - - if (GetAsyncKeyState(VK_F1)) - settings.pvr.ta_skip = 100; -diff -Nur a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp ---- a/shell/android/jni/src/Android.cpp 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/android/jni/src/Android.cpp 2015-10-06 22:08:18.383992714 -0300 -@@ -16,6 +16,7 @@ - #include "rend/TexCache.h" - #include "hw/maple/maple_devs.h" - #include "hw/maple/maple_if.h" -+#include "hw/maple/maple_controller.h" - #include "oslib/audiobackend_android.h" - - #include "util.h" -@@ -175,10 +176,6 @@ - // Additonal controllers 2, 3 and 4 connected ? - static bool add_controllers[3] = { false, false, false }; - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; - float vjoy_pos[14][8]; - - extern bool print_stats; -@@ -211,7 +208,7 @@ - } - - // Add additonal controllers -- for (int i = 0; i < 3; i++) -+ for (int i = 0; i < (MAPLE_NUM_PORTS - 1); i++) - { - if (add_controllers[i]) - mcfg_Create(MDT_SegaController,i+1,5); -@@ -443,13 +440,13 @@ - jint *jx_body = env->GetIntArrayElements(jx, 0); - jint *jy_body = env->GetIntArrayElements(jy, 0); - -- for(int i = 0; i < 4; i++) -+ for(int i = 0; i < MAPLE_NUM_PORTS; i++) - { -- kcode[i] = k_code_body[i]; -- lt[i] = l_t_body[i]; -- rt[i] = r_t_body[i]; -- joyx[i] = jx_body[i]; -- joyy[i] = jy_body[i]; -+ maple_controller[i].buttons = k_code_body[i]; -+ maple_controller[i].trigger_left = l_t_body[i]; -+ maple_controller[i].trigger_right = r_t_body[i]; -+ maple_controller[i].stick_x = jx_body[i]; -+ maple_controller[i].stick_y = jy_body[i]; - } - - env->ReleaseIntArrayElements(k_code, k_code_body, 0); -diff -Nur a/shell/apple/emulator-ios/emulator/EmulatorView.mm b/shell/apple/emulator-ios/emulator/EmulatorView.mm ---- a/shell/apple/emulator-ios/emulator/EmulatorView.mm 2015-10-06 21:43:53.121336967 -0300 -+++ b/shell/apple/emulator-ios/emulator/EmulatorView.mm 2015-10-06 22:08:18.383992714 -0300 -@@ -9,15 +9,7 @@ - #import "EmulatorView.h" - - #include "types.h" -- --extern u16 kcode[4]; --extern u32 vks[4]; --extern s8 joyx[4],joyy[4]; --extern u8 rt[4],lt[4]; -- --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_LEFT (1 << 6) -+#include "hw/maple/maple_controller.h" - - int dpad_or_btn = 0; - -@@ -34,9 +26,9 @@ - -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - - if (dpad_or_btn &1) -- kcode[0] &= ~(key_CONT_START|key_CONT_A); -+ maple_controller[0].buttons &= ~(DC_BTN_START|DC_BTN_A); - else -- kcode[0] &= ~(key_CONT_DPAD_LEFT); -+ maple_controller[0].buttons &= ~(DC_BTN_DPAD_LEFT); - } - - -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { -@@ -44,9 +36,9 @@ - // [event allTouches]; - - if (dpad_or_btn &1) -- kcode[0] |= (key_CONT_START|key_CONT_A); -+ maple_controller[0].buttons |= (DC_BTN_START|DC_BTN_A); - else -- kcode[0] |= (key_CONT_DPAD_LEFT); -+ maple_controller[0].buttons |= (DC_BTN_DPAD_LEFT); - - dpad_or_btn++; - } -diff -Nur a/shell/apple/emulator-ios/emulator/ios_main.mm b/shell/apple/emulator-ios/emulator/ios_main.mm ---- a/shell/apple/emulator-ios/emulator/ios_main.mm 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/apple/emulator-ios/emulator/ios_main.mm 2015-10-06 22:08:18.383992714 -0300 -@@ -20,6 +20,7 @@ - #include <sys/mman.h> - #include <sys/time.h> - #include "hw/sh4/dyna/blockmanager.h" -+#include "hw/maple/maple_controller.h" - #include <unistd.h> - - -@@ -55,11 +56,6 @@ - int dc_init(int argc,wchar* argv[]); - void dc_run(); - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - extern "C" int reicast_main(int argc, wchar* argv[]) - { - //if (argc==2) -diff -Nur a/shell/apple/emulator-osx/emulator-osx/osx-main.mm b/shell/apple/emulator-osx/emulator-osx/osx-main.mm ---- a/shell/apple/emulator-osx/emulator-osx/osx-main.mm 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/apple/emulator-osx/emulator-osx/osx-main.mm 2015-10-06 22:08:18.383992714 -0300 -@@ -8,6 +8,7 @@ - #import <Carbon/Carbon.h> - - #include "types.h" -+#include "hw/maple/maple_controller.h" - #include <sys/stat.h> - - #include <OpenGL/gl3.h> -@@ -38,11 +39,6 @@ - return 0; - } - --u16 kcode[4] = { 0xFFFF }; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - int get_mic_data(u8* buffer) { return 0; } - int push_vmu_screen(u8* buffer) { return 0; } - -@@ -131,35 +127,11 @@ - gles_init(); - } - --enum DCPad { -- Btn_C = 1, -- Btn_B = 1<<1, -- Btn_A = 1<<2, -- Btn_Start = 1<<3, -- DPad_Up = 1<<4, -- DPad_Down = 1<<5, -- DPad_Left = 1<<6, -- DPad_Right = 1<<7, -- Btn_Z = 1<<8, -- Btn_Y = 1<<9, -- Btn_X = 1<<10, -- Btn_D = 1<<11, -- DPad2_Up = 1<<12, -- DPad2_Down = 1<<13, -- DPad2_Left = 1<<14, -- DPad2_Right = 1<<15, -- -- Axis_LT= 0x10000, -- Axis_RT= 0x10001, -- Axis_X= 0x20000, -- Axis_Y= 0x20001, --}; -- - void handle_key(int dckey, int state) { - if (state) -- kcode[0] &= ~dckey; -+ maple_controller[0].buttons &= ~dckey; - else -- kcode[0] |= dckey; -+ maple_controller[0].buttons |= dckey; - } - - void handle_trig(u8* dckey, int state) { -@@ -172,18 +144,18 @@ - extern "C" void emu_key_input(char* keyt, int state) { - int key = keyt[0]; - switch(key) { -- case 'z': handle_key(Btn_X, state); break; -- case 'x': handle_key(Btn_Y, state); break; -- case 'c': handle_key(Btn_B, state); break; -- case 'v': handle_key(Btn_A, state); break; -+ case 'z': handle_key(DC_BTN_X, state); break; -+ case 'x': handle_key(DC_BTN_Y, state); break; -+ case 'c': handle_key(DC_BTN_B, state); break; -+ case 'v': handle_key(DC_BTN_A, state); break; - - case 'a': handle_trig(lt, state); break; - case 's': handle_trig(rt, state); break; - -- case 'j': handle_key(DPad_Left, state); break; -- case 'k': handle_key(DPad_Down, state); break; -- case 'l': handle_key(DPad_Right, state); break; -- case 'i': handle_key(DPad_Up, state); break; -- case 0xa: handle_key(Btn_Start, state); break; -+ case 'j': handle_key(DC_BTN_DPAD_LEFT, state); break; -+ case 'k': handle_key(DC_BTN_DPAD_DOWN, state); break; -+ case 'l': handle_key(DC_BTN_DPAD_RIGHT, state); break; -+ case 'i': handle_key(DC_BTN_DPAD_UP, state); break; -+ case 0xa: handle_key(DC_BTN_START, state); break; - } - } -\ No newline at end of file -diff -Nur a/shell/reicast.vcxproj b/shell/reicast.vcxproj ---- a/shell/reicast.vcxproj 2015-10-06 22:07:39.030703893 -0300 -+++ b/shell/reicast.vcxproj 2015-10-06 22:08:18.383992714 -0300 -@@ -92,6 +92,7 @@ - <ClCompile Include="..\core\hw\holly\sb_dma.cpp" /> - <ClCompile Include="..\core\hw\holly\sb_mem.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_cfg.cpp" /> -+ <ClCompile Include="..\core\hw\maple\maple_controller.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_devs.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_helper.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_if.cpp" /> diff --git a/pcr/reicast-git/multiplayer_new.patch b/pcr/reicast-git/multiplayer_new.patch deleted file mode 100644 index ed2ba8772..000000000 --- a/pcr/reicast-git/multiplayer_new.patch +++ /dev/null @@ -1,1133 +0,0 @@ -diff -Nur a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp ---- a/core/hw/maple/maple_cfg.cpp 2016-01-18 21:29:18.658937519 -0300 -+++ b/core/hw/maple/maple_cfg.cpp 2016-01-18 21:35:15.480978214 -0300 -@@ -3,6 +3,7 @@ - #include "maple_helper.h" - #include "maple_devs.h" - #include "maple_cfg.h" -+#include "maple_controller.h" - - #define HAS_VMU - /* -@@ -22,11 +23,6 @@ - */ - void UpdateInputState(u32 port); - --extern u16 kcode[4]; --extern u32 vks[4]; --extern s8 joyx[4],joyy[4]; --extern u8 rt[4],lt[4]; -- - u8 GetBtFromSgn(s8 val) - { - return val+128; -@@ -45,11 +41,11 @@ - { - UpdateInputState(dev->bus_id); - -- pjs->kcode=kcode[dev->bus_id] | 0xF901; -- pjs->joy[PJAI_X1]=GetBtFromSgn(joyx[dev->bus_id]); -- pjs->joy[PJAI_Y1]=GetBtFromSgn(joyy[dev->bus_id]); -- pjs->trigger[PJTI_R]=rt[dev->bus_id]; -- pjs->trigger[PJTI_L]=lt[dev->bus_id]; -+ pjs->kcode = maple_controller[dev->bus_id].buttons | 0xF901; -+ pjs->joy[PJAI_X1] = GetBtFromSgn(maple_controller[dev->bus_id].stick_x); -+ pjs->joy[PJAI_Y1] = GetBtFromSgn(maple_controller[dev->bus_id].stick_y); -+ pjs->trigger[PJTI_R] = maple_controller[dev->bus_id].trigger_right; -+ pjs->trigger[PJTI_L] = maple_controller[dev->bus_id].trigger_left; - } - void SetImage(void* img) - { -@@ -68,14 +64,19 @@ - - void mcfg_CreateDevices() - { --#if DC_PLATFORM == DC_PLATFORM_DREAMCAST -- mcfg_Create(MDT_SegaController,0,5); -- -- mcfg_Create(MDT_SegaVMU,0,0); -- mcfg_Create(MDT_SegaVMU,0,1); --#else -- mcfg_Create(MDT_NaomiJamma, 0, 5); --#endif -+ #if DC_PLATFORM == DC_PLATFORM_DREAMCAST -+ for(int port = 0; port < MAPLE_NUM_PORTS; port++) -+ { -+ if(maple_controller[port].enabled) -+ { -+ mcfg_Create(MDT_SegaController, port, 5); -+ mcfg_Create(MDT_SegaVMU, port, 0); -+ mcfg_Create(MDT_SegaVMU, port, 1); -+ } -+ } -+ #else -+ mcfg_Create(MDT_NaomiJamma, 0, 5); -+ #endif - } - - void mcfg_DestroyDevices() -diff -Nur a/core/hw/maple/maple_controller.cpp b/core/hw/maple/maple_controller.cpp ---- a/core/hw/maple/maple_controller.cpp 1969-12-31 21:00:00.000000000 -0300 -+++ b/core/hw/maple/maple_controller.cpp 2016-01-18 21:35:15.480978214 -0300 -@@ -0,0 +1,8 @@ -+#include "hw/maple/maple_controller.h" -+ -+MapleController maple_controller[MAPLE_NUM_PORTS] = { -+ { 1 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 }, -+ { 0 , 0xFFFF, 0, 0, 0, 0 } -+}; -diff -Nur a/core/hw/maple/maple_controller.h b/core/hw/maple/maple_controller.h ---- a/core/hw/maple/maple_controller.h 1969-12-31 21:00:00.000000000 -0300 -+++ b/core/hw/maple/maple_controller.h 2016-01-18 21:35:15.480978214 -0300 -@@ -0,0 +1,42 @@ -+#pragma once -+#include "types.h" -+ -+// If you change the value of MAPLE_NUM_PORTS, please note that you need to change the initializers in maple_controller.cpp as well -+#define MAPLE_NUM_PORTS 4 -+ -+struct MapleController -+{ -+ bool enabled; -+ u16 buttons; -+ u8 trigger_left; -+ u8 trigger_right; -+ s8 stick_x; -+ s8 stick_y; -+}; -+ -+extern MapleController maple_controller[MAPLE_NUM_PORTS]; -+ -+enum MapleControllerCode -+{ -+ DC_BTN_C = 1, -+ DC_BTN_B = 1<<1, -+ DC_BTN_A = 1<<2, -+ DC_BTN_START = 1<<3, -+ DC_BTN_DPAD_UP = 1<<4, -+ DC_BTN_DPAD_DOWN = 1<<5, -+ DC_BTN_DPAD_LEFT = 1<<6, -+ DC_BTN_DPAD_RIGHT = 1<<7, -+ DC_BTN_Z = 1<<8, -+ DC_BTN_Y = 1<<9, -+ DC_BTN_X = 1<<10, -+ DC_BTN_D = 1<<11, -+ DC_BTN_DPAD2_UP = 1<<12, -+ DC_BTN_DPAD2_DOWN = 1<<13, -+ DC_BTN_DPAD2_LEFT = 1<<14, -+ DC_BTN_DPAD2_RIGHT = 1<<15, -+ -+ DC_AXIS_LT = 0X10000, -+ DC_AXIS_RT = 0X10001, -+ DC_AXIS_X = 0X20000, -+ DC_AXIS_Y = 0X20001 -+}; -diff -Nur a/core/linux-dist/evdev.cpp b/core/linux-dist/evdev.cpp ---- a/core/linux-dist/evdev.cpp 2016-01-18 21:29:18.672937639 -0300 -+++ b/core/linux-dist/evdev.cpp 2016-01-18 21:35:15.480978214 -0300 -@@ -314,43 +314,43 @@ - { - case EV_KEY: - if (ie.code == controller->mapping->Btn_A) { -- SET_FLAG(kcode[port], DC_BTN_A, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_A, ie.value); - } else if (ie.code == controller->mapping->Btn_B) { -- SET_FLAG(kcode[port], DC_BTN_B, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_B, ie.value); - } else if (ie.code == controller->mapping->Btn_C) { -- SET_FLAG(kcode[port], DC_BTN_C, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_C, ie.value); - } else if (ie.code == controller->mapping->Btn_D) { -- SET_FLAG(kcode[port], DC_BTN_D, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_D, ie.value); - } else if (ie.code == controller->mapping->Btn_X) { -- SET_FLAG(kcode[port], DC_BTN_X, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_X, ie.value); - } else if (ie.code == controller->mapping->Btn_Y) { -- SET_FLAG(kcode[port], DC_BTN_Y, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_Y, ie.value); - } else if (ie.code == controller->mapping->Btn_Z) { -- SET_FLAG(kcode[port], DC_BTN_Z, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_Z, ie.value); - } else if (ie.code == controller->mapping->Btn_Start) { -- SET_FLAG(kcode[port], DC_BTN_START, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_START, ie.value); - } else if (ie.code == controller->mapping->Btn_Escape) { - die("death by escape key"); - } else if (ie.code == controller->mapping->Btn_DPad_Left) { -- SET_FLAG(kcode[port], DC_DPAD_LEFT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad_Right) { -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad_Up) { -- SET_FLAG(kcode[port], DC_DPAD_UP, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad_Down) { -- SET_FLAG(kcode[port], DC_DPAD_DOWN, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Left) { -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Right) { -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Up) { -- SET_FLAG(kcode[port], DC_DPAD2_UP, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, ie.value); - } else if (ie.code == controller->mapping->Btn_DPad2_Down) { -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, ie.value); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, ie.value); - } else if (ie.code == controller->mapping->Btn_Trigger_Left) { -- lt[port] = (ie.value ? 255 : 0); -+ maple_controller[port].trigger_left = (ie.value ? 255 : 0); - } else if (ie.code == controller->mapping->Btn_Trigger_Right) { -- rt[port] = (ie.value ? 255 : 0); -+ maple_controller[port].trigger_right = (ie.value ? 255 : 0); - } - break; - case EV_ABS: -@@ -359,16 +359,16 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD_LEFT, 1); -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD_RIGHT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_RIGHT, 1); - break; - } - } -@@ -377,16 +377,16 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD_UP, 1); -- SET_FLAG(kcode[port], DC_DPAD_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD_DOWN, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD_DOWN, 1); - break; - } - } -@@ -395,16 +395,16 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, 1); -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD2_LEFT, 0); -- SET_FLAG(kcode[port], DC_DPAD2_RIGHT, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_LEFT, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_RIGHT, 1); - break; - } - } -@@ -413,34 +413,34 @@ - switch(ie.value) - { - case -1: -- SET_FLAG(kcode[port], DC_DPAD2_UP, 1); -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, 0); - break; - case 0: -- SET_FLAG(kcode[port], DC_DPAD2_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, 0); - break; - case 1: -- SET_FLAG(kcode[port], DC_DPAD2_UP, 0); -- SET_FLAG(kcode[port], DC_DPAD2_DOWN, 1); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_UP, 0); -+ SET_FLAG(maple_controller[port].buttons, DC_BTN_DPAD2_DOWN, 1); - break; - } - } - else if (ie.code == controller->mapping->Axis_Analog_X) - { -- joyx[port] = (controller->data_x.convert(ie.value) + 128); -+ maple_controller[port].stick_x = (controller->data_x.convert(ie.value) + 128); - } - else if (ie.code == controller->mapping->Axis_Analog_Y) - { -- joyy[port] = (controller->data_y.convert(ie.value) + 128); -+ maple_controller[port].stick_y = (controller->data_y.convert(ie.value) + 128); - } - else if (ie.code == controller->mapping->Axis_Trigger_Left) - { -- lt[port] = controller->data_trigger_left.convert(ie.value); -+ maple_controller[port].trigger_left = controller->data_trigger_left.convert(ie.value); - } - else if (ie.code == controller->mapping->Axis_Trigger_Right) - { -- rt[port] = controller->data_trigger_right.convert(ie.value); -+ maple_controller[port].trigger_right = controller->data_trigger_right.convert(ie.value); - } - break; - } -diff -Nur a/core/linux-dist/joystick.cpp b/core/linux-dist/joystick.cpp ---- a/core/linux-dist/joystick.cpp 2016-01-18 21:29:18.672937639 -0300 -+++ b/core/linux-dist/joystick.cpp 2016-01-18 21:35:15.480978214 -0300 -@@ -9,7 +9,7 @@ - const u32 joystick_map_axis_usb[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, 0, 0, 0, 0, 0, 0, 0, 0 }; - - const u32 joystick_map_btn_xbox360[JOYSTICK_MAP_SIZE] = { DC_BTN_A, DC_BTN_B, DC_BTN_X, DC_BTN_Y, 0, 0, 0, DC_BTN_START, 0, 0 }; -- const u32 joystick_map_axis_xbox360[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_DPAD_LEFT, DC_DPAD_UP, 0, 0 }; -+ const u32 joystick_map_axis_xbox360[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_BTN_DPAD_LEFT, DC_BTN_DPAD_UP, 0, 0 }; - - const u32* joystick_map_btn = joystick_map_btn_usb; - const u32* joystick_map_axis = joystick_map_axis_usb; -@@ -73,18 +73,18 @@ - - if (mt == 0) - { -- kcode[port] |= mo; -- kcode[port] |= mo*2; -+ maple_controller[port].buttons |= mo; -+ maple_controller[port].buttons |= mo*2; - if (v<-64) - { -- kcode[port] &= ~mo; -+ maple_controller[port].buttons &= ~mo; - } - else if (v>64) - { -- kcode[port] &= ~(mo*2); -+ maple_controller[port].buttons &= ~(mo*2); - } - -- //printf("Mapped to %d %d %d\n",mo,kcode[port]&mo,kcode[port]&(mo*2)); -+ //printf("Mapped to %d %d %d\n",mo,maple_controller[port].buttons&mo,maple_controller[port].buttons&(mo*2)); - } - else if (mt == 1) - { -@@ -95,11 +95,11 @@ - //printf("AXIS %d,%d Mapped to %d %d %d\n",JE.number,JE.value,mo,v,v+127); - if (mo == 0) - { -- lt[port] = (v + 127); -+ maple_controller[port].trigger_left = (v + 127); - } - else if (mo == 1) - { -- rt[port] = (v + 127); -+ maple_controller[port].trigger_right = (v + 127); - } - } - else if (mt == 2) -@@ -107,11 +107,11 @@ - // printf("AXIS %d,%d Mapped to %d %d [%d]",JE.number,JE.value,mo,v); - if (mo == 0) - { -- joyx[port] = v; -+ maple_controller[port].stick_x = v; - } - else if (mo == 1) - { -- joyy[port] = v; -+ maple_controller[port].stick_y = v; - } - } - } -@@ -129,11 +129,11 @@ - // printf("Mapped to %d\n",mo); - if (JE.value) - { -- kcode[port] &= ~mo; -+ maple_controller[port].buttons &= ~mo; - } - else - { -- kcode[port] |= mo; -+ maple_controller[port].buttons |= mo; - } - } - else if (mt == 1) -@@ -141,11 +141,11 @@ - // printf("Mapped to %d %d\n",mo,JE.value?255:0); - if (mo==0) - { -- lt[port] = JE.value ? 255 : 0; -+ maple_controller[port].trigger_left = JE.value ? 255 : 0; - } - else if (mo==1) - { -- rt[port] = JE.value ? 255 : 0; -+ maple_controller[port].trigger_right = JE.value ? 255 : 0; - } - } - } -diff -Nur a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp ---- a/core/linux-dist/main.cpp 2016-01-18 21:29:18.673937648 -0300 -+++ b/core/linux-dist/main.cpp 2016-01-18 21:35:15.480978214 -0300 -@@ -76,22 +76,11 @@ - return x11_disp; - } - --u16 kcode[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; --u8 rt[4] = {0, 0, 0, 0}; --u8 lt[4] = {0, 0, 0, 0}; --u32 vks[4]; --s8 joyx[4], joyy[4]; -- - void emit_WriteCodeCache(); - - #if defined(USE_EVDEV) - /* evdev input */ -- static EvdevController evdev_controllers[4] = { -- { -1, NULL }, -- { -1, NULL }, -- { -1, NULL }, -- { -1, NULL } -- }; -+ static EvdevController evdev_controllers[MAPLE_NUM_PORTS]; - #endif - - #if defined(USE_JOYSTICK) -@@ -102,14 +91,17 @@ - void SetupInput() - { - #if defined(USE_EVDEV) -- int evdev_device_id[4] = { -1, -1, -1, -1 }; -+ int evdev_device_id[MAPLE_NUM_PORTS]; - size_t size_needed; - int port, i; - - char* evdev_device; - -- for (port = 0; port < 4; port++) -+ for (port = 0; port < MAPLE_NUM_PORTS; port++) - { -+ evdev_controllers[port] = { -1, NULL }; -+ evdev_device_id[port] = -1; -+ - size_needed = snprintf(NULL, 0, EVDEV_DEVICE_CONFIG_KEY, port+1) + 1; - char* evdev_config_key = (char*)malloc(size_needed); - sprintf(evdev_config_key, EVDEV_DEVICE_CONFIG_KEY, port+1); -@@ -142,6 +134,7 @@ - free(evdev_config_key); - - input_evdev_init(&evdev_controllers[port], evdev_device, mapping); -+ maple_controller[port].enabled = true; - - free(evdev_device); - } -diff -Nur a/core/linux-dist/main.h b/core/linux-dist/main.h ---- a/core/linux-dist/main.h 2016-01-18 21:29:18.673937648 -0300 -+++ b/core/linux-dist/main.h 2016-01-18 21:35:15.480978214 -0300 -@@ -1,35 +1,6 @@ - #pragma once - #include "types.h" -- --extern u16 kcode[4]; --extern u32 vks[4]; --extern u8 rt[4], lt[4]; --extern s8 joyx[4], joyy[4]; -+#include "hw/maple/maple_controller.h" - - extern void* x11_win; - extern void* x11_disp; -- --enum DreamcastController --{ -- DC_BTN_C = 1, -- DC_BTN_B = 1<<1, -- DC_BTN_A = 1<<2, -- DC_BTN_START = 1<<3, -- DC_DPAD_UP = 1<<4, -- DC_DPAD_DOWN = 1<<5, -- DC_DPAD_LEFT = 1<<6, -- DC_DPAD_RIGHT = 1<<7, -- DC_BTN_Z = 1<<8, -- DC_BTN_Y = 1<<9, -- DC_BTN_X = 1<<10, -- DC_BTN_D = 1<<11, -- DC_DPAD2_UP = 1<<12, -- DC_DPAD2_DOWN = 1<<13, -- DC_DPAD2_LEFT = 1<<14, -- DC_DPAD2_RIGHT = 1<<15, -- -- DC_AXIS_LT = 0X10000, -- DC_AXIS_RT = 0X10001, -- DC_AXIS_X = 0X20000, -- DC_AXIS_Y = 0X20001, --}; -diff -Nur a/core/linux-dist/x11.cpp b/core/linux-dist/x11.cpp ---- a/core/linux-dist/x11.cpp 2016-01-18 21:29:18.673937648 -0300 -+++ b/core/linux-dist/x11.cpp 2016-01-18 21:35:15.481978222 -0300 -@@ -101,11 +101,11 @@ - int dc_key = x11_keymap[e.xkey.keycode]; - if (e.type == KeyPress) - { -- kcode[0] &= ~dc_key; -+ maple_controller[0].buttons &= ~dc_key; - } - else - { -- kcode[0] |= dc_key; -+ maple_controller[0].buttons |= dc_key; - } - } - //printf("KEY: %d -> %d: %d\n",e.xkey.keycode, dc_key, x11_dc_buttons ); -@@ -117,11 +117,11 @@ - - void input_x11_init() - { -- x11_keymap[113] = DC_DPAD_LEFT; -- x11_keymap[114] = DC_DPAD_RIGHT; -+ x11_keymap[113] = DC_BTN_DPAD_LEFT; -+ x11_keymap[114] = DC_BTN_DPAD_RIGHT; - -- x11_keymap[111] = DC_DPAD_UP; -- x11_keymap[116] = DC_DPAD_DOWN; -+ x11_keymap[111] = DC_BTN_DPAD_UP; -+ x11_keymap[116] = DC_BTN_DPAD_DOWN; - - x11_keymap[53] = DC_BTN_X; - x11_keymap[54] = DC_BTN_B; -diff -Nur a/core/nacl/nacl.cpp b/core/nacl/nacl.cpp ---- a/core/nacl/nacl.cpp 2016-01-18 21:29:18.673937648 -0300 -+++ b/core/nacl/nacl.cpp 2016-01-18 21:35:15.481978222 -0300 -@@ -15,6 +15,7 @@ - #include "ppapi/utility/completion_callback_factory.h" - - #include "types.h" -+#include "hw/maple/maple_controller.h" - - #include <GLES2/gl2.h> - -@@ -235,12 +236,6 @@ - } - } // namespace pp - -- --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - int get_mic_data(u8* buffer) { return 0; } - int push_vmu_screen(u8* buffer) { return 0; } - -diff -Nur a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp ---- a/core/rend/gles/gles.cpp 2016-01-18 21:29:18.677937682 -0300 -+++ b/core/rend/gles/gles.cpp 2016-01-18 21:35:15.481978222 -0300 -@@ -2,6 +2,7 @@ - #include "gles.h" - #include "rend/TexCache.h" - #include "cfg/cfg.h" -+#include "hw/maple/maple_controller.h" - - #ifdef TARGET_PANDORA - #include <unistd.h> -@@ -1043,28 +1044,6 @@ - //printf("%f\n",B*log(maxdev)/log(2.0)+A); - } - -- -- --extern u16 kcode[4]; --extern u8 rt[4],lt[4]; -- --#define key_CONT_C (1 << 0) --#define key_CONT_B (1 << 1) --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_UP (1 << 4) --#define key_CONT_DPAD_DOWN (1 << 5) --#define key_CONT_DPAD_LEFT (1 << 6) --#define key_CONT_DPAD_RIGHT (1 << 7) --#define key_CONT_Z (1 << 8) --#define key_CONT_Y (1 << 9) --#define key_CONT_X (1 << 10) --#define key_CONT_D (1 << 11) --#define key_CONT_DPAD2_UP (1 << 12) --#define key_CONT_DPAD2_DOWN (1 << 13) --#define key_CONT_DPAD2_LEFT (1 << 14) --#define key_CONT_DPAD2_RIGHT (1 << 15) -- - u32 osd_base; - u32 osd_count; - -@@ -1260,21 +1239,21 @@ - osd_count=0; - - #ifndef TARGET_PANDORA -- DrawButton2(vjoy_pos[0],kcode[0]&key_CONT_DPAD_LEFT); -- DrawButton2(vjoy_pos[1],kcode[0]&key_CONT_DPAD_UP); -- DrawButton2(vjoy_pos[2],kcode[0]&key_CONT_DPAD_RIGHT); -- DrawButton2(vjoy_pos[3],kcode[0]&key_CONT_DPAD_DOWN); -+ DrawButton2(vjoy_pos[0], maple_controller[0].buttons & DC_BTN_DPAD_LEFT); -+ DrawButton2(vjoy_pos[1], maple_controller[0].buttons & DC_BTN_DPAD_UP); -+ DrawButton2(vjoy_pos[2], maple_controller[0].buttons & DC_BTN_DPAD_RIGHT); -+ DrawButton2(vjoy_pos[3], maple_controller[0].buttons & DC_BTN_DPAD_DOWN); - -- DrawButton2(vjoy_pos[4],kcode[0]&key_CONT_X); -- DrawButton2(vjoy_pos[5],kcode[0]&key_CONT_Y); -- DrawButton2(vjoy_pos[6],kcode[0]&key_CONT_B); -- DrawButton2(vjoy_pos[7],kcode[0]&key_CONT_A); -+ DrawButton2(vjoy_pos[4], maple_controller[0].buttons & DC_BTN_X); -+ DrawButton2(vjoy_pos[5], maple_controller[0].buttons & DC_BTN_Y); -+ DrawButton2(vjoy_pos[6], maple_controller[0].buttons & DC_BTN_B); -+ DrawButton2(vjoy_pos[7], maple_controller[0].buttons & DC_BTN_A); - -- DrawButton2(vjoy_pos[8],kcode[0]&key_CONT_START); -+ DrawButton2(vjoy_pos[8], maple_controller[0].buttons & DC_BTN_START); - -- DrawButton(vjoy_pos[9],lt[0]); -+ DrawButton(vjoy_pos[9], maple_controller[0].trigger_left); - -- DrawButton(vjoy_pos[10],rt[0]); -+ DrawButton(vjoy_pos[10], maple_controller[0].trigger_right); - - DrawButton2(vjoy_pos[11],1); - DrawButton2(vjoy_pos[12],0); -@@ -1818,8 +1797,6 @@ - #endif - #endif - --extern u16 kcode[4]; -- - /* - bool rend_single_frame() - { -@@ -1833,7 +1810,7 @@ - } - - bool do_swp=false; -- //if (kcode[0]&(1<<9)) -+ //if (maple_controller[0].buttons&(1<<9)) - { - - -diff -Nur a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp ---- a/core/sdl/sdl.cpp 2016-01-18 21:29:18.678937690 -0300 -+++ b/core/sdl/sdl.cpp 2016-01-18 21:35:15.481978222 -0300 -@@ -41,7 +41,7 @@ - { DC_BTN_A, DC_BTN_B, DC_BTN_X, DC_BTN_Y, 0, 0, 0, DC_BTN_START, 0, 0 }; - - const u32 sdl_map_axis_xbox360[SDL_MAP_SIZE] = -- { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_DPAD_LEFT, DC_DPAD_UP, 0, 0 }; -+ { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, 0, 0, DC_AXIS_RT, DC_BTN_DPAD_LEFT, DC_BTN_DPAD_UP, 0, 0 }; - - const u32* sdl_map_btn = sdl_map_btn_usb; - const u32* sdl_map_axis = sdl_map_axis_usb; -@@ -206,20 +206,20 @@ - { - // printf("Mapped to %d\n",mo); - if (value) -- kcode[port] &= ~mo; -+ maple_controller[port].buttons &= ~mo; - else -- kcode[port] |= mo; -+ maple_controller[port].buttons |= mo; - } - else if (mt == 1) - { - // printf("Mapped to %d %d\n",mo,JE.value?255:0); - if (mo == 0) - { -- lt[port] = value ? 255 : 0; -+ maple_controller[port].trigger_left = value ? 255 : 0; - } - else if (mo == 1) - { -- rt[port] = value ? 255 : 0; -+ maple_controller[port].trigger_right = value ? 255 : 0; - } - } - -@@ -240,18 +240,18 @@ - - if (mt == 0) - { -- kcode[port] |= mo; -- kcode[port] |= mo*2; -+ maple_controller[port].buttons |= mo; -+ maple_controller[port].buttons |= mo*2; - if (v < -64) - { -- kcode[port] &= ~mo; -+ maple_controller[port].buttons &= ~mo; - } - else if (v > 64) - { -- kcode[port] &= ~(mo*2); -+ maple_controller[port].buttons &= ~(mo*2); - } - -- // printf("Mapped to %d %d %d\n",mo,kcode[port]&mo,kcode[port]&(mo*2)); -+ // printf("Mapped to %d %d %d\n",mo,maple_controller[port].buttons&mo,maple_controller[port].buttons&(mo*2)); - } - else if (mt == 1) - { -@@ -261,11 +261,11 @@ - - if (mo == 0) - { -- lt[port] = v + 127; -+ maple_controller[port].trigger_left = v + 127; - } - else if (mo == 1) - { -- rt[port] = v + 127; -+ maple_controller[port].trigger_right = v + 127; - } - } - else if (mt == 2) -@@ -273,11 +273,11 @@ - // printf("AXIS %d,%d Mapped to %d %d [%d]",JE.number,JE.value,mo,v); - if (mo == 0) - { -- joyx[port] = v; -+ maple_controller[port].stick_x = v; - } - else if (mo==1) - { -- joyy[port] = v; -+ maple_controller[port].stick_y = v; - } - } - } -@@ -325,39 +325,39 @@ - case 1: // Up=RT, Down=LT - if (yy<0) - { -- rt[port] = -yy; -+ maple_controller[port].trigger_right = -yy; - } - else if (yy>0) - { -- lt[port] = yy; -+ maple_controller[port].trigger_left = yy; - } - break; - case 2: // Left=LT, Right=RT - if (xx < 0) - { -- lt[port] = -xx; -+ maple_controller[port].trigger_left = -xx; - } - else if (xx > 0) - { -- rt[port] = xx; -+ maple_controller[port].trigger_right = xx; - } - break; - case 3: // Nub = ABXY - if (xx < -127) - { -- kcode[port] &= ~DC_BTN_X; -+ maple_controller[port].buttons &= ~DC_BTN_X; - } - else if (xx > 127) - { -- kcode[port] &= ~DC_BTN_B; -+ maple_controller[port].buttons &= ~DC_BTN_B; - } - if (yy < -127) - { -- kcode[port] &= ~DC_BTN_Y; -+ maple_controller[port].buttons &= ~DC_BTN_Y; - } - else if (yy > 127) - { -- kcode[port] &= ~DC_BTN_A; -+ maple_controller[port].buttons &= ~DC_BTN_A; - } - break; - } -@@ -365,16 +365,16 @@ - } - } - -- if (keys[0]) { kcode[port] &= ~DC_BTN_C; } -- if (keys[6]) { kcode[port] &= ~DC_BTN_A; } -- if (keys[7]) { kcode[port] &= ~DC_BTN_B; } -- if (keys[5]) { kcode[port] &= ~DC_BTN_Y; } -- if (keys[8]) { kcode[port] &= ~DC_BTN_X; } -- if (keys[1]) { kcode[port] &= ~DC_DPAD_UP; } -- if (keys[2]) { kcode[port] &= ~DC_DPAD_DOWN; } -- if (keys[3]) { kcode[port] &= ~DC_DPAD_LEFT; } -- if (keys[4]) { kcode[port] &= ~DC_DPAD_RIGHT; } -- if (keys[12]){ kcode[port] &= ~DC_BTN_START; } -+ if (keys[0]) { maple_controller[port].buttons &= ~DC_BTN_C; } -+ if (keys[6]) { maple_controller[port].buttons &= ~DC_BTN_A; } -+ if (keys[7]) { maple_controller[port].buttons &= ~DC_BTN_B; } -+ if (keys[5]) { maple_controller[port].buttons &= ~DC_BTN_Y; } -+ if (keys[8]) { maple_controller[port].buttons &= ~DC_BTN_X; } -+ if (keys[1]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_UP; } -+ if (keys[2]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_DOWN; } -+ if (keys[3]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_LEFT; } -+ if (keys[4]) { maple_controller[port].buttons &= ~DC_BTN_DPAD_RIGHT; } -+ if (keys[12]){ maple_controller[port].buttons &= ~DC_BTN_START; } - if (keys[9]) - { - dc_term(); -@@ -384,11 +384,11 @@ - } - if (keys[10]) - { -- rt[port] = 255; -+ maple_controller[port].trigger_right = 255; - } - if (keys[11]) - { -- lt[port] = 255; -+ maple_controller[port].trigger_left = 255; - } - } - -diff -Nur a/core/windows/winmain.cpp b/core/windows/winmain.cpp ---- a/core/windows/winmain.cpp 2016-01-18 21:29:18.679937699 -0300 -+++ b/core/windows/winmain.cpp 2016-01-18 21:35:15.482978230 -0300 -@@ -1,5 +1,6 @@ - #include "oslib\oslib.h" - #include "oslib\audiostream.h" -+#include "hw\maple\maple_controller.h" - #include "imgread\common.h" - - #define _WIN32_WINNT 0x0500 -@@ -174,66 +175,46 @@ - return MessageBox(NULL,temp,VER_SHORTNAME,type | MB_TASKMODAL); - } - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; --#define key_CONT_C (1 << 0) --#define key_CONT_B (1 << 1) --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_UP (1 << 4) --#define key_CONT_DPAD_DOWN (1 << 5) --#define key_CONT_DPAD_LEFT (1 << 6) --#define key_CONT_DPAD_RIGHT (1 << 7) --#define key_CONT_Z (1 << 8) --#define key_CONT_Y (1 << 9) --#define key_CONT_X (1 << 10) --#define key_CONT_D (1 << 11) --#define key_CONT_DPAD2_UP (1 << 12) --#define key_CONT_DPAD2_DOWN (1 << 13) --#define key_CONT_DPAD2_LEFT (1 << 14) --#define key_CONT_DPAD2_RIGHT (1 << 15) - void UpdateInputState(u32 port) - { -- //joyx[port]=pad.Lx; -- //joyy[port]=pad.Ly; -- lt[port]=GetAsyncKeyState('A')?255:0; -- rt[port]=GetAsyncKeyState('S')?255:0; -+ //maple_controller[port].stick_x = pad.Lx; -+ //maple_controller[port].stick_y = pad.Ly; -+ maple_controller[port].trigger_left = GetAsyncKeyState('A') ? 255 : 0; -+ maple_controller[port].trigger_right = GetAsyncKeyState('S') ? 255 : 0; - -- joyx[port]=joyy[port]=0; -+ maple_controller[port].stick_x = maple_controller[port].stick_y = 0; - - if (GetAsyncKeyState('J')) -- joyx[port]-=126; -+ maple_controller[port].stick_x -= 126; - if (GetAsyncKeyState('L')) -- joyx[port]+=126; -+ maple_controller[port].stick_x += 126; - - if (GetAsyncKeyState('I')) -- joyy[port]-=126; -+ maple_controller[port].stick_y -= 126; - if (GetAsyncKeyState('K')) -- joyy[port]+=126; -+ maple_controller[port].stick_y += 126; - -- kcode[port]=0xFFFF; -+ maple_controller[port].buttons = 0xFFFF; - if (GetAsyncKeyState('V')) -- kcode[port]&=~key_CONT_A; -+ maple_controller[port].buttons &= ~DC_BTN_A; - if (GetAsyncKeyState('C')) -- kcode[port]&=~key_CONT_B; -+ maple_controller[port].buttons &= ~DC_BTN_B; - if (GetAsyncKeyState('X')) -- kcode[port]&=~key_CONT_Y; -+ maple_controller[port].buttons &= ~DC_BTN_Y; - if (GetAsyncKeyState('Z')) -- kcode[port]&=~key_CONT_X; -+ maple_controller[port].buttons &= ~DC_BTN_X; - - if (GetAsyncKeyState(VK_SHIFT)) -- kcode[port]&=~key_CONT_START; -+ maple_controller[port].buttons &= ~DC_BTN_START; - - if (GetAsyncKeyState(VK_UP)) -- kcode[port]&=~key_CONT_DPAD_UP; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_UP; - if (GetAsyncKeyState(VK_DOWN)) -- kcode[port]&=~key_CONT_DPAD_DOWN; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_DOWN; - if (GetAsyncKeyState(VK_LEFT)) -- kcode[port]&=~key_CONT_DPAD_LEFT; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_LEFT; - if (GetAsyncKeyState(VK_RIGHT)) -- kcode[port]&=~key_CONT_DPAD_RIGHT; -+ maple_controller[port].buttons &= ~DC_BTN_DPAD_RIGHT; - - if (GetAsyncKeyState(VK_F1)) - settings.pvr.ta_skip = 100; -diff -Nur a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp ---- a/shell/android/jni/src/Android.cpp 2016-01-18 21:29:18.705937922 -0300 -+++ b/shell/android/jni/src/Android.cpp 2016-01-18 21:35:15.482978230 -0300 -@@ -16,6 +16,7 @@ - #include "rend/TexCache.h" - #include "hw/maple/maple_devs.h" - #include "hw/maple/maple_if.h" -+#include "hw/maple/maple_controller.h" - #include "oslib/audiobackend_android.h" - - #include "util.h" -@@ -175,10 +176,6 @@ - // Additonal controllers 2, 3 and 4 connected ? - static bool add_controllers[3] = { false, false, false }; - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; - float vjoy_pos[14][8]; - - extern bool print_stats; -@@ -211,7 +208,7 @@ - } - - // Add additonal controllers -- for (int i = 0; i < 3; i++) -+ for (int i = 0; i < (MAPLE_NUM_PORTS - 1); i++) - { - if (add_controllers[i]) - mcfg_Create(MDT_SegaController,i+1,5); -@@ -445,13 +442,13 @@ - jint *jx_body = env->GetIntArrayElements(jx, 0); - jint *jy_body = env->GetIntArrayElements(jy, 0); - -- for(int i = 0; i < 4; i++) -+ for(int i = 0; i < MAPLE_NUM_PORTS; i++) - { -- kcode[i] = k_code_body[i]; -- lt[i] = l_t_body[i]; -- rt[i] = r_t_body[i]; -- joyx[i] = jx_body[i]; -- joyy[i] = jy_body[i]; -+ maple_controller[i].buttons = k_code_body[i]; -+ maple_controller[i].trigger_left = l_t_body[i]; -+ maple_controller[i].trigger_right = r_t_body[i]; -+ maple_controller[i].stick_x = jx_body[i]; -+ maple_controller[i].stick_y = jy_body[i]; - } - - env->ReleaseIntArrayElements(k_code, k_code_body, 0); -diff -Nur a/shell/apple/emulator-ios/emulator/EmulatorView.mm b/shell/apple/emulator-ios/emulator/EmulatorView.mm ---- a/shell/apple/emulator-ios/emulator/EmulatorView.mm 2016-01-18 21:29:18.777938539 -0300 -+++ b/shell/apple/emulator-ios/emulator/EmulatorView.mm 2016-01-18 21:35:15.482978230 -0300 -@@ -9,15 +9,7 @@ - #import "EmulatorView.h" - - #include "types.h" -- --extern u16 kcode[4]; --extern u32 vks[4]; --extern s8 joyx[4],joyy[4]; --extern u8 rt[4],lt[4]; -- --#define key_CONT_A (1 << 2) --#define key_CONT_START (1 << 3) --#define key_CONT_DPAD_LEFT (1 << 6) -+#include "hw/maple/maple_controller.h" - - int dpad_or_btn = 0; - -@@ -34,9 +26,9 @@ - -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - - if (dpad_or_btn &1) -- kcode[0] &= ~(key_CONT_START|key_CONT_A); -+ maple_controller[0].buttons &= ~(DC_BTN_START|DC_BTN_A); - else -- kcode[0] &= ~(key_CONT_DPAD_LEFT); -+ maple_controller[0].buttons &= ~(DC_BTN_DPAD_LEFT); - } - - -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { -@@ -44,9 +36,9 @@ - // [event allTouches]; - - if (dpad_or_btn &1) -- kcode[0] |= (key_CONT_START|key_CONT_A); -+ maple_controller[0].buttons |= (DC_BTN_START|DC_BTN_A); - else -- kcode[0] |= (key_CONT_DPAD_LEFT); -+ maple_controller[0].buttons |= (DC_BTN_DPAD_LEFT); - - dpad_or_btn++; - } -diff -Nur a/shell/apple/emulator-ios/emulator/ios_main.mm b/shell/apple/emulator-ios/emulator/ios_main.mm ---- a/shell/apple/emulator-ios/emulator/ios_main.mm 2016-01-18 21:29:18.780938565 -0300 -+++ b/shell/apple/emulator-ios/emulator/ios_main.mm 2016-01-18 21:35:15.482978230 -0300 -@@ -20,6 +20,7 @@ - #include <sys/mman.h> - #include <sys/time.h> - #include "hw/sh4/dyna/blockmanager.h" -+#include "hw/maple/maple_controller.h" - #include <unistd.h> - - -@@ -55,11 +56,6 @@ - int dc_init(int argc,wchar* argv[]); - void dc_run(); - --u16 kcode[4]; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - extern "C" int reicast_main(int argc, wchar* argv[]) - { - //if (argc==2) -diff -Nur a/shell/apple/emulator-osx/emulator-osx/osx-main.mm b/shell/apple/emulator-osx/emulator-osx/osx-main.mm ---- a/shell/apple/emulator-osx/emulator-osx/osx-main.mm 2016-01-18 21:29:18.782938582 -0300 -+++ b/shell/apple/emulator-osx/emulator-osx/osx-main.mm 2016-01-18 21:35:15.482978230 -0300 -@@ -8,6 +8,7 @@ - #import <Carbon/Carbon.h> - - #include "types.h" -+#include "hw/maple/maple_controller.h" - #include <sys/stat.h> - - #include <OpenGL/gl3.h> -@@ -38,11 +39,6 @@ - return 0; - } - --u16 kcode[4] = { 0xFFFF }; --u32 vks[4]; --s8 joyx[4],joyy[4]; --u8 rt[4],lt[4]; -- - int get_mic_data(u8* buffer) { return 0; } - int push_vmu_screen(u8* buffer) { return 0; } - -@@ -135,35 +131,11 @@ - gles_init(); - } - --enum DCPad { -- Btn_C = 1, -- Btn_B = 1<<1, -- Btn_A = 1<<2, -- Btn_Start = 1<<3, -- DPad_Up = 1<<4, -- DPad_Down = 1<<5, -- DPad_Left = 1<<6, -- DPad_Right = 1<<7, -- Btn_Z = 1<<8, -- Btn_Y = 1<<9, -- Btn_X = 1<<10, -- Btn_D = 1<<11, -- DPad2_Up = 1<<12, -- DPad2_Down = 1<<13, -- DPad2_Left = 1<<14, -- DPad2_Right = 1<<15, -- -- Axis_LT= 0x10000, -- Axis_RT= 0x10001, -- Axis_X= 0x20000, -- Axis_Y= 0x20001, --}; -- - void handle_key(int dckey, int state) { - if (state) -- kcode[0] &= ~dckey; -+ maple_controller[0].buttons &= ~dckey; - else -- kcode[0] |= dckey; -+ maple_controller[0].buttons |= dckey; - } - - void handle_trig(u8* dckey, int state) { -@@ -176,18 +148,18 @@ - extern "C" void emu_key_input(char* keyt, int state) { - int key = keyt[0]; - switch(key) { -- case 'z': handle_key(Btn_X, state); break; -- case 'x': handle_key(Btn_Y, state); break; -- case 'c': handle_key(Btn_B, state); break; -- case 'v': handle_key(Btn_A, state); break; -+ case 'z': handle_key(DC_BTN_X, state); break; -+ case 'x': handle_key(DC_BTN_Y, state); break; -+ case 'c': handle_key(DC_BTN_B, state); break; -+ case 'v': handle_key(DC_BTN_A, state); break; - - case 'a': handle_trig(lt, state); break; - case 's': handle_trig(rt, state); break; - -- case 'j': handle_key(DPad_Left, state); break; -- case 'k': handle_key(DPad_Down, state); break; -- case 'l': handle_key(DPad_Right, state); break; -- case 'i': handle_key(DPad_Up, state); break; -- case 0xa: handle_key(Btn_Start, state); break; -+ case 'j': handle_key(DC_BTN_DPAD_LEFT, state); break; -+ case 'k': handle_key(DC_BTN_DPAD_DOWN, state); break; -+ case 'l': handle_key(DC_BTN_DPAD_RIGHT, state); break; -+ case 'i': handle_key(DC_BTN_DPAD_UP, state); break; -+ case 0xa: handle_key(DC_BTN_START, state); break; - } - } -\ No newline at end of file -diff -Nur a/shell/reicast.vcxproj b/shell/reicast.vcxproj ---- a/shell/reicast.vcxproj 2016-01-18 21:29:18.820938908 -0300 -+++ b/shell/reicast.vcxproj 2016-01-18 21:35:15.483978239 -0300 -@@ -92,6 +92,7 @@ - <ClCompile Include="..\core\hw\holly\sb_dma.cpp" /> - <ClCompile Include="..\core\hw\holly\sb_mem.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_cfg.cpp" /> -+ <ClCompile Include="..\core\hw\maple\maple_controller.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_devs.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_helper.cpp" /> - <ClCompile Include="..\core\hw\maple\maple_if.cpp" /> |