<commit_before>// Copyright (C) 2015 <NAME>
// This file is part of the Ouzel engine.

#include <GameController/GameController.h>
#include "Engine.h"
#include "GamepadApple.h"
#include "CompileConfig.h"
#include "EventDispatcher.h"
#include "Utils.h"

namespace ouzel
{
    GamepadApple::GamepadApple(GCController* controller):
        _controller(controller)
    {
        if (_controller.extendedGamepad)
        {
            // left thumbstick
            _controller.extendedGamepad.leftThumbstick.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_UP, pressed, value);
            };
            _controller.extendedGamepad.leftThumbstick.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_DOWN, pressed, value);
            };
            _controller.extendedGamepad.leftThumbstick.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_LEFT, pressed, value);
            };
            _controller.extendedGamepad.leftThumbstick.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_RIGHT, pressed, value);
            };
            
            // right thumbstick
            _controller.extendedGamepad.rightThumbstick.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_UP, pressed, value);
            };
            _controller.extendedGamepad.rightThumbstick.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_DOWN, pressed, value);
            };
            _controller.extendedGamepad.rightThumbstick.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_LEFT, pressed, value);
            };
            _controller.extendedGamepad.rightThumbstick.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_RIGHT, pressed, value);
            };
            
            // D-pad
            _controller.extendedGamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_UP, pressed, value);
            };
            _controller.extendedGamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_DOWN, pressed, value);
            };
            _controller.extendedGamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_LEFT, pressed, value);
            };
            _controller.extendedGamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_RIGHT, pressed, value);
            };
            
            // buttons
            _controller.extendedGamepad.buttonA.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::A, pressed, value);
            };
            _controller.extendedGamepad.buttonB.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::B, pressed, value);
            };
            _controller.extendedGamepad.buttonX.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::X, pressed, value);
            };
            _controller.extendedGamepad.buttonY.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::Y, pressed, value);
            };
        }
        else if (_controller.gamepad)
        {
            // D-pad
            _controller.gamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_UP, pressed, value);
            };
            _controller.gamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_DOWN, pressed, value);
            };
            _controller.gamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_LEFT, pressed, value);
            };
            _controller.gamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_RIGHT, pressed, value);
            };
            
            // buttons
            _controller.gamepad.buttonA.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::A, pressed, value);
            };<commit_msg>Implement Apple gamepad trigger and shoulder events<commit_after>// Copyright (C) 2015 <NAME>
// This file is part of the Ouzel engine.

#include <GameController/GameController.h>
#include "Engine.h"
#include "GamepadApple.h"
#include "CompileConfig.h"
#include "EventDispatcher.h"
#include "Utils.h"

namespace ouzel
{
    GamepadApple::GamepadApple(GCController* controller):
        _controller(controller)
    {
        if (_controller.extendedGamepad)
        {
            // left thumbstick
            _controller.extendedGamepad.leftThumbstick.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_UP, pressed, value);
            };
            _controller.extendedGamepad.leftThumbstick.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_DOWN, pressed, value);
            };
            _controller.extendedGamepad.leftThumbstick.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_LEFT, pressed, value);
            };
            _controller.extendedGamepad.leftThumbstick.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_THUMB_RIGHT, pressed, value);
            };
            
            // right thumbstick
            _controller.extendedGamepad.rightThumbstick.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_UP, pressed, value);
            };
            _controller.extendedGamepad.rightThumbstick.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_DOWN, pressed, value);
            };
            _controller.extendedGamepad.rightThumbstick.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_LEFT, pressed, value);
            };
            _controller.extendedGamepad.rightThumbstick.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_THUMB_RIGHT, pressed, value);
            };
            
            // D-pad
            _controller.extendedGamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_UP, pressed, value);
            };
            _controller.extendedGamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_DOWN, pressed, value);
            };
            _controller.extendedGamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_LEFT, pressed, value);
            };
            _controller.extendedGamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_RIGHT, pressed, value);
            };
            
            // buttons
            _controller.extendedGamepad.buttonA.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::A, pressed, value);
            };
            _controller.extendedGamepad.buttonB.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::B, pressed, value);
            };
            _controller.extendedGamepad.buttonX.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::X, pressed, value);
            };
            _controller.extendedGamepad.buttonY.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::Y, pressed, value);
            };
            
            // triggers and shoulders
            _controller.extendedGamepad.leftShoulder.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_SHOULDER, pressed, value);
            };
            _controller.extendedGamepad.leftTrigger.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::LEFT_TRIGGER, pressed, value);
            };
            _controller.extendedGamepad.rightShoulder.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_SHOULDER, pressed, value);
            };
            _controller.extendedGamepad.rightTrigger.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::RIGHT_TRIGGER, pressed, value);
            };
            
        }
        else if (_controller.gamepad)
        {
            // D-pad
            _controller.gamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_UP, pressed, value);
            };
            _controller.gamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_DOWN, pressed, value);
            };
            _controller.gamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_LEFT, pressed, value);
            };
            _controller.gamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::DPAD_RIGHT, pressed, value);
            };
            
            // buttons
            _controller.gamepad.buttonA.valueChangedHandler = ^(GCControllerButtonInput* button, float value, BOOL pressed) {
                handleButtonValueChange(GamepadButton::A, pressed, value);
            };
{'fraction_non_alphanumeric': 0.08859734369938452, 'fraction_numerical': 0.0006478781988986071, 'mean_word_length': 2.874803890806401, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2855851', 'n_tokens_mistral': 3185, 'n_tokens_neox': 3084, 'n_words': 555}