//
//  ControlsDelegate.h
//  Meteor
//
//  Created by Cesar Parent on 31/08/2015.
//  Copyright © 2015 Cesar Parent. All rights reserved.
//

#ifndef ControlsDelegate_h
#define ControlsDelegate_h

#include "../defines.h"
#include "../Geometry.h"
#include "Key.h"

NS_BEGIN

/*!
 * @interface       ControlsDelegate
 * @ingroup         Management
 * @brief           The protocol that objects must implement to be able to receive control events.
 * @details         While any object can implement ControlsDelegate, it is most common to make the
 *                  game's scenes delegates. The scene usually sets itself as the controls
 *                  delegate in Scene::didMoveToView(), making sure that the currently displayed
 *                  scene receives controls events.
 */
class ControlsDelegate {
    
public:
    
    /**
     * @name        Receiving Controller Connect and Disconnect Events
     * @{
     */
    
    /*!
     * @brief       Tells the delegate that a controller was connected.
     * @param       controllerID    The controller's unique ID.
     */
    virtual void controllerDidConnect(int controllerID) {};
    
    /*!
     * @brief       Tells the delegate that a controller was disconnected.
     * @param       controllerID    The controller's unique ID.
     */
    virtual void controllerDidDisconnect(int controllerID) {};
    
    /**
     * @}
     * @name        Receiving Controller Button Events
     * @{
     */
    
    /*!
     * @brief       Tells the delegate that a button was pressed on a controller.
     * @param       controller      The controller's unique ID.
     * @param       button          The button that was pressed.
     */
    virtual void controllerButtonDown(int controller, Button button) {};
    
    /*!
     * @brief       Tells the delegate that a button was released on a controller.
     * @param       controller      The controller's unique ID.
     * @param       button          The button that was released.
     */
    virtual void controllerButtonUp(int controller, Button button) {};
    
    /**
     * @}
     * @name        Receiving Controller Axis Events
     * @{
     */
    
    /*!
     * @brief       Tells the delegate that an axis was moved on a controller.
     * @param       controller      The controller's unique ID.
     * @param       axis            The axis that was moved.
     * @param       value           The axis's new positon, between `-1.0` and `1.0`.
     */
    virtual void controllerAxisMoved(int controller, Axis axis, float value) {};
    
    /**
     * @}
     * @name        Receiving Keyboard Events
     * @{
     */
    
    /*!
     * @brief       Tells the delegate that a key was pressed.
     * @param       key             The axis that was pressed.
     */
    virtual void keyDown(Key key) {};
    
    /*!
     * @brief       Tells the delegate that a key was released.
     * @param       key             The axis that was released.
     */
    virtual void keyUp(Key key) {};
    
    /**
     * @}
     * @name        Receiving Mouse Events
     * @{
     */
    
    /*!
     * @brief       Tells the delegate that one of the mouse button was pressed.
     * @param       button          The mouse button that was pressed.
     * @param       position        The mouse's position relative the top left corner of the window.
     */
    virtual void mouseButtonDown(int button, const ivec2& position) {};
    
    /*!
     * @brief       Tells the delegate that one of the mouse button was released.
     * @param       button          The mouse button that was released.
     * @param       position        The mouse's position relative the top left corner of the window.
     */
    
    virtual void mouseButtonUp(int button, const ivec2& position) {};
    /*!
     * @brief       Tells the delegate that the mouse has moved within the games's window.
     * @param       position        The mouse's new position relative the top left corner of the
     *                              window.
     */
    virtual void mouseMoved(const ivec2& position) {};
    
    /**
     * @}
     */
    
};

NS_END


#endif /* ControlsDelegate_h */
