<commit_before>#include "libpixel/graphics/camera/camera.h"
#include "libpixel/graphics/helper/screenHelpers.h"
#include "libpixel/input/touchManager.h"

namespace libpixel
{

Vec2 Touch::GetScreenPosition()
{
   	Vec2 position = _Position;
    
    // Specifically handle retina displays where the input co-ordinates aren't scaled
    float inputScale = ScreenHelpers::IsHighResolution() ? 2 : 1;
    
    position[0] = position[0] - ScreenHelpers::GetScreenResolution()[0]/(2*inputScale);
    position[1] = ScreenHelpers::GetScreenResolution()[1]/(2*inputScale) - position[1];
    
	position[0] /= (ScreenHelpers::GetDpu()/inputScale);
	position[1] /= (ScreenHelpers::GetDpu()/inputScale);
	
	return position;
}

Vec2 Touch::GetWorldPosition(Camera* camera)
{
	Vec2 position = _Position;
    
    // Specifically handle retina displays where the input co-ordinates aren't scaled
    float inputScale = ScreenHelpers::IsHighResolution() ? 2 : 1;
    
    position[0] = position[0] - ScreenHelpers::GetScreenResolution()[0]/(2*inputScale);
    position[1] = ScreenHelpers::GetScreenResolution()[1]/(2*inputScale) - position[1];

	position[0] /= (ScreenHelpers::GetDpu()/inputScale);
	position[1] /= (ScreenHelpers::GetDpu()/inputScale);
    
    position -= camera->Position;
	
	return position;
}

void TouchHandler::OnTouchBegin(Touch* touch)
{
}

void TouchHandler::OnTouchUpdate(Touch* touch)
{
}

void TouchHandler::OnTouchEnd(Touch* touch)
{
}
    
TouchManager::TouchManager()
{
    
}

void TouchManager::AddTouchHandler(TouchHandler* handler)
{
    _Handlers.insert(handler);
}
    
void TouchManager::RemoveTouchHandler(TouchHandler* handler)
{
    _Handlers.erase(handler);
}

void TouchManager::AddTouch(void* uiTouch, Vec2 position)
{
	Touch* touch = new Touch();
	touch->_Position = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? Vec2(position[0]/2.4f, position[1]/2.133f) : position;
	_Touches[uiTouch] = touch;
	OnTouchBegin(touch);
}

void TouchManager::RemoveTouch(void* touch)
{
	std::map<void*, Touch*>::iterator it = _Touches.find(touch);
	
	if (it != _Touches.end())
	{
		OnTouchEnd(it->second);
		delete it->second;
		_Touches.erase(it);
	}
}<commit_msg>Fix iPad input<commit_after>#include "libpixel/graphics/camera/camera.h"
#include "libpixel/graphics/helper/screenHelpers.h"
#include "libpixel/input/touchManager.h"

namespace libpixel
{

Vec2 Touch::GetScreenPosition()
{
   	Vec2 position = _Position;
    
    // Specifically handle retina displays where the input co-ordinates aren't scaled
    float inputScale = ScreenHelpers::IsHighResolution() ? 2 : 1;
    
    position[0] = position[0] - ScreenHelpers::GetScreenResolution()[0]/(2*inputScale);
    position[1] = ScreenHelpers::GetScreenResolution()[1]/(2*inputScale) - position[1];
    
	position[0] /= (ScreenHelpers::GetDpu()/inputScale);
	position[1] /= (ScreenHelpers::GetDpu()/inputScale);
	
	return position;
}

Vec2 Touch::GetWorldPosition(Camera* camera)
{
	Vec2 position = _Position;
    
    // Specifically handle retina displays where the input co-ordinates aren't scaled
    float inputScale = ScreenHelpers::IsHighResolution() ? 2 : 1;
    
    position[0] = position[0] - ScreenHelpers::GetScreenResolution()[0]/(2*inputScale);
    position[1] = ScreenHelpers::GetScreenResolution()[1]/(2*inputScale) - position[1];

	position[0] /= (ScreenHelpers::GetDpu()/inputScale);
	position[1] /= (ScreenHelpers::GetDpu()/inputScale);
    
    position -= camera->Position;
	
	return position;
}

void TouchHandler::OnTouchBegin(Touch* touch)
{
}

void TouchHandler::OnTouchUpdate(Touch* touch)
{
}

void TouchHandler::OnTouchEnd(Touch* touch)
{
}
    
TouchManager::TouchManager()
{
    
}

void TouchManager::AddTouchHandler(TouchHandler* handler)
{
    _Handlers.insert(handler);
}
    
void TouchManager::RemoveTouchHandler(TouchHandler* handler)
{
    _Handlers.erase(handler);
}

void TouchManager::AddTouch(void* uiTouch, Vec2 position)
{
	Touch* touch = new Touch();
	touch->_Position = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? Vec2(position[0]/2.f, position[1]/2.f) : position;
	_Touches[uiTouch] = touch;
	OnTouchBegin(touch);
}

void TouchManager::RemoveTouch(void* touch)
{
	std::map<void*, Touch*>::iterator it = _Touches.find(touch);
	
	if (it != _Touches.end())
	{
		OnTouchEnd(it->second);
		delete it->second;
		_Touches.erase(it);
	}
}
{'fraction_non_alphanumeric': 0.14733470601692977, 'fraction_numerical': 0.016472203157172273, 'mean_word_length': 5.131837307152876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '7478835', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1469, 'n_words': 252}