flycast/core/hw/maple/maple_cfg.cpp

124 lines
2.5 KiB
C++
Raw Normal View History

2013-12-19 17:10:14 +00:00
#include "types.h"
#include "maple_if.h"
#include "maple_helper.h"
#include "maple_devs.h"
#include "maple_cfg.h"
#include "cfg/cfg.h"
2013-12-19 17:10:14 +00:00
#define HAS_VMU
2013-12-19 17:10:14 +00:00
/*
bus_x=0{p0=1{config};p1=2{config};config;}
Plugins:
Input Source
EventMap -- 'Raw' interface, source_name[seid]:mode
KeyMap -- translated chars ( no re-mapping possible)
Output
Image
2018-08-13 11:00:24 +00:00
2013-12-19 17:10:14 +00:00
*/
/*
MapleConfig:
InputUpdate(&fmt);
ImageUpdate(data);
*/
void UpdateInputState(u32 port);
void UpdateVibration(u32 port, u32 value);
2013-12-19 17:10:14 +00:00
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;
}
struct MapleConfigMap : IMapleConfigMap
{
maple_device* dev;
MapleConfigMap(maple_device* dev)
{
this->dev=dev;
}
void SetVibration(u32 value)
{
UpdateVibration(dev->bus_id, value);
}
2013-12-19 17:10:14 +00:00
void GetInput(PlainJoystickState* pjs)
{
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];
}
void SetImage(void* img)
{
//?
}
};
2018-08-13 11:00:24 +00:00
void mcfg_Create(MapleDeviceType type, u32 bus, u32 port)
2013-12-19 17:10:14 +00:00
{
2018-08-13 11:00:24 +00:00
maple_device* dev = maple_Create(type);
dev->Setup(maple_GetAddress(bus, port));
2013-12-19 17:10:14 +00:00
dev->config = new MapleConfigMap(dev);
dev->OnSetup();
2018-08-13 11:00:24 +00:00
MapleDevices[bus][port] = dev;
2013-12-19 17:10:14 +00:00
}
void mcfg_CreateNAOMIJamma()
2013-12-19 17:10:14 +00:00
{
mcfg_Create(MDT_NaomiJamma, 0, 5);
}
void mcfg_CreateController(u32 bus, MapleDeviceType maple_type1, MapleDeviceType maple_type2)
{
mcfg_Create(MDT_SegaController, bus, 5);
if (maple_type1 != MDT_None)
mcfg_Create(maple_type1, bus, 0);
if (maple_type2 != MDT_None)
mcfg_Create(maple_type2, bus, 1);
}
void mcfg_CreateDevicesFromConfig()
2013-12-19 17:10:14 +00:00
{
// Create the configure controller count
2018-08-13 11:00:24 +00:00
int numberOfControl = cfgLoadInt("players", "nb", 1);
if (numberOfControl <= 0)
numberOfControl = 1;
if (numberOfControl > 4)
numberOfControl = 4;
for (int i = 0; i < numberOfControl; i++)
{
mcfg_Create(MDT_SegaController, i, 5);
// Default to two VMUs on each controller
mcfg_Create(MDT_SegaVMU, i, 0);
mcfg_Create(MDT_SegaVMU, i, 1);
}
2018-09-18 07:27:16 +00:00
if (settings.input.DCKeyboard && numberOfControl < 4)
mcfg_Create(MDT_Keyboard, numberOfControl++, 5);
2018-09-18 07:27:16 +00:00
if (settings.input.DCMouse != 0 && numberOfControl < 4)
mcfg_Create(MDT_Mouse, numberOfControl++, 5);
}
2013-12-19 17:10:14 +00:00
void mcfg_DestroyDevices()
{
for (int i=0;i<=3;i++)
for (int j=0;j<=5;j++)
2013-12-19 17:10:14 +00:00
delete MapleDevices[i][j];
}