mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Merge pull request #93 from tinkeros/cf-mouse-fix
Add support for user apps to capture raw mouse data and mouse support to Castle Frankenstein
This commit is contained in:
commit
e65f27c46d
4 changed files with 4656 additions and 4568 deletions
|
@ -578,6 +578,29 @@ U0 RotateMan(F64 d)
|
|||
}
|
||||
}
|
||||
|
||||
CTask *mouse_task = NULL;
|
||||
CTask *game_task = Fs;
|
||||
F64 mouse_scale = 32.0;
|
||||
|
||||
U0 MouseHandler()
|
||||
{
|
||||
Bool button;
|
||||
I64 x;
|
||||
while (TRUE)
|
||||
{
|
||||
button = mouse_hard.raw_bttns[0];
|
||||
x = mouse_hard.raw_data.x;
|
||||
if (button || x!=0)
|
||||
MouseRawReset; // Mark mouse data as consumed
|
||||
if (button)
|
||||
MessagePostWait(game_task,MESSAGE_KEY_DOWN_UP,CH_SPACE,0);
|
||||
if (x != 0) {
|
||||
man_é += (x/mouse_scale)/MICRO_STEPS;
|
||||
}
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
U0 CastleFrankenstein()
|
||||
{
|
||||
I64 sc;
|
||||
|
@ -618,6 +641,26 @@ U0 CastleFrankenstein()
|
|||
Fire;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (!mouse_task) {
|
||||
MouseRaw(TRUE);
|
||||
mouse_task=Spawn(&MouseHandler,NULL);
|
||||
}
|
||||
else {
|
||||
Kill(mouse_task);
|
||||
mouse_task=NULL;
|
||||
MouseRaw(FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
case '+':
|
||||
mouse_scale *= 0.9;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
mouse_scale *= 1.1;
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
Init;
|
||||
break;
|
||||
|
@ -663,7 +706,11 @@ fs_done:
|
|||
RegWrite("ZealOS/CastleFrankenstein", "F64 best_score=%5.4f;\n", best_score);
|
||||
}
|
||||
|
||||
MouseRaw(TRUE);
|
||||
mouse_task=Spawn(&MouseHandler,NULL);
|
||||
CastleFrankenstein;
|
||||
if (mouse_task) Kill(mouse_task);
|
||||
MouseRaw(FALSE);
|
||||
|