snes9x/macosx/mac-keyboard.mm

71 lines
1.8 KiB
Plaintext
Raw Normal View History

/*****************************************************************************\
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
(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
(c) Copyright 2019 Michael Donald Buckley
2010-09-25 15:46:12 +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"
int16 keyCodes[MAC_NUM_KEYCODES];
2010-09-25 15:46:12 +00:00
void InitKeyboard (void)
{
for (int i = 0; i < MAC_NUM_KEYCODES; ++i)
{
keyCodes[i] = -1;
}
2010-09-25 15:46:12 +00:00
}
void DeinitKeyboard (void)
{
for (int i = 0; i < MAC_NUM_KEYCODES; ++i)
{
keyCodes[i] = -1;
}
2010-09-25 15:46:12 +00:00
}
void SetKeyCode(int16 keyCode, S9xKey control, int16 *oldKeyCode, S9xKey *oldControl)
2010-09-25 15:46:12 +00:00
{
for ( int i = 0; i < MAC_NUM_KEYCODES; ++i)
{
if (keyCodes[i] == control && i != keyCode)
{
keyCodes[i] = -1;
2010-09-25 15:46:12 +00:00
if (oldKeyCode !=NULL)
{
*oldKeyCode = i;
}
}
}
if (oldControl != NULL)
{
*oldControl = (S9xKey)keyCodes[keyCode];
}
2010-09-25 15:46:12 +00:00
keyCodes[keyCode] = control;
2010-09-25 15:46:12 +00:00
}