*/}}

la_controllers.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "la_5.h"
  19. #include <math.h>
  20. #ifdef __linux__
  21. #include <fcntl.h>
  22. #include <sys/ioctl.h>
  23. #include <linux/input.h>
  24. #include <linux/joystick.h>
  25. #include <errno.h>
  26. #include <X11/extensions/XInput2.h>
  27. #endif
  28. extern LA MAIN;
  29. STRUCTURE(laJoystickEvent){
  30. unsigned int time;
  31. short value;
  32. unsigned char type;
  33. unsigned char number;
  34. };
  35. #define LA_JS_EVENT_BUTTON 0x01 // button pressed/released
  36. #define LA_JS_EVENT_AXIS 0x02 // joystick moved
  37. #define LA_JS_EVENT_INIT 0x80 // initial state of device
  38. #define LA_JS_TYPE_X56_THROTTLE 1
  39. #define LA_JS_TYPE_X56_STICK 2
  40. char LA_JS_BTN_NAMES[LA_JS_MAX_BUTTONS][10];
  41. char LA_JS_AXIS_NAMES[LA_JS_MAX_AXES][10];
  42. int la_IdentifyControllerInternalType(char* name){
  43. if(strstr(name, "X-56") && strstr(name, "Throttle")){ return LA_JS_TYPE_X56_THROTTLE; }
  44. if(strstr(name, "X-56") && strstr(name, "Stick")){ return LA_JS_TYPE_X56_STICK; }
  45. return 0;
  46. }
  47. laController* la_NewController(char* name, char* path, int device, int NumAxes, int NumButtons){
  48. laController* c=memAcquire(sizeof(laController));
  49. logPrint("Found controller %s\n at %s\n with %d axes, %d buttons\n", name, path, NumAxes, NumButtons);
  50. strSafeSet(&c->Name, name); strSafeSet(&c->Path, path); c->fd=device;
  51. c->NumAxes = NumAxes; c->NumButtons=NumButtons;
  52. c->InternalType = la_IdentifyControllerInternalType(name);
  53. lstAppendItem(&MAIN.Controllers,c);
  54. c->UserAssignedID=MAIN.NextControllerID; MAIN.NextControllerID++;
  55. return c;
  56. }
  57. void la_DestroyController(laController* c){
  58. strSafeDestroy(&c->Name); strSafeDestroy(&c->Path);
  59. memFree(c); laNotifyUsers("la.controllers");
  60. }
  61. laController* la_FindControllerWithID(int id){
  62. for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){ if(c->UserAssignedID==id) return c; } return 0;
  63. }
  64. void la_InitControllers(){
  65. #ifdef __linux__
  66. char path[32]="/dev/input/js";
  67. char name[128]={0};
  68. int numpos=strlen(path);
  69. for(int i=0;i<16;i++){
  70. int fd;
  71. int version; uint8_t axes, buttons;
  72. int btnmapok = 1;
  73. sprintf(&path[numpos],"%d",i);
  74. if ((fd=open(path, O_RDONLY|O_NONBLOCK))<0) { continue; }
  75. ioctl(fd, JSIOCGVERSION, &version);
  76. ioctl(fd, JSIOCGAXES, &axes);
  77. ioctl(fd, JSIOCGBUTTONS, &buttons);
  78. ioctl(fd, JSIOCGNAME(128), name);
  79. laController* c=la_NewController(name, path, fd, axes, buttons);
  80. }
  81. #endif
  82. }
  83. void la_UpdateControllerStatus(){
  84. #ifdef __linux__
  85. laJoystickEvent event; int HasEvent=0;
  86. for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){ if(c->Error) continue;
  87. int bytes; while((bytes=read(c->fd, &event, sizeof(laJoystickEvent)))>0){
  88. if(event.type&LA_JS_EVENT_BUTTON){
  89. if(event.number>=c->NumButtons) continue;
  90. c->ButtonValues[event.number]=event.value; HasEvent=1;
  91. printf("b %d %d\n", event.number, event.value);
  92. }
  93. if(event.type&LA_JS_EVENT_AXIS){
  94. if(event.number>=c->NumAxes) continue;
  95. c->AxisValues[event.number]=event.value;
  96. printf("a %d %d\n", event.number, event.value); HasEvent=1;
  97. }
  98. }
  99. if(bytes<=0){ struct stat buffer; if(stat(c->Path->Ptr,&buffer)<0){ c->Error=1; HasEvent=1; } }
  100. }
  101. if(HasEvent){ laNotifyUsers("la.controllers"); laMappingRequestEval(); }
  102. #endif
  103. }
  104. void la_RefreshControllers(){
  105. laController* c; while(c=lstPopItem(&MAIN.Controllers)){ la_DestroyController(c); } MAIN.NextControllerID=0;
  106. la_InitControllers();
  107. }
  108. int OPINV_RefreshControllers(){
  109. la_RefreshControllers();
  110. #ifdef __linux__
  111. la_ScanWacomDevices(MAIN.dpy,XIAllDevices);
  112. #endif
  113. #ifdef _WIN32
  114. MAIN.WinTabOpened = 0;
  115. if(MAIN.CurrentWindow){ la_OpenWacomWinTab(MAIN.CurrentWindow->win); }
  116. #endif
  117. return LA_FINISHED;
  118. }
  119. void la_AddButtonProp(laPropContainer* pc, char* id, char* name, char* desc, int i, int array_len, char* array_prefix){
  120. laProp* p=laAddEnumProperty(pc, id, name, desc, LA_WIDGET_ENUM_HIGHLIGHT,
  121. array_prefix,0,0,0,offsetof(laController, ButtonValues[i]),0,0,array_len,0,0,0,0,0,0,LA_READ_ONLY);
  122. laAddEnumItemAs(p,"IDLE", "Idle", "Button is not pressed", 0, 0);
  123. laAddEnumItemAs(p,"ACTIVE", "Active", "Button is pressed", 1, 0);
  124. p->ElementBytes=1;
  125. }
  126. void la_AddAxisProp(laPropContainer* pc, char* id, char* name, char* desc, int i, int array_len, char* array_prefix){
  127. laProp* p=laAddIntProperty(pc,id,name,desc,array_len>1?LA_WIDGET_VALUE_METER_2D:LA_WIDGET_VALUE_METER,
  128. array_prefix,0,32768,-32767,1,0,0,offsetof(laController, AxisValues[i]),0,0,array_len,0,0,0,0,0,0,0,LA_READ_ONLY);
  129. }
  130. void la_AddGenericButtonProps(laPropContainer* pc){
  131. for(int i=0;i<LA_JS_MAX_BUTTONS;i++){ char* name=LA_JS_BTN_NAMES[i]; la_AddButtonProp(pc,name,name,name,i,0,0); }
  132. }
  133. void la_AddGenericAxisProps(laPropContainer* pc){
  134. for(int i=0;i<LA_JS_MAX_AXES;i++){ char* name=LA_JS_AXIS_NAMES[i]; la_AddAxisProp(pc,name,name,name,i,0,0); }
  135. }
  136. void laui_X56Throttle(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context);
  137. void laui_X56Stick(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context);
  138. laPropContainer* LA_PC_JS_GENERIC;
  139. laPropContainer* LA_PC_JS_X56_THROTTLE;
  140. laPropContainer* LA_PC_JS_X56_STICK;
  141. laPropContainer* laget_ControllerType(laController* c){
  142. switch(c->InternalType){
  143. default: case 0: return LA_PC_JS_GENERIC;
  144. case LA_JS_TYPE_X56_THROTTLE: return LA_PC_JS_X56_THROTTLE;
  145. case LA_JS_TYPE_X56_STICK: return LA_PC_JS_X56_STICK;
  146. }
  147. }
  148. void la_RegisterControllerProps(){
  149. for(int i=0;i<LA_JS_MAX_AXES;i++){ sprintf(LA_JS_AXIS_NAMES[i],"a%d",i); }
  150. for(int i=0;i<LA_JS_MAX_BUTTONS;i++){ sprintf(LA_JS_BTN_NAMES[i],"b%d",i); }
  151. laCreateOperatorType("LA_refresh_controllers", "Refresh Controllers", "Look for connected controllers",0,0,0,OPINV_RefreshControllers,0,U'🗘',0);
  152. laPropContainer* pc; laProp* p;
  153. pc=laAddPropertyContainer("la_controller", "Controller", "A joystick/gamepad controller", U'🕹', 0, sizeof(laController), 0,0,1);
  154. LA_PC_JS_GENERIC = pc;
  155. laAddStringProperty(pc,"name","Name","Name of the controller", LA_WIDGET_STRING_PLAIN,0,0,0,1,offsetof(laController,Name),0,0,0,0,LA_READ_ONLY);
  156. laAddStringProperty(pc,"path","Path","Device path to the controller", LA_WIDGET_STRING_PLAIN,0,0,0,1,offsetof(laController,Path),0,0,0,0,LA_READ_ONLY);
  157. laAddIntProperty(pc,"user_assigned_id", "ID", "User assigned ID", 0,0,0,0,0,0,0,0,offsetof(laController, UserAssignedID),0,0,0,0,0,0,0,0,0,0,LA_AS_IDENTIFIER);
  158. laAddIntProperty(pc,"error", "Error", "Device error", 0,0,0,0,0,0,0,0,offsetof(laController, Error),0,0,0,0,0,0,0,0,0,0,0);
  159. la_AddGenericButtonProps(pc);
  160. la_AddGenericAxisProps(pc);
  161. pc=laAddPropertyContainer("la_controller_x56_throttle", "X56 Throttle", "X56 Throttle", 0,laui_X56Throttle,sizeof(laController),0,0,1);
  162. LA_PC_JS_X56_THROTTLE = pc;
  163. laAddStringProperty(pc,"name","Name","Name of the controller", LA_WIDGET_STRING_PLAIN,0,0,0,1,offsetof(laController,Name),0,0,0,0,LA_READ_ONLY|LA_AS_IDENTIFIER);
  164. laAddSubGroup(pc,"base","Base","Generic controller status", "la_controller",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  165. la_AddAxisProp(pc,"thr1","THR1","Throttle 1",0,0,0);
  166. la_AddAxisProp(pc,"thr2","THR2","Throttle 1",1,0,0);
  167. la_AddAxisProp(pc,"wf","WF","Wheel F (big wheel)",2,0,0);
  168. la_AddAxisProp(pc,"ball","Ball","Thumb ball",3,2,"Left/Right,Up/Down");
  169. la_AddAxisProp(pc,"wg","WG","Wheel G (smaller wheel)",5,0,0);
  170. la_AddAxisProp(pc,"r4","RTY4","Rotary 4",6,0,0);
  171. la_AddAxisProp(pc,"r3","RTY3","Rotary 3",7,0,0);
  172. la_AddButtonProp(pc,"be","E","Button E (thumb flat switch)", 0,0,0);
  173. la_AddButtonProp(pc,"bf","F","Button F (big push down switch)", 1,0,0);
  174. la_AddButtonProp(pc,"bg","G","Button G (smaller up-side-down switch)", 2,0,0);
  175. la_AddButtonProp(pc,"bi","I","Button I (left reverser)", 3,0,0);
  176. la_AddButtonProp(pc,"bh","H","Button H (right reverser)", 4,0,0);
  177. la_AddButtonProp(pc,"sw1","SW1","Switch 1", 5,0,0);
  178. la_AddButtonProp(pc,"sw2","SW2","Switch 2", 6,0,0);
  179. la_AddButtonProp(pc,"sw3","SW3","Switch 3", 7,0,0);
  180. la_AddButtonProp(pc,"sw4","SW4","Switch 4", 8,0,0);
  181. la_AddButtonProp(pc,"sw5","SW5","Switch 5", 9,0,0);
  182. la_AddButtonProp(pc,"sw6","SW6","Switch 6", 10,0,0);
  183. la_AddButtonProp(pc,"t1_up","T1+","Toggle 1+", 11,0,0);
  184. la_AddButtonProp(pc,"t1_dn","T1-","Toggle 1-", 12,0,0);
  185. la_AddButtonProp(pc,"t2_up","T2+","Toggle 2+", 13,0,0);
  186. la_AddButtonProp(pc,"t2_dn","T2-","Toggle 2-", 14,0,0);
  187. la_AddButtonProp(pc,"t3_up","T3+","Toggle 3+", 15,0,0);
  188. la_AddButtonProp(pc,"t3_dn","T3-","Toggle 3-", 16,0,0);
  189. la_AddButtonProp(pc,"t4_up","T4+","Toggle 4+", 17,0,0);
  190. la_AddButtonProp(pc,"t4_dn","T4-","Toggle 4-", 18,0,0);
  191. la_AddButtonProp(pc,"h3","H3","Hat 3 (Upper round hat)", 19,4,"N,E,S,W");
  192. la_AddButtonProp(pc,"h4","H4","Hat 4 (lower jagged hat)", 23,4,"N,E,S,W");
  193. la_AddButtonProp(pc,"pinky_up","P+","Pinky up", 27,0,0);
  194. la_AddButtonProp(pc,"pinky_dn","P-","Pinky down", 28,0,0);
  195. la_AddButtonProp(pc,"dial_fwd","D+","Dial forward", 29,0,0);
  196. la_AddButtonProp(pc,"dial_back","D-","Dial backward", 30,0,0);
  197. la_AddButtonProp(pc,"bball","BP","Ball push", 31,0,0);
  198. la_AddButtonProp(pc,"slider","SLD","Slider", 32,0,0);
  199. la_AddButtonProp(pc,"mode","Mode","Mode switch", 33,3,"M1,M2,S1");
  200. pc=laAddPropertyContainer("la_controller_x56_stick", "X56 Stick", "X56 Stick", 0,laui_X56Stick,sizeof(laController),0,0,1);
  201. LA_PC_JS_X56_STICK = pc;
  202. laAddStringProperty(pc,"name","Name","Name of the controller", LA_WIDGET_STRING_PLAIN,0,0,0,1,offsetof(laController,Name),0,0,0,0,LA_READ_ONLY|LA_AS_IDENTIFIER);
  203. laAddSubGroup(pc,"base","Base","Generic controller status", "la_controller",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
  204. la_AddAxisProp(pc,"stick","Stick","Main stick",0,2,"Left/Right,Up/Down");
  205. la_AddAxisProp(pc,"ball","Ball","Ball stick",2,2,"Left/Right,Up/Down");
  206. la_AddAxisProp(pc,"rudder","Rudder","Ruder twist",4,0,0);
  207. la_AddAxisProp(pc,"pov","POV","POV hat",5,2,"Left/Right,Up/Down");
  208. la_AddButtonProp(pc,"trigger","Trigger","Trigger", 0,0,0);
  209. la_AddButtonProp(pc,"ba","A","Button A", 1,0,0);
  210. la_AddButtonProp(pc,"bb","B","Button B (Side of stick)", 2,0,0);
  211. la_AddButtonProp(pc,"bball","BP","Ball push", 3,0,0); la_AddButtonProp(pc,"bc","BC","Button C (ball push)", 3,0,0);
  212. la_AddButtonProp(pc,"pinky","PK","Pinky small button", 4,0,0); la_AddButtonProp(pc,"bd","BD","Button D pinky small button", 4,0,0);
  213. la_AddButtonProp(pc,"pinkyl","PKL","Pinky lever", 5,0,0);
  214. la_AddButtonProp(pc,"h1","H1","Hat 1 (Upper round hat)", 6,4,"N,E,S,W");
  215. la_AddButtonProp(pc,"h2","H2","Hat 2 (lower jagged hat)", 10,4,"N,E,S,W");
  216. //button 14-16 not sure where it is....
  217. }
  218. void laui_X56Throttle(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  219. laColumn* c=laFirstColumn(uil),*cl, *cr, *crl,*crr, *rc, *vc, *rcl,*rcr;
  220. laSplitColumn(uil,c,0.17); cl=laLeftColumn(c,0); cr=laRightColumn(c,0);
  221. laSplitColumn(uil,cr,0.4); crl=laLeftColumn(cr,0); crr=laRightColumn(cr,0);
  222. laSplitColumn(uil,crr,0.6); rc=laLeftColumn(crr,10); vc=laRightColumn(crr,0);
  223. laSplitColumn(uil,rc,0.4); rcl=laLeftColumn(rc,2); rcr=laRightColumn(rc,0);
  224. laUiItem* b,*ui,*g; laUiList*gu;
  225. laShowItem(uil,c,This,"base.name")->Flags|=LA_TEXT_ALIGN_CENTER;
  226. b=laBeginRow(uil,c,0,0);
  227. laShowItem(uil,c,This,"base.user_assigned_id");
  228. laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(This,"base.error"));{
  229. laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
  230. }laElse(uil,b1);{
  231. laShowItem(uil,c,This,"base.path")->Expand=1;
  232. }laEndCondition(uil,b1);
  233. laEndRow(uil,b);
  234. laShowSeparator(uil,c);
  235. laShowItem(uil,cl,This,"pinky_up");
  236. laShowItem(uil,cl,This,"pinky_dn");
  237. laShowSeparator(uil,cl);
  238. laShowItem(uil,cl,This,"dial_fwd");
  239. laShowItem(uil,cl,This,"dial_back");
  240. b=laBeginRow(uil,crl,0,0);
  241. ui=laShowItem(uil,crl,This,"bi");ui->Expand=1;
  242. ui=laShowItem(uil,crl,This,"bh");ui->Expand=1;
  243. laEndRow(uil,b);
  244. b=laBeginRow(uil,crl,0,0);
  245. ui=laShowItem(uil,crl,This,"thr1");ui->Expand=1;ui->Extra->HeightCoeff=10;ui->Flags|=LA_UI_FLAGS_TRANSPOSE;
  246. ui=laShowItem(uil,crl,This,"thr2");ui->Expand=1;ui->Extra->HeightCoeff=10;ui->Flags|=LA_UI_FLAGS_TRANSPOSE;
  247. laEndRow(uil,b);
  248. laShowItem(uil,rcl,This,"bf");
  249. laShowItem(uil,rcr,This,"wf");
  250. laShowItem(uil,rcl,This,"bg");
  251. laShowItem(uil,rcr,This,"wg");
  252. laShowSeparator(uil,cl);
  253. laShowItem(uil,rcl,This,"slider");
  254. laShowSeparator(uil,rcl);
  255. laShowItem(uil,rcl,This,"be");
  256. laShowItem(uil,rcl,This,"bball");
  257. laShowItem(uil,rcr,This,"ball");
  258. laShowItem(uil,rc,This,"h3")->Flags|=LA_UI_FLAGS_TRANSPOSE;
  259. laShowItem(uil,rc,This,"h4")->Flags|=LA_UI_FLAGS_TRANSPOSE;
  260. laShowItem(uil,vc,This,"t4_up");
  261. laShowItem(uil,vc,This,"t4_dn"); laShowSeparator(uil,vc);
  262. laShowItem(uil,vc,This,"t3_up");
  263. laShowItem(uil,vc,This,"t3_dn"); laShowSeparator(uil,vc);
  264. laShowItem(uil,vc,This,"t2_up");
  265. laShowItem(uil,vc,This,"t2_dn"); laShowSeparator(uil,vc);
  266. laShowItem(uil,vc,This,"t1_up");
  267. laShowItem(uil,vc,This,"t1_dn"); laShowSeparator(uil,vc);
  268. laShowItem(uil,vc,This,"r3");
  269. laShowItem(uil,vc,This,"r4");
  270. laShowSeparator(uil,c);
  271. laShowLabel(uil,cl,"Mode",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  272. laShowItem(uil,cl,This,"mode");
  273. laShowLabel(uil,cr,"Switches",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  274. b=laBeginRow(uil,cr,0,0);
  275. laShowItem(uil,cr,This,"sw1")->Expand=1;
  276. laShowItem(uil,cr,This,"sw3")->Expand=1;
  277. laShowItem(uil,cr,This,"sw5")->Expand=1;
  278. laEndRow(uil,b);
  279. b=laBeginRow(uil,cr,0,0);
  280. laShowItem(uil,cr,This,"sw2")->Expand=1;
  281. laShowItem(uil,cr,This,"sw4")->Expand=1;
  282. laShowItem(uil,cr,This,"sw6")->Expand=1;
  283. laEndRow(uil,b);
  284. }
  285. void laui_X56Stick(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
  286. laColumn* c=laFirstColumn(uil),*cl, *cc, *cr;
  287. laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,10); cr=laRightColumn(c,0);
  288. laSplitColumn(uil,cr,0.8); cc=laLeftColumn(cr,0); cr=laRightColumn(cr,10);
  289. laUiItem* b;
  290. laShowItem(uil,c,This,"base.name")->Flags|=LA_TEXT_ALIGN_CENTER;
  291. b=laBeginRow(uil,c,0,0);
  292. laShowItem(uil,c,This,"base.user_assigned_id");
  293. laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(This,"base.error"));{
  294. laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
  295. }laElse(uil,b1);{
  296. laShowItem(uil,c,This,"base.path")->Expand=1;
  297. }laEndCondition(uil,b1);
  298. laEndRow(uil,b);
  299. laShowSeparator(uil,c);
  300. laShowItem(uil,cl,This,"ba");
  301. laShowItem(uil,cl,This,"pov");
  302. laShowSeparator(uil,cl);
  303. laShowLabel(uil,cl,"Thumb",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  304. laShowItem(uil,cl,This,"bc");
  305. laShowItem(uil,cl,This,"ball");
  306. laShowSeparator(uil,cl);
  307. laShowLabel(uil,cl,"Pinky",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  308. laShowItem(uil,cl,This,"pinkyl");
  309. laShowItem(uil,cl,This,"pinky");
  310. laShowItem(uil,cr,This,"bb");
  311. laShowSeparator(uil,cr);
  312. laShowItem(uil,cc,This,"trigger");
  313. laShowItem(uil,cc,This,"stick");
  314. laShowItem(uil,cc,This,"rudder");
  315. laShowLabel(uil,cr,"H1",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  316. laShowItem(uil,cr,This,"h1");
  317. laShowSeparator(uil,cr);
  318. laShowLabel(uil,cr,"H2",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
  319. laShowItem(uil,cr,This,"h2");
  320. }