Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / arch / all-linux / hidd / linuxinput / mouseclass.c
blobd07412e73bfe7fe05b9a01809b0b3b0c6aaf97f8
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Linux hidd handling mouse events.
6 Lang: English.
7 */
9 #define __OOP_NOATTRBASES__
11 #include <proto/utility.h>
12 #include <proto/oop.h>
13 #include <oop/oop.h>
15 #include <hidd/mouse.h>
17 #include <aros/symbolsets.h>
19 #include "linuxinput_intern.h"
21 #include LC_LIBDEFS_FILE
23 #define DEBUG 0
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);
39 if (o)
41 struct LinuxMouse_data *data = OOP_INST_DATA(cl, o);
42 struct TagItem *tag, *tstate;
44 tstate = msg->attrList;
45 while ((tag = NextTagItem(&tstate)))
47 ULONG idx;
49 if (IS_HIDDMOUSE_ATTR(tag->ti_Tag, idx))
51 switch (idx)
53 case aoHidd_Mouse_IrqHandler:
54 data->mouse_callback = (VOID (*)())tag->ti_Data;
55 break;
57 case aoHidd_Mouse_IrqHandlerData:
58 data->callbackdata = (APTR)tag->ti_Data;
59 break;
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);
71 return o;
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)
88 ULONG idx;
90 if (IS_HIDDMOUSE_ATTR(msg->attrID, idx))
92 switch (idx)
94 case aoHidd_Mouse_RelativeCoords:
95 *msg->storage = TRUE;
96 return;
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);
111 return;
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;
119 if (!mid)
120 mid = OOP_GetMethodID(IID_Hidd_LinuxMouse, moHidd_LinuxMouse_HandleEvent);
122 p.mID = mid;
123 p.mouseEvent = mouseEvent;
125 OOP_DoMethod(o, (OOP_Msg)&p);