// === PROTOTYPES ===
int Mouse_Install(char **Arguments);
-void Mouse_Cleanup(void);
+ int Mouse_Cleanup(void);
// - "User" side
-char *Mouse_Root_ReadDir(tVFS_Node *Node, int Pos);
-tVFS_Node *Mouse_Root_FindDir(tVFS_Node *Node, const char *Name);
+ int Mouse_Root_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]);
+tVFS_Node *Mouse_Root_FindDir(tVFS_Node *Node, const char *Name, Uint Flags);
int Mouse_Dev_IOCtl(tVFS_Node *Node, int ID, void *Data);
-size_t Mouse_Dev_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Data);
+size_t Mouse_Dev_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Data, Uint Flags);
// - Device Side
tMouse *Mouse_Register(const char *Name, int NumButtons, int NumAxies);
void Mouse_RemoveInstance(tMouse *Handle);
};
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;
}
/**
* \brief Pre-unload cleanup function
*/
-void Mouse_Cleanup(void)
+int Mouse_Cleanup(void)
{
+ return 0;
}
// --- VFS Interface ---
-char *Mouse_Root_ReadDir(tVFS_Node *Node, int Pos)
+int Mouse_Root_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX])
{
- if( Pos != 0 ) return NULL;
- return strdup("system");
+ if( Pos != 0 )
+ return -EINVAL;
+ strcpy(Dest, "system");
+ return 0;
}
-tVFS_Node *Mouse_Root_FindDir(tVFS_Node *Node, const char *Name)
+tVFS_Node *Mouse_Root_FindDir(tVFS_Node *Node, const char *Name, Uint Flags)
{
if( strcmp(Name, "system") != 0 ) return NULL;
return &gMouse_Pointer.Node;
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)
/**
* \brief Read from a device
*/
-size_t Mouse_Dev_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Data)
+size_t Mouse_Dev_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Data, Uint Flags)
{
tPointer *ptr = Node->ImplPtr;
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('-');
}