2 Copyright © 2012, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <proto/muimaster.h>
9 #include <proto/intuition.h>
10 #include <proto/icon.h>
11 #include <proto/alib.h>
12 #include <proto/commodities.h>
13 #include <proto/utility.h>
15 #include <libraries/mui.h>
19 #include "keyboardgroup_class.h"
23 #include <aros/debug.h>
28 - fix layout, maybe we need a render hook
29 - a custom class for the keys might be useful
30 - keys are rendered too small to show control state e.g. ^X
31 - original KeyShow prefixes some control keys with ~ and others with ^. WTF?
32 - original KeyShow prints $$ when pressing shift and tab. WTF?
33 - fix handling of control keys for dead keys
37 static void cleanup_exit(CONST_STRPTR str
);
38 static void HandleAll(void);
40 static Object
*app
, *win
;
41 static BOOL cx_popup
= FALSE
;
42 static struct Hook broker_hook
;
43 static struct Hook show_hook
;
45 AROS_UFH3(void, broker_func
,
46 AROS_UFHA(struct Hook
*, hook
, A0
),
47 AROS_UFHA(Object
* , obj
, A2
),
48 AROS_UFHA(CxMsg
* , msg
, A1
))
52 D(bug("KeyShow: Broker hook called\n"));
53 if (CxMsgType(msg
) == CXM_COMMAND
)
55 if (CxMsgID(msg
) == CXCMD_APPEAR
)
57 CallHookPkt(&show_hook
, NULL
, NULL
);
59 else if (CxMsgID(msg
) == CXCMD_DISAPPEAR
)
61 set(win
, MUIA_Window_Open
, FALSE
);
68 AROS_UFH3(void, show_func
,
69 AROS_UFHA(struct Hook
*, hook
, A0
),
70 AROS_UFHA(APTR
, obj
, A2
),
71 AROS_UFHA(APTR
, param
, A1
))
75 if (XGET(app
, MUIA_Application_Iconified
) == TRUE
)
76 set(app
, MUIA_Application_Iconified
, FALSE
);
78 set(win
, MUIA_Window_Open
, TRUE
);
83 int main(int argc
, char **argv
)
85 ULONG kbtype
= MUIV_KeyboardGroup_Type_Amiga
;
88 // Read icon even if we have been started from CLI
89 struct DiskObject
*dobj
= GetDiskObject("PROGDIR:KeyShow");
92 STRPTR
*toolarray
= dobj
->do_ToolTypes
;
94 result
= FindToolType(toolarray
, "TYPE");
97 if (strcasecmp(result
, "PC105") == 0)
99 kbtype
= MUIV_KeyboardGroup_Type_PC105
;
101 else if (strcasecmp(result
, "PC104") == 0)
103 kbtype
= MUIV_KeyboardGroup_Type_PC104
;
108 broker_hook
.h_Entry
= HookEntry
;
109 broker_hook
.h_SubEntry
= (HOOKFUNC
)broker_func
;
110 show_hook
.h_Entry
= (HOOKFUNC
)show_func
;
112 app
= ApplicationObject
,
113 MUIA_Application_Title
, (IPTR
)"KeyShow",
114 MUIA_Application_Version
, (IPTR
)"$VER: KeyShow 1.6 (20.03.2012)",
115 MUIA_Application_Copyright
, (IPTR
)_(MSG_AppCopyright
),
116 MUIA_Application_Author
, (IPTR
)"The AROS Development Team",
117 MUIA_Application_Description
, (IPTR
)_(MSG_AppDescription
),
118 MUIA_Application_Base
, (IPTR
)"KEYSHOW",
119 MUIA_Application_DiskObject
, (IPTR
)dobj
,
120 MUIA_Application_BrokerHook
, (IPTR
)&broker_hook
,
121 SubWindow
, (IPTR
)(win
= WindowObject
,
122 MUIA_Window_Title
, (IPTR
)_(MSG_WI_TITLE
),
123 MUIA_Window_ID
, MAKE_ID('K','S','W','N'),
124 WindowContents
, (IPTR
)KeyboardGroupObject
,
125 MUIA_KeyboardGroup_Type
, kbtype
,
132 cleanup_exit("Can't create application");
135 DoMethod(win
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
136 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
140 FreeDiskObject(dobj
);
145 static void HandleAll(void)
149 set(win
, MUIA_Window_Open
, cx_popup
);
151 while((LONG
) DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)&sigs
)
152 != MUIV_Application_ReturnID_Quit
)
156 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
| SIGBREAKF_CTRL_F
);
157 if (sigs
& SIGBREAKF_CTRL_C
)
161 if (sigs
& SIGBREAKF_CTRL_F
)
163 CallHookPkt(&show_hook
, NULL
, NULL
);
169 static void cleanup_exit(CONST_STRPTR str
)
173 struct EasyStruct es
=
175 sizeof(struct EasyStruct
), 0,
176 _(MSG_ERR
), str
, _(MSG_OK
)
178 EasyRequestArgs(NULL
, &es
, NULL
, NULL
);
180 MUI_DisposeObject(app
);