2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Linux hidd handling mouse events.
9 #define __OOP_NOATTRBASES__
11 #include <proto/utility.h>
12 #include <proto/oop.h>
15 #include <hidd/mouse.h>
17 #include <aros/symbolsets.h>
19 #include "linuxinput_intern.h"
21 #include LC_LIBDEFS_FILE
24 #include <aros/debug.h>
26 OOP_Object
*LinuxMouse__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
28 BOOL has_mouse_hidd
= FALSE
;
30 ObtainSemaphore(&LSD(cl
)->sema
);
31 if (LSD(cl
)->mousehidd
)
32 has_mouse_hidd
= TRUE
;
33 ReleaseSemaphore(&LSD(cl
)->sema
);
35 if (has_mouse_hidd
) /* Cannot open twice */
36 return NULL
; /* Should have some error code here */
38 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
41 struct LinuxMouse_data
*data
= OOP_INST_DATA(cl
, o
);
42 struct TagItem
*tag
, *tstate
;
44 tstate
= msg
->attrList
;
45 while ((tag
= NextTagItem(&tstate
)))
49 if (IS_HIDDMOUSE_ATTR(tag
->ti_Tag
, idx
))
53 case aoHidd_Mouse_IrqHandler
:
54 data
->mouse_callback
= (VOID (*)())tag
->ti_Data
;
57 case aoHidd_Mouse_IrqHandlerData
:
58 data
->callbackdata
= (APTR
)tag
->ti_Data
;
63 } /* while (tags to process) */
65 /* Install the mouse hidd */
66 ObtainSemaphore(&LSD(cl
)->sema
);
67 LSD(cl
)->mousehidd
= o
;
68 Update_EventHandlers(LSD(cl
));
69 ReleaseSemaphore(&LSD(cl
)->sema
);
74 VOID
LinuxMouse__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
76 ObtainSemaphore(&LSD(cl
)->sema
);
77 LSD(cl
)->mousehidd
= NULL
;
78 Update_EventHandlers(LSD(cl
));
79 ReleaseSemaphore(&LSD(cl
)->sema
);
81 OOP_DoSuperMethod(cl
, o
, msg
);
86 VOID
LinuxMouse__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
90 if (IS_HIDDMOUSE_ATTR(msg
->attrID
, idx
))
94 case aoHidd_Mouse_RelativeCoords
:
100 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
104 VOID
LinuxMouse__Hidd_LinuxMouse__HandleEvent(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_LinuxMouse_HandleEvent
*msg
)
107 struct LinuxMouse_data
*data
= OOP_INST_DATA(cl
, o
);
109 data
->mouse_callback(data
->callbackdata
, msg
->mouseEvent
);
114 VOID
HIDD_LinuxMouse_HandleEvent(OOP_Object
*o
, struct pHidd_Mouse_Event
*mouseEvent
)
116 static OOP_MethodID mid
= 0;
117 struct pHidd_LinuxMouse_HandleEvent p
;
120 mid
= OOP_GetMethodID(IID_Hidd_LinuxMouse
, moHidd_LinuxMouse_HandleEvent
);
123 p
.mouseEvent
= mouseEvent
;
125 OOP_DoMethod(o
, (OOP_Msg
)&p
);