};
tDevFS_Driver gMouse_DevInfo = {
NULL, "Mouse",
- { .Flags = VFS_FFLAG_DIRECTORY, .Type = &gMouse_RootNodeType }
+ { .Flags = VFS_FFLAG_DIRECTORY, .Type = &gMouse_RootNodeType, .Size = 1 }
};
tPointer gMouse_Pointer;
gMouse_Pointer.Node.Type = &gMouse_DevNodeType;
gMouse_Pointer.Node.ImplPtr = &gMouse_Pointer;
+ gMouse_Pointer.FileHeader = (void*)gMouse_Pointer.FileData;
+ gMouse_Pointer.Axies = (void*)( gMouse_Pointer.FileHeader + 1 );
return 0;
}
case JOY_IOCTL_GETSETAXISLIMIT:
if( !numval || !CheckMem(numval, sizeof(*numval)) )
return -1;
+ LOG("GetSetAxisLimit %i = %i", numval->Num, numval->Value);
if(numval->Num < 0 || numval->Num >= ptr->FileHeader->NAxies)
return 0;
if(numval->Value != -1)
int n_buttons = ptr->FileHeader->NButtons;
int n_axies = ptr->FileHeader->NAxies;
+ ENTER("pNode iLength pData", Node, Length, Data);
+
// TODO: Locking (Acquire)
Length = MIN(
// TODO: Locking (Release)
+ LEAVE('i', Length);
return Length;
}
// TODO: Locking
ret->Next = target->FirstDev;
target->FirstDev = ret;
- if( ret->NumAxies <= MAX_AXIES && ret->NumAxies > target->FileHeader->NAxies ) {
+ if( ret->NumAxies > target->FileHeader->NAxies ) {
// Clear new axis data
memset(
target->Axies + target->FileHeader->NAxies,
target->FileHeader->NAxies = ret->NumAxies;
target->Buttons = (void*)( target->Axies + ret->NumAxies );
}
- if( ret->NumButtons <= MAX_BUTTONS && ret->NumButtons > target->FileHeader->NButtons ) {
+ if( ret->NumButtons > target->FileHeader->NButtons ) {
// No need to move as buttons can expand out into space
target->FileHeader->NButtons = ret->NumButtons;
}
*/
void Mouse_HandleEvent(tMouse *Handle, Uint32 ButtonState, int *AxisDeltas)
{
- tPointer *ptr = Handle->Pointer;
+ tPointer *ptr;
- Handle->ButtonState = ButtonState;
+ ENTER("pHandle xButtonState pAxisDeltas", Handle, ButtonState, AxisDeltas);
+
+ ptr = Handle->Pointer;
+ // Update device state
+ Handle->ButtonState = ButtonState;
memcpy(Handle->LastAxisVal, AxisDeltas, sizeof(*AxisDeltas)*Handle->NumAxies);
+ // Update cursor position
// TODO: Acceleration?
-
for( int i = 0; i < Handle->NumAxies; i ++ )
{
ptr->Axies[i].CursorPos = MIN(MAX(0, ptr->Axies[i].CursorPos+AxisDeltas[i]), ptr->AxisLimits[i]);
+ LOG("Axis %i: delta = %i, pos = %i", i, AxisDeltas[i], ptr->Axies[i].CursorPos);
}
+
VFS_MarkAvaliable( &ptr->Node, 1 );
+ LEAVE('-');
}