Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- private var deadZone : float = 0.25;
- private var axisValue : float;
- private var acceptInput : boolean = true;
- function Start()
- {
- if(OuyaSDK.IsOUYA())
- {
- UICamera.current.onCustomInput = OuyaNguiInput;
- }
- }
- function OuyaNguiInput()
- {
- if(SuperInputMapper.GetButtonDown(OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT, OuyaSDK.OuyaPlayer.player1)) UICamera.Notify(UICamera.selectedObject, "OnKey", KeyCode.RightArrow);
- if(SuperInputMapper.GetButtonDown(OuyaSDK.KeyEnum.BUTTON_DPAD_UP, OuyaSDK.OuyaPlayer.player1)) UICamera.Notify(UICamera.selectedObject, "OnKey", KeyCode.UpArrow);
- if(SuperInputMapper.GetButtonDown(OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT, OuyaSDK.OuyaPlayer.player1)) UICamera.Notify(UICamera.selectedObject, "OnKey", KeyCode.LeftArrow);
- if(SuperInputMapper.GetButtonDown(OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN, OuyaSDK.OuyaPlayer.player1)) UICamera.Notify(UICamera.selectedObject, "OnKey", KeyCode.DownArrow);
- axisValue = SuperInputMapper.GetAxis (OuyaSDK.KeyEnum.AXIS_LSTICK_Y, OuyaSDK.OuyaPlayer.player1);
- if(axisValue > deadZone)
- {
- if(acceptInput)
- {
- UICamera.Notify(UICamera.selectedObject, "OnKey", KeyCode.DownArrow);
- acceptInput = false; // prevents auto-fire
- }
- }
- else if(axisValue < -deadZone)
- {
- if(acceptInput)
- {
- UICamera.Notify(UICamera.selectedObject, "OnKey", KeyCode.UpArrow);
- acceptInput = false; // prevents auto-fire
- }
- }
- else
- {
- // no joystick movement or between deadZone (= little to no movement at all)
- acceptInput = true; // enable joystick input again
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement