Zapper: Make sure zapper works with all overscan configurations & any video video (ntsc, etc.)
This commit is contained in:
parent
3845c859a3
commit
361f4b8025
7 changed files with 19 additions and 11 deletions
|
@ -237,7 +237,7 @@ bool ControlManager::HasZapper()
|
|||
return GetZapper(0) != nullptr || GetZapper(1) != nullptr;
|
||||
}
|
||||
|
||||
void ControlManager::ZapperSetPosition(uint8_t port, int32_t x, int32_t y)
|
||||
void ControlManager::ZapperSetPosition(uint8_t port, double x, double y)
|
||||
{
|
||||
shared_ptr<Zapper> zapper = GetZapper(port);
|
||||
if(zapper) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class ControlManager : public Snapshotable, public IMemoryHandler
|
|||
static shared_ptr<BaseControlDevice> GetControlDevice(uint8_t port);
|
||||
|
||||
static bool HasZapper();
|
||||
static void ZapperSetPosition(uint8_t port, int32_t x, int32_t y);
|
||||
static void ZapperSetPosition(uint8_t port, double x, double y);
|
||||
static void ZapperSetTriggerState(uint8_t port, bool pulled);
|
||||
|
||||
static void BroadcastInput(uint8_t port, uint8_t state);
|
||||
|
|
|
@ -22,10 +22,17 @@ void Zapper::StreamState(bool saving)
|
|||
Stream<bool>(_pulled);
|
||||
}
|
||||
|
||||
void Zapper::SetPosition(int32_t x, int32_t y)
|
||||
void Zapper::SetPosition(double x, double y)
|
||||
{
|
||||
_xPosition = x;
|
||||
_yPosition = y;
|
||||
uint32_t scale = EmulationSettings::GetVideoScale();
|
||||
OverscanDimensions overscan = EmulationSettings::GetOverscanDimensions();
|
||||
if(x < 0 || y < 0) {
|
||||
_xPosition = -1;
|
||||
_yPosition = -1;
|
||||
} else {
|
||||
_xPosition = (int32_t)(x * (PPU::ScreenWidth - overscan.Left - overscan.Right) + overscan.Left);
|
||||
_yPosition = (int32_t)(y * (PPU::ScreenHeight - overscan.Top - overscan.Bottom) + overscan.Top);
|
||||
}
|
||||
}
|
||||
|
||||
void Zapper::SetTriggerState(bool pulled)
|
||||
|
|
|
@ -20,6 +20,6 @@ public:
|
|||
uint8_t GetPortOutput();
|
||||
|
||||
uint32_t GetZapperState();
|
||||
void SetPosition(int32_t x, int32_t y);
|
||||
void SetPosition(double x, double y);
|
||||
void SetTriggerState(bool pulled);
|
||||
};
|
|
@ -42,9 +42,10 @@ namespace Mesen.GUI.Controls
|
|||
InteropEmu.ZapperSetPosition(0, -1, -1);
|
||||
InteropEmu.ZapperSetPosition(1, -1, -1);
|
||||
} else {
|
||||
//TODO
|
||||
InteropEmu.ZapperSetPosition(0, e.X/4, e.Y/4);
|
||||
InteropEmu.ZapperSetPosition(1, e.X/4, e.Y/4);
|
||||
double xPos = (double)e.X / this.Width;
|
||||
double yPos = (double)e.Y / this.Height;
|
||||
InteropEmu.ZapperSetPosition(0, xPos, yPos);
|
||||
InteropEmu.ZapperSetPosition(1, xPos, yPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Mesen.GUI
|
|||
[DllImport(DLLPath)] public static extern void AddKnowGameFolder([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(UTF8Marshaler))]string folder);
|
||||
|
||||
[DllImport(DLLPath)] public static extern void ZapperSetTriggerState(Int32 port, [MarshalAs(UnmanagedType.I1)]bool pulled);
|
||||
[DllImport(DLLPath)] public static extern void ZapperSetPosition(Int32 port, Int32 x, Int32 y);
|
||||
[DllImport(DLLPath)] public static extern void ZapperSetPosition(Int32 port, double x, double y);
|
||||
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool HasZapper();
|
||||
|
||||
[DllImport(DLLPath)] public static extern void SetControllerType(int port, ControllerType type);
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace InteropEmu {
|
|||
|
||||
DllExport bool __stdcall HasZapper() { return ControlManager::HasZapper(); }
|
||||
DllExport void __stdcall ZapperSetTriggerState(int32_t port, bool pulled) { ControlManager::ZapperSetTriggerState(port, pulled); }
|
||||
DllExport void __stdcall ZapperSetPosition(int32_t port, int32_t x, int32_t y) { ControlManager::ZapperSetPosition(port, x, y); }
|
||||
DllExport void __stdcall ZapperSetPosition(int32_t port, double x, double y) { ControlManager::ZapperSetPosition(port, x, y); }
|
||||
|
||||
DllExport uint32_t __stdcall GetPressedKey() { return ControlManager::GetPressedKey(); }
|
||||
DllExport const char* __stdcall GetKeyName(uint32_t keyCode)
|
||||
|
|
Loading…
Add table
Reference in a new issue