41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class EmulatorGUI : MonoBehaviour
|
|
{
|
|
private Dictionary<GBAKeyCode, KeyCode> keyboardKeyCodeMap;
|
|
private Emulator emulator;
|
|
|
|
void Start()
|
|
{
|
|
keyboardKeyCodeMap = new Dictionary<GBAKeyCode, KeyCode>()
|
|
{
|
|
{ GBAKeyCode.Start,KeyCode.Return},
|
|
{ GBAKeyCode.Select,KeyCode.Backspace},
|
|
{ GBAKeyCode.Left,KeyCode.A},
|
|
{ GBAKeyCode.Right,KeyCode.D},
|
|
{ GBAKeyCode.Up,KeyCode.W},
|
|
{ GBAKeyCode.Down,KeyCode.S},
|
|
{ GBAKeyCode.A,KeyCode.J},
|
|
{ GBAKeyCode.B,KeyCode.K},
|
|
{ GBAKeyCode.L,KeyCode.U},
|
|
{ GBAKeyCode.R,KeyCode.I},
|
|
};
|
|
emulator = GameObject.FindObjectOfType<Emulator>();
|
|
emulator.KeyPressed += GetKey;
|
|
|
|
|
|
}
|
|
public bool GetKey(GBAKeyCode keyCode)
|
|
{
|
|
#if UNITY_EDITOR || UNITY_STANDALONE
|
|
bool input = Input.GetKey( keyboardKeyCodeMap[keyCode]);
|
|
if(input) return true;else return false;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
}
|