Commit 0577ef04 authored by Rinnegatamante's avatar Rinnegatamante
Browse files

Avoiding to spam Sys_Milliseconds calls.

parent abecfd7a
......@@ -38,31 +38,31 @@ void Key_Event(int key, int value, int time){
Com_QueueEvent(time, SE_KEY, key, value, 0, NULL);
}
void Sys_SetKeys(uint32_t keys){
void Sys_SetKeys(uint32_t keys, int time){
if((keys & SCE_CTRL_START) != (oldkeys & SCE_CTRL_START))
Key_Event(K_ESCAPE, (keys & SCE_CTRL_START) == SCE_CTRL_START, Sys_Milliseconds());
Key_Event(K_ESCAPE, (keys & SCE_CTRL_START) == SCE_CTRL_START, time);
if((keys & SCE_CTRL_SELECT) != (oldkeys & SCE_CTRL_SELECT))
Key_Event(K_ENTER, (keys & SCE_CTRL_SELECT) == SCE_CTRL_SELECT, Sys_Milliseconds());
Key_Event(K_ENTER, (keys & SCE_CTRL_SELECT) == SCE_CTRL_SELECT, time);
if((keys & SCE_CTRL_UP) != (oldkeys & SCE_CTRL_UP))
Key_Event(K_UPARROW, (keys & SCE_CTRL_UP) == SCE_CTRL_UP, Sys_Milliseconds());
Key_Event(K_UPARROW, (keys & SCE_CTRL_UP) == SCE_CTRL_UP, time);
if((keys & SCE_CTRL_DOWN) != (oldkeys & SCE_CTRL_DOWN))
Key_Event(K_DOWNARROW, (keys & SCE_CTRL_DOWN) == SCE_CTRL_DOWN, Sys_Milliseconds());
Key_Event(K_DOWNARROW, (keys & SCE_CTRL_DOWN) == SCE_CTRL_DOWN, time);
if((keys & SCE_CTRL_LEFT) != (oldkeys & SCE_CTRL_LEFT))
Key_Event(K_LEFTARROW, (keys & SCE_CTRL_LEFT) == SCE_CTRL_LEFT, Sys_Milliseconds());
Key_Event(K_LEFTARROW, (keys & SCE_CTRL_LEFT) == SCE_CTRL_LEFT, time);
if((keys & SCE_CTRL_RIGHT) != (oldkeys & SCE_CTRL_RIGHT))
Key_Event(K_RIGHTARROW, (keys & SCE_CTRL_RIGHT) == SCE_CTRL_RIGHT, Sys_Milliseconds());
Key_Event(K_RIGHTARROW, (keys & SCE_CTRL_RIGHT) == SCE_CTRL_RIGHT, time);
if((keys & SCE_CTRL_TRIANGLE) != (oldkeys & SCE_CTRL_TRIANGLE))
Key_Event(K_AUX4, (keys & SCE_CTRL_TRIANGLE) == SCE_CTRL_TRIANGLE, Sys_Milliseconds());
Key_Event(K_AUX4, (keys & SCE_CTRL_TRIANGLE) == SCE_CTRL_TRIANGLE, time);
if((keys & SCE_CTRL_SQUARE) != (oldkeys & SCE_CTRL_SQUARE))
Key_Event(K_AUX3, (keys & SCE_CTRL_SQUARE) == SCE_CTRL_SQUARE, Sys_Milliseconds());
Key_Event(K_AUX3, (keys & SCE_CTRL_SQUARE) == SCE_CTRL_SQUARE, time);
if((keys & SCE_CTRL_CIRCLE) != (oldkeys & SCE_CTRL_CIRCLE))
Key_Event(K_AUX2, (keys & SCE_CTRL_CIRCLE) == SCE_CTRL_CIRCLE, Sys_Milliseconds());
Key_Event(K_AUX2, (keys & SCE_CTRL_CIRCLE) == SCE_CTRL_CIRCLE, time);
if((keys & SCE_CTRL_CROSS) != (oldkeys & SCE_CTRL_CROSS))
Key_Event(K_AUX1, (keys & SCE_CTRL_CROSS) == SCE_CTRL_CROSS, Sys_Milliseconds());
Key_Event(K_AUX1, (keys & SCE_CTRL_CROSS) == SCE_CTRL_CROSS, time);
if((keys & SCE_CTRL_LTRIGGER) != (oldkeys & SCE_CTRL_LTRIGGER))
Key_Event(K_AUX5, (keys & SCE_CTRL_LTRIGGER) == SCE_CTRL_LTRIGGER, Sys_Milliseconds());
Key_Event(K_AUX5, (keys & SCE_CTRL_LTRIGGER) == SCE_CTRL_LTRIGGER, time);
if((keys & SCE_CTRL_RTRIGGER) != (oldkeys & SCE_CTRL_RTRIGGER))
Key_Event(K_AUX6, (keys & SCE_CTRL_RTRIGGER) == SCE_CTRL_RTRIGGER, Sys_Milliseconds());
Key_Event(K_AUX6, (keys & SCE_CTRL_RTRIGGER) == SCE_CTRL_RTRIGGER, time);
}
void IN_RescaleAnalog(int *x, int *y, int dead) {
......@@ -87,8 +87,9 @@ void IN_Frame( void )
{
SceCtrlData keys;
sceCtrlPeekBufferPositive(0, &keys, 1);
int time = Sys_Milliseconds();
if(keys.buttons != oldkeys)
Sys_SetKeys(keys.buttons);
Sys_SetKeys(keys.buttons, time);
oldkeys = keys.buttons;
// Emulating mouse with right analog
......@@ -96,7 +97,7 @@ void IN_Frame( void )
int right_y = keys.ry - 127;
IN_RescaleAnalog(&right_x, &right_y, 30);
if (right_x != 0 || right_y != 0)
Com_QueueEvent(0, SE_MOUSE, right_x, right_y, 0, NULL);
Com_QueueEvent(time, SE_MOUSE, right_x, right_y, 0, NULL);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment