2018-11-16 00:31:39 +01:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
SNES9X for Mac OS (c) Copyright John Stiles
|
|
|
|
|
|
|
|
Snes9x for Mac OS X
|
|
|
|
|
2011-04-10 15:44:28 +02:00
|
|
|
(c) Copyright 2001 - 2011 zones
|
2010-09-25 17:46:12 +02:00
|
|
|
(c) Copyright 2002 - 2005 107
|
|
|
|
(c) Copyright 2002 PB1400c
|
|
|
|
(c) Copyright 2004 Alexander and Sander
|
|
|
|
(c) Copyright 2004 - 2005 Steven Seeger
|
|
|
|
(c) Copyright 2005 Ryan Vogt
|
2019-09-02 19:20:32 +02:00
|
|
|
(c) Copyright 2019 Michael Donald Buckley
|
2010-09-25 17:46:12 +02:00
|
|
|
***********************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _mac_joypad_h_
|
|
|
|
#define _mac_joypad_h_
|
|
|
|
|
2019-11-10 22:02:21 +01:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
|
|
|
|
2019-10-05 22:16:19 +02:00
|
|
|
#include "mac-controls.h"
|
2010-09-25 17:46:12 +02:00
|
|
|
|
2019-11-10 22:02:21 +01:00
|
|
|
struct JoypadDevice {
|
|
|
|
uint16 vendorID;
|
|
|
|
uint16 productID;
|
|
|
|
uint32 index;
|
|
|
|
|
|
|
|
bool operator==(const struct JoypadDevice &o) const
|
|
|
|
{
|
|
|
|
return vendorID == o.vendorID && productID == o.productID && index == o.index;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const struct JoypadDevice &o) const
|
|
|
|
{
|
|
|
|
return vendorID < o.vendorID || productID < o.productID || index < o.index;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct JoypadCookie {
|
|
|
|
struct JoypadDevice device;
|
|
|
|
uint32 cookie;
|
|
|
|
|
|
|
|
JoypadCookie() {}
|
|
|
|
|
|
|
|
struct JoypadCookie &operator=(const struct JoypadCookie &o)
|
|
|
|
{
|
|
|
|
device = o.device;
|
|
|
|
cookie = o.cookie;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const struct JoypadCookie &o) const
|
|
|
|
{
|
|
|
|
return device == o.device && cookie == o.cookie;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const struct JoypadCookie &o) const
|
|
|
|
{
|
|
|
|
return device < o.device || cookie < o.cookie;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct JoypadCookieInfo {
|
|
|
|
uint32 usage;
|
|
|
|
uint32 index;
|
|
|
|
int32 midpoint;
|
|
|
|
int32 min;
|
|
|
|
int32 max;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct JoypadInput {
|
|
|
|
struct JoypadCookie cookie;
|
|
|
|
int32 value;
|
|
|
|
|
|
|
|
bool operator==(const struct JoypadInput &o) const
|
|
|
|
{
|
|
|
|
return cookie == o.cookie && value == o.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const struct JoypadInput &o) const
|
|
|
|
{
|
|
|
|
return cookie < o.cookie || value < o.value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
template <>
|
|
|
|
struct hash<struct JoypadDevice>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const JoypadDevice& k) const
|
|
|
|
{
|
|
|
|
return k.vendorID ^ k.productID ^ k.index;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct hash<struct JoypadCookie>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const JoypadCookie& k) const
|
|
|
|
{
|
|
|
|
return std::hash<struct JoypadDevice>()(k.device) ^ k.cookie;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct hash<struct JoypadInput>
|
|
|
|
{
|
|
|
|
std::size_t operator()(const JoypadInput& k) const
|
|
|
|
{
|
|
|
|
return std::hash<struct JoypadCookie>()(k.cookie) ^ k.value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-09-25 17:46:12 +02:00
|
|
|
void SetUpHID (void);
|
|
|
|
void ReleaseHID (void);
|
2019-11-02 05:10:29 +01:00
|
|
|
|
2019-11-10 22:02:21 +01:00
|
|
|
std::unordered_set<struct JoypadDevice> ListJoypads (void);
|
|
|
|
std::string NameForDevice(struct JoypadDevice device);
|
|
|
|
|
|
|
|
void SetPlayerForJoypad(int8 playerNum, uint32 vendorID, uint32 productID, uint32 index, int8 *oldPlayerNum);
|
|
|
|
bool SetButtonCodeForJoypadControl(uint32 vendorID, uint32 productID, uint32 index, uint32 cookie, int32 value, S9xButtonCode buttonCode, bool overwrite, S9xButtonCode *oldButtonCode);
|
|
|
|
void ClearButtonCodeForJoypad(uint32 vendorID, uint32 productID, uint32 index, S9xButtonCode buttonCode);
|
|
|
|
|
|
|
|
void ClearJoypad(uint32 vendorID, uint32 productID, uint32 index);
|
|
|
|
std::unordered_map<struct JoypadInput, S9xButtonCode> GetJuypadButtons(uint32 vendorID, uint32 productID, uint32 index);
|
|
|
|
|
|
|
|
std::string LabelForInput(uint32 vendorID, uint32 productID, uint32 cookie, int32 value);
|
2010-09-25 17:46:12 +02:00
|
|
|
|
|
|
|
#endif
|