2018-11-15 23:31:39 +00: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 15:46:12 +00:00
|
|
|
|
|
|
|
/***********************************************************************************
|
|
|
|
SNES9X for Mac OS (c) Copyright John Stiles
|
|
|
|
|
|
|
|
Snes9x for Mac OS X
|
|
|
|
|
2011-04-10 13:44:28 +00:00
|
|
|
(c) Copyright 2001 - 2011 zones
|
2010-09-25 15:46:12 +00: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 17:20:32 +00:00
|
|
|
(c) Copyright 2019 Michael Donald Buckley
|
2010-09-25 15:46:12 +00:00
|
|
|
***********************************************************************************/
|
|
|
|
|
2019-10-05 20:16:19 +00:00
|
|
|
#include <Cocoa/Cocoa.h>
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
#include "port.h"
|
|
|
|
|
|
|
|
#include "mac-prefix.h"
|
|
|
|
#include "mac-dialog.h"
|
|
|
|
#include "mac-gworld.h"
|
|
|
|
#include "mac-os.h"
|
|
|
|
#include "mac-keyboard.h"
|
|
|
|
|
2019-10-19 14:08:27 +00:00
|
|
|
struct S9xButton keyCodes[MAC_NUM_KEYCODES];
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
void InitKeyboard (void)
|
|
|
|
{
|
2019-10-05 20:16:19 +00:00
|
|
|
for (int i = 0; i < MAC_NUM_KEYCODES; ++i)
|
|
|
|
{
|
2019-10-19 14:08:27 +00:00
|
|
|
keyCodes[i] = { -1, -1 };
|
2019-10-05 20:16:19 +00:00
|
|
|
}
|
2010-09-25 15:46:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeinitKeyboard (void)
|
|
|
|
{
|
2019-10-05 20:16:19 +00:00
|
|
|
for (int i = 0; i < MAC_NUM_KEYCODES; ++i)
|
|
|
|
{
|
2019-10-19 14:08:27 +00:00
|
|
|
keyCodes[i] = { -1, -1 };
|
2019-10-05 20:16:19 +00:00
|
|
|
}
|
2010-09-25 15:46:12 +00:00
|
|
|
}
|
|
|
|
|
2019-10-19 14:08:27 +00:00
|
|
|
bool SetKeyCode(int16 keyCode, S9xButtonCode buttonCode, int8 player, int16 *oldKeyCode, S9xButtonCode *oldButtonCode, int8 *oldPlayer)
|
2010-09-25 15:46:12 +00:00
|
|
|
{
|
2019-10-19 14:08:27 +00:00
|
|
|
if (player < 0 || player >= MAC_MAX_PLAYERS || buttonCode < 0 || buttonCode >= kNumButtons)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-05 20:16:19 +00:00
|
|
|
for ( int i = 0; i < MAC_NUM_KEYCODES; ++i)
|
|
|
|
{
|
2019-10-19 14:08:27 +00:00
|
|
|
struct S9xButton button = keyCodes[i];
|
|
|
|
if (button.player == player && button.buttonCode == buttonCode && i != keyCode)
|
2019-10-05 20:16:19 +00:00
|
|
|
{
|
2019-10-19 14:08:27 +00:00
|
|
|
keyCodes[i] = { -1, -1 };
|
2010-09-25 15:46:12 +00:00
|
|
|
|
2019-10-05 20:16:19 +00:00
|
|
|
if (oldKeyCode !=NULL)
|
|
|
|
{
|
|
|
|
*oldKeyCode = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-14 03:42:21 +00:00
|
|
|
|
2019-10-19 14:08:27 +00:00
|
|
|
if (oldButtonCode != NULL)
|
2019-10-05 20:16:19 +00:00
|
|
|
{
|
2019-10-19 14:08:27 +00:00
|
|
|
*oldButtonCode = (S9xButtonCode)keyCodes[keyCode].buttonCode;
|
2019-10-05 20:16:19 +00:00
|
|
|
}
|
2010-09-25 15:46:12 +00:00
|
|
|
|
2019-11-03 16:09:43 +00:00
|
|
|
if (oldPlayer != NULL )
|
2019-10-19 14:08:27 +00:00
|
|
|
{
|
|
|
|
*oldPlayer = (S9xButtonCode)keyCodes[keyCode].player;
|
|
|
|
}
|
|
|
|
|
|
|
|
keyCodes[keyCode] = { static_cast<int16>(buttonCode), player };
|
|
|
|
|
|
|
|
return true;
|
2010-09-25 15:46:12 +00:00
|
|
|
}
|