cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

inputmanager.h (2284B)


      1/*
      2 * Gearboy - Nintendo Game Boy Emulator
      3 * Copyright (C) 2012  Ignacio Sanchez
      4 
      5 * This program is free software: you can redistribute it and/or modify
      6 * it under the terms of the GNU General Public License as published by
      7 * the Free Software Foundation, either version 3 of the License, or
      8 * any later version.
      9 
     10 * This program is distributed in the hope that it will be useful,
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     13 * GNU General Public License for more details.
     14 
     15 * You should have received a copy of the GNU General Public License
     16 * along with this program.  If not, see http://www.gnu.org/licenses/
     17 *
     18 */
     19
     20#pragma once
     21#ifndef _INPUTMANAGER_H
     22#define	_INPUTMANAGER_H
     23
     24#import <UIKit/UIKit.h>
     25#include <queue>
     26#include <vector>
     27#include "singleton.h"
     28#include "inputcallback.h"
     29#include "regions.h"
     30#include "timer.h"
     31
     32class InputManager : public Singleton<InputManager>
     33{
     34    friend class Singleton<InputManager>;
     35
     36private:
     37
     38    enum eRegionType
     39    {
     40        REGION_RECT,
     41        REGION_CIRCLE
     42    };
     43
     44    struct stRegionEvent
     45    {
     46        int id;
     47        bool receiveMoveEvent;
     48        eRegionType regionType;
     49        bool pressed;
     50        Region* region;
     51        InputCallbackGeneric* pCallback;
     52        UITouch* pActualTouch;
     53    };
     54
     55    struct stRegionEventResponse
     56    {
     57        stInputCallbackParameter parameter;
     58        InputCallbackGeneric* pCallback;
     59        int id;
     60    };
     61
     62    typedef std::queue<stRegionEventResponse> TRegionEventResponseQueue;
     63
     64    TRegionEventResponseQueue m_RegionEventResponseQueue;
     65
     66    typedef std::vector<stRegionEvent> TRegionEventVector;
     67
     68    TRegionEventVector m_RegionEventVector;
     69
     70    Timer m_Timer;
     71
     72    float m_fInputRate;
     73    
     74private:
     75    
     76    InputManager();
     77
     78public:
     79
     80    ~InputManager();
     81
     82    void Update(void);
     83
     84    void HandleTouch(UITouch* touch, UIView* view);
     85
     86    void AddRectRegionEvent(float x, float y, float width, float height, InputCallbackGeneric* pCallback, int id = 0, bool receiveMoveEvent = false);
     87    void AddCircleRegionEvent(float x, float y, float radius, InputCallbackGeneric* pCallback, int id = 0, bool receiveMoveEvent = false);
     88
     89    void ClearRegionEvents(void);
     90};
     91
     92#endif	/* _INPUTMANAGER_H */
     93