310 lines
3.8 KiB
C
310 lines
3.8 KiB
C
/*
|
|
* This file is automaticaly generated, Please dont edit this file!
|
|
*/
|
|
#include <engine/eventManager.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void eventManger_constructor( eventManger * this ) {
|
|
|
|
this->lastEvent = event_newPointer();
|
|
|
|
this->lastEvent->mouse->button = -1;
|
|
|
|
|
|
}
|
|
|
|
event * eventManger_fetchEvent( eventManger * this ) {
|
|
|
|
event * currentEvent = event_newPointer();
|
|
|
|
|
|
currentEvent->mouse->button = -1;
|
|
|
|
Window qRoot;
|
|
|
|
Window qChild;
|
|
|
|
unsigned int qMask;
|
|
|
|
int childX;
|
|
|
|
int childY;
|
|
|
|
int mouseX;
|
|
|
|
int mouseY;
|
|
|
|
int child;
|
|
|
|
|
|
XWindowAttributes window;
|
|
|
|
if( XGetWindowAttributes( this->mainDisplay, this->mainWindow, &window ) ) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if( XQueryPointer( this->mainDisplay, this->RootWindow, &qRoot, &qChild, &mouseX, &mouseY, &childX, &childY, &qMask ) )
|
|
{
|
|
|
|
mouseX -= window.x;
|
|
|
|
mouseY -= window.y;
|
|
|
|
for(int i = 0; i < sizeof(int) * 8; i++)
|
|
{
|
|
int mask = 1 << sizeof(int) * 8 - i - 1;
|
|
|
|
if(mask & qMask)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( qMask == Button1MotionMask ) {
|
|
|
|
|
|
|
|
currentEvent->mouse->button = 0;
|
|
|
|
}
|
|
|
|
|
|
if( qMask == Button2MotionMask ) {
|
|
|
|
printf("Button2MotionMask\n");
|
|
|
|
}
|
|
|
|
|
|
if( qMask == Button3MotionMask ) {
|
|
|
|
printf("RightMouse\n");
|
|
|
|
}
|
|
|
|
if( qMask == Button4MotionMask ) {
|
|
|
|
printf("Button2MotionMask\n");
|
|
|
|
}
|
|
|
|
|
|
if( qMask == Button5MotionMask ) {
|
|
|
|
printf("Button2MotionMask\n");
|
|
|
|
}
|
|
|
|
if( qMask == ShiftMask ) {
|
|
|
|
printf("Pressed shift\n");
|
|
|
|
}
|
|
|
|
if( qMask == ControlMask ) {
|
|
|
|
printf("Pressed control\n");
|
|
|
|
}
|
|
|
|
|
|
if( qMask == EnterWindowMask ) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
XEvent event;
|
|
|
|
int keyboardEventCount = XPending( this->mainDisplay );
|
|
|
|
|
|
|
|
while( XPending( this->mainDisplay ) ) {
|
|
|
|
|
|
XNextEvent( this->mainDisplay, &event );
|
|
|
|
switch ( event.type ) {
|
|
|
|
case KeyPress:
|
|
|
|
printf("key has been pressed. %i\n\n", event.xkey.keycode);
|
|
|
|
break;
|
|
|
|
|
|
case KeyRelease:
|
|
|
|
printf("key has been released. %i\n\n", event.xkey.keycode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Expose:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
bool hasBorder = true;
|
|
|
|
int borderCorrection = 0;
|
|
|
|
|
|
|
|
if( hasBorder ) {
|
|
|
|
borderCorrection = 12;
|
|
|
|
}
|
|
|
|
|
|
currentEvent->mouse->position = vector2_new( mouseX, mouseY + borderCorrection );
|
|
|
|
currentEvent->screen->size = vector2_new( window.width, window.height + borderCorrection );
|
|
|
|
|
|
|
|
vector_char_pointer * mouseEvents = currentEvent->mouse->eventTypes;
|
|
|
|
mouseEvents = vector_char_pointer_newPointer();
|
|
|
|
if( this->lastEvent->mouse->position.x != currentEvent->mouse->position.x ||
|
|
this->lastEvent->mouse->position.y != currentEvent->mouse->position.y ) {
|
|
|
|
vector_char_pointer_add( mouseEvents, "mousemove" );
|
|
|
|
}
|
|
|
|
if( this->lastEvent->mouse->button != 0 && currentEvent->mouse->button == 0 ) {
|
|
|
|
this->lastMouseDownTime = clock();
|
|
|
|
printf("Mouse down\n\n");
|
|
|
|
vector_char_pointer_add( mouseEvents, "mousedown" );
|
|
|
|
}
|
|
|
|
if( this->lastEvent->mouse->button == 0 && currentEvent->mouse->button != 0 ) {
|
|
|
|
clock_t difference = clock() - this->lastMouseDownTime;
|
|
|
|
int milliseconds = difference * 1000 / CLOCKS_PER_SEC;
|
|
|
|
if( milliseconds < 150 ) {
|
|
|
|
printf("click event\n\n");
|
|
|
|
|
|
vector_char_pointer_add( mouseEvents, "click" );
|
|
|
|
}
|
|
|
|
printf("mouseup event\n\n");
|
|
|
|
vector_char_pointer_add( mouseEvents, "mouseup" );
|
|
|
|
|
|
|
|
}
|
|
|
|
currentEvent->mouse->eventTypes = mouseEvents;
|
|
|
|
|
|
this->lastEvent = currentEvent;
|
|
|
|
return currentEvent;
|
|
|
|
}
|
|
|
|
eventManger eventManger_new() {
|
|
|
|
eventManger instance;
|
|
|
|
eventManger_constructor( &instance);
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
eventManger * eventManger_newPointer() {
|
|
|
|
struct eventManger * pointer = malloc( sizeof ( struct eventManger ) );
|
|
|
|
eventManger_constructor( pointer );
|
|
|
|
return pointer;
|
|
|
|
}
|
|
|