/*
* LaGUI: A graphical application framework.
* Copyright (C) 2022-2023 Wu Yiming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "la_5.h"
#include
#ifdef LA_LINUX
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
extern LA MAIN;
#define LA_JS_EVENT_BUTTON 0x01 // button pressed/released
#define LA_JS_EVENT_AXIS 0x02 // joystick moved
#define LA_JS_EVENT_INIT 0x80 // initial state of device
#define LA_JS_TYPE_X56_THROTTLE 1
#define LA_JS_TYPE_X56_STICK 2
char LA_JS_BTN_NAMES[LA_JS_MAX_BUTTONS][12];
char LA_JS_BTN_MAP_NAMES[LA_JS_MAX_BUTTONS][12];
char LA_JS_AXIS_NAMES[LA_JS_MAX_AXES][12];
char LA_JS_AXIS_MAP_NAMES[LA_JS_MAX_AXES][12];
char LA_JS_AXIS_CMAX_NAMES[LA_JS_MAX_AXES][12];
char LA_JS_AXIS_CMIN_NAMES[LA_JS_MAX_AXES][12];
char LA_JS_AXIS_LMAX_NAMES[LA_JS_MAX_AXES][12];
char LA_JS_AXIS_LMIN_NAMES[LA_JS_MAX_AXES][12];
int la_IdentifyControllerInternalType(char* name){
if(strstr(name, "X-56") && strstr(name, "Throttle")){ return LA_JS_TYPE_X56_THROTTLE; }
if(strstr(name, "X-56") && strstr(name, "Stick")){ return LA_JS_TYPE_X56_STICK; }
return 0;
}
void la_EnsureControllerNames(laController* c){
laPropContainer*pc=la_EnsureSubTarget(LA_PROP_CONTROLLER,c);
if(!pc){ return; }
for(laProp* p=pc->Props.pFirst;p;p=p->Item.pNext){
if(p->PropertyType & LA_PROP_INT && p->Offset){ int off=p->Offset;
if(off >= offsetof(laController,AxisValues[0]) && off <= offsetof(laController,AxisValues[LA_JS_MAX_AXES-1])){
int index = (off - offsetof(laController,AxisValues[0]))/sizeof(u16bit);
if(p->Len<2){ strSafeSet(&c->AxisNames[index], p->Name); }
else for(int i=0;iLen;i++){ strSafePrint(&c->AxisNames[index+i],"%s.%d", p->Name,i+1); }
}
}elif(p->PropertyType & LA_PROP_ENUM && p->Offset){ int off=p->Offset;
if(off >= offsetof(laController,ButtonValues[0]) && off <= offsetof(laController,ButtonValues[LA_JS_MAX_BUTTONS-1])){
int index = (off - offsetof(laController,ButtonValues[0]));
if(p->Len<2){ strSafeSet(&c->ButtonNames[index], p->Name); }
else for(int i=0;iLen;i++){ strSafePrint(&c->ButtonNames[index+i],"%s.%d", p->Name,i+1); }
}
}
}
}
laController* la_NewController(char* name, char* path, int device, int NumAxes, int NumButtons){
laController* c=memAcquire(sizeof(laController));
logPrint("Found controller %s\n at %s\n with %d axes, %d buttons\n", name, path, NumAxes, NumButtons);
strSafeSet(&c->Name, name); strSafeSet(&c->Path, path); c->fd=device;
c->NumAxes = NumAxes; c->NumButtons=NumButtons;
c->InternalType = la_IdentifyControllerInternalType(name);
lstPushItem(&MAIN.Controllers,c);
c->UserAssignedID=MAIN.NextControllerID; MAIN.NextControllerID++;
la_EnsureControllerNames(c);
return c;
}
void la_DestroyController(laController* c){
strSafeDestroy(&c->Name); strSafeDestroy(&c->Path); if(c->fd){ close(c->fd); }
lstRemoveItem(&MAIN.Controllers,c); laNotifyInstanceUsers(c); memFree(c); laNotifyUsers("la.controllers");
}
laController* la_FindControllerWithID(int id){
for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){ if(c->UserAssignedID==id) return c; } return 0;
}
void la_ReadControllerAxisLimit(laController* c, int i, int Min, int Max){
c->AxisMins[i] = Min;
c->AxisMaxes[i] = Max;
c->AxisLimitMins[i] = -32768*0.95;
c->AxisLimitMaxes[i] = 32767*0.95;
}
int la_ControllerButtonToMap(int btn){
#ifdef LA_LINUX
if(btnButtonsMap[map];
}
int la_ControllerAxisToMap(int abs){
#ifdef LA_LINUX
if(absABS_MAX) return -1;
return abs;
#endif
#ifdef _WIN32
return abs;
#endif
}
int la_ControllerAxisToIndex(laController* c,int abs){
int map=la_ControllerAxisToMap(abs); if(map<0) return -1; return c->AxisMap[map];
}
char* laControllerIDGetAxisName(int id, int axis){
laController* c=la_FindControllerWithID(id); if(!c){ return "?"; }
return SSTR(c->AxisNames[axis]);
}
char* laControllerIDGetButtonName(int id, int button){
laController* c=la_FindControllerWithID(id); if(!c){ return "?"; }
return SSTR(c->ButtonNames[button]);
}
int laControllerIDGetAxis(int id, char* name){
laController* c=la_FindControllerWithID(id); if(!c){ return -1; }
for(int i=0;iAxisNames[i]),name)) return i; } return -1;
}
int laControllerIDGetButton(int id, char* name){
laController* c=la_FindControllerWithID(id); if(!c){ return -1; }
for(int i=0;iButtonNames[i]),name)) return i; } return -1;
}
void la_InitControllers(){
#ifdef LA_LINUX
char path[32]="/dev/input/js";
char name[128]={0};
int numpos=strlen(path);
char fileName[32];
for (int i=0; i<32; ++i) {
sprintf(fileName, "/dev/input/event%d", i);
int file = open(fileName, O_RDWR | O_NONBLOCK);
if (file != -1){
ioctl(file, EVIOCGNAME(128), name);
barray_t *abs_barray = barray_init(ABS_CNT);
ioctl(file, EVIOCGBIT(EV_ABS, ABS_CNT), barray_data(abs_barray));
size_t abs_count = barray_count_set(abs_barray);
barray_t *key_barray = barray_init(KEY_CNT);
ioctl(file, EVIOCGBIT(EV_KEY, KEY_CNT), barray_data(key_barray));
size_t key_count = barray_count_set(key_barray);
if(!abs_count && !key_count){ close(file); continue; }
laController* c=la_NewController(name, fileName, file, abs_count, key_count);
int nextid=0;
for (unsigned int j=0; jButtonsMap[mapid]=nextid; nextid++;
}
}
nextid=0;
for (unsigned int j=0; jAxisMap[mapid]=nextid; nextid++;
}
}
barray_free(abs_barray);
barray_free(key_barray);
}
}
#endif
}
void la_UpdateControllerStatus(){
#ifdef LA_LINUX
struct input_event event; int HasEvent=0;
for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){ if(c->Error) continue;
if(!c->Error && !c->fd){ c->fd=open(SSTR(c->Path), O_RDWR | O_NONBLOCK); if(c->fd<0){ c->Error=1; } continue; }
int bytes; while((bytes=read(c->fd, &event, sizeof(struct input_event)))>0){
if(event.type == EV_KEY){
int idx = la_ControllerButtonToIndex(c,event.code); if(idx<0) continue;
c->ButtonValues[idx]=event.value; HasEvent=1;
MAIN.LastControllerKey=idx; MAIN.LastControllerKeyDevice=c->UserAssignedID; MAIN.ControllerHasNewKey = 1; laRetriggerOperators();
}
else if(event.type == EV_ABS){
int idx = la_ControllerAxisToIndex(c,event.code); if(idx<0) continue; HasEvent=1;
c->AxisValues[idx]=rint(tnsLinearItp(-32768.0f,32767.0f,(((real)event.value-c->AxisMins[idx])/(c->AxisMaxes[idx]-c->AxisMins[idx]))));
if(abs(c->AxisValues[idx]-c->SaveAxisValues[idx])>10000){ c->SaveAxisValues[idx]=c->AxisValues[idx];
MAIN.LastControllerAxis=idx; MAIN.LastControllerAxisDevice=c->UserAssignedID; MAIN.ControllerHasNewAxis = 1; laRetriggerOperators();
}
}
}
if(bytes<=0){ struct stat buffer; if(stat(c->Path->Ptr,&buffer)<0){ c->Error=1; HasEvent=1; } }
}
if(HasEvent){ laNotifyUsers("la.controllers"); laMappingRequestEval(); }
#endif
}
void la_CopyControllerConfig(laController* to, laController* from){
strSafeSet(&to->Path,SSTR(from->Path));
to->UserAssignedID = from->UserAssignedID;
memcpy(to->AxisCenterMaxes,from->AxisCenterMaxes,sizeof(int16_t)*LA_JS_MAX_AXES);
memcpy(to->AxisCenterMins,from->AxisCenterMins,sizeof(int16_t)*LA_JS_MAX_AXES);
memcpy(to->AxisLimitMaxes,from->AxisLimitMaxes,sizeof(int16_t)*LA_JS_MAX_AXES);
memcpy(to->AxisLimitMins,from->AxisLimitMins,sizeof(int16_t)*LA_JS_MAX_AXES);
memcpy(to->ButtonsMap,from->ButtonsMap,sizeof(u8bit)*LA_JS_MAX_BUTTONS);
memcpy(to->AxisMap,from->AxisMap,sizeof(u8bit)*LA_JS_MAX_AXES);
}
void la_RemoveDuplicatedControllers(){
laController* NextC;
for(laController* fc=MAIN.Controllers.pFirst;fc;fc=fc->Item.pNext){
if(fc->fd>=0){ close(fc->fd); fc->fd=0; }
}
for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){
for(laController* fc=c->Item.pNext;fc;fc=NextC){
NextC=fc->Item.pNext;
if(strSame(SSTR(fc->Name),SSTR(c->Name))){
la_CopyControllerConfig(c,fc); la_EnsureControllerNames(c);
la_DestroyController(fc);
}
}
}
}
void la_RefreshControllers(){
la_InitControllers();
la_RemoveDuplicatedControllers();
}
int OPINV_RefreshControllers(laOperator* a, laEvent* e){
la_RefreshControllers();
#ifdef LA_LINUX
la_ScanWacomDevices(MAIN.dpy,XIAllDevices);
#endif
#ifdef _WIN32
MAIN.WinTabOpened = 0;
if(MAIN.CurrentWindow){ la_OpenWacomWinTab(MAIN.CurrentWindow->win); }
#endif
laNotifyUsers("la.controllers");
return LA_FINISHED;
}
int OPINV_RemoveController(laOperator* a, laEvent* e){
if(!a->This || !a->This->EndInstance) return LA_FINISHED;
laEnableYesNoPanel(0, 0, "Confirm?", "Will remove this controller config.", e->x-200, e->y, 200, e);
return LA_RUNNING;
}
int OPMOD_RemoveController(laOperator* a, laEvent* e){
if(!a->This || !a->This->EndInstance) return LA_FINISHED; laController* c=a->This->EndInstance;
if(a->ConfirmData){
if(a->ConfirmData->Mode == LA_CONFIRM_OK){
la_DestroyController(c); laNotifyUsers("la.controllers");
}
return LA_FINISHED;
}
return LA_FINISHED;
}
void lapost_Controller(laController* c){
c->InternalType = la_IdentifyControllerInternalType(SSTR(c->Name));
#ifdef LA_LINUX
c->fd=open(SSTR(c->Path),O_RDWR | O_NONBLOCK); if(c->fd<0){ c->Error=1; }
#endif
}
void* lagetraw_ControllerButtonMap(laController* c, int* r_size, int* ret_is_copy){
int use_size=/*sizeof(int16_t)*LA_JS_MAX_AXES*4 +*/ sizeof(u8bit)*LA_JS_MAX_BUTTONS + sizeof(u8bit)*LA_JS_MAX_AXES;
char* data = malloc(use_size); char* p = data; if (!data) return 0;
//memcpy(p,c->AxisCenterMaxes,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
//memcpy(p,c->AxisCenterMins,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
//memcpy(p,c->AxisLimitMaxes,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
//memcpy(p,c->AxisLimitMins,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
memcpy(p,c->ButtonsMap,sizeof(u8bit)*LA_JS_MAX_BUTTONS); p+= sizeof(u8bit)*LA_JS_MAX_BUTTONS;
memcpy(p,c->AxisMap,sizeof(u8bit)*LA_JS_MAX_AXES); p+= sizeof(u8bit)*LA_JS_MAX_AXES;
return data;
}
void lasetraw_ControllerButtonMap(laController* c, void* data, int DataSize){
int use_size=/*sizeof(int16_t)*LA_JS_MAX_AXES*4 +*/ sizeof(u8bit)*LA_JS_MAX_BUTTONS + sizeof(u8bit)*LA_JS_MAX_AXES;
if(DataSize!=use_size){ c->Error=1; return; /* need reinit */ }
char* p=data;
//memcpy(c->AxisCenterMaxes,p,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
//memcpy(c->AxisCenterMins,p,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
//memcpy(c->AxisLimitMaxes,p,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
//memcpy(c->AxisLimitMins,p,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
memcpy(c->ButtonsMap,p,sizeof(u8bit)*LA_JS_MAX_BUTTONS); p+= sizeof(u8bit)*LA_JS_MAX_BUTTONS;
memcpy(c->AxisMap,p,sizeof(u8bit)*LA_JS_MAX_AXES); p+= sizeof(u8bit)*LA_JS_MAX_AXES;
}
void la_AddButtonProp(laPropContainer* pc, char* id, char* id_map, char* name, char* desc, int i, int array_len, char* array_prefix){
laProp* p=laAddEnumProperty(pc, id, name, desc, LA_WIDGET_ENUM_HIGHLIGHT,
array_prefix,0,0,0,offsetof(laController, ButtonValues[i]),0,0,array_len,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE);
laAddEnumItemAs(p,"IDLE", "Idle", "Button is not pressed", 0, 0);
laAddEnumItemAs(p,"ACTIVE", "Active", "Button is pressed", 1, 0);
p->ElementBytes=1;
laAddIntProperty(pc,id_map,name,desc,0,
array_prefix,0,0,0,1,0,0,offsetof(laController, ButtonsMap[i]),0,0,array_len,0,0,0,0,0,0,0,0)->ElementBytes = 1;
}
void la_AddAxisProp(laPropContainer* pc, char* id, char* name, char* id_min, char* id_max, char* id_cmin, char* id_cmax, char* id_map, char* desc, int i, int array_len, char* array_prefix){
laAddIntProperty(pc,id,name,desc,array_len>1?LA_WIDGET_VALUE_METER_2D:LA_WIDGET_METER_TYPE2,
array_prefix,0,32767,-32768,1,0,0,offsetof(laController, AxisValues[i]),0,0,array_len,0,0,0,0,0,0,0,LA_READ_ONLY|LA_UDF_IGNORE)->ElementBytes = 2;
laAddIntProperty(pc,id_map,name,desc,0,
array_prefix,0,0,0,1,0,0,offsetof(laController, AxisMap[i]),0,0,array_len,0,0,0,0,0,0,0,0)->ElementBytes = 1;
if(id_min) laAddIntProperty(pc,id_min,id_min,desc,0,
array_prefix,0,-25000,-32768,1,0,0,offsetof(laController, AxisLimitMins[i]),0,0,array_len,0,0,0,0,0,0,0,0)->ElementBytes = 2;
if(id_max) laAddIntProperty(pc,id_max,id_max,desc,0,
array_prefix,0,32767,25000,1,0,0,offsetof(laController, AxisLimitMaxes[i]),0,0,array_len,0,0,0,0,0,0,0,0)->ElementBytes = 2;
if(id_cmin) laAddIntProperty(pc,id_cmax,id_cmax,desc,0,
array_prefix,0,-25000,-32768,1,0,0,offsetof(laController, AxisCenterMins[i]),0,0,array_len,0,0,0,0,0,0,0,0)->ElementBytes = 2;
if(id_cmax) laAddIntProperty(pc,id_cmin,id_cmin,desc,0,
array_prefix,0,32767,25000,1,0,0,offsetof(laController, AxisCenterMaxes[i]),0,0,array_len,0,0,0,0,0,0,0,0)->ElementBytes = 2;
}
#define ADD_BUTTON_PROP(pc,id,name,desc,i,array_len,array_prefix) \
la_AddButtonProp(pc,id,id "_map",name,desc,i,array_len,array_prefix)
#define ADD_AXIS_PROP(pc,id,name,desc,i,array_len,array_prefix) \
la_AddAxisProp(pc,id,name,id "_min",id "_max",id "_cmin",id "_cmax", id "_map",desc,i,array_len,array_prefix)
void la_AddGenericButtonProps(laPropContainer* pc){
for(int i=0;iInternalType){
default: case 0: return LA_PC_JS_GENERIC;
case LA_JS_TYPE_X56_THROTTLE: return LA_PC_JS_X56_THROTTLE;
case LA_JS_TYPE_X56_STICK: return LA_PC_JS_X56_STICK;
}
}
void la_RegisterControllerProps(){
for(int i=0;iFlags|=LA_TEXT_ALIGN_CENTER;
b=laBeginRow(uil,c,0,0);
laShowItem(uil,c,This,"user_assigned_id");
b1=laOnConditionThat(uil,c,laPropExpression(This,"error"));{
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
}laElse(uil,b1);{
laShowItem(uil,c,This,"path")->Expand=1;
laShowItem(uil,c,This,"remove");
}laEndCondition(uil,b1);
laEndRow(uil,b);
laShowSeparator(uil,c);
laShowLabel(uil,c,"Axes",0,0);
for(int i=0;i<8;i++){
if(!(i%2)){ b=laBeginRow(uil,c,0,0); }
sprintf(buf,"a%d",i);
laShowLabel(uil,c,buf,0,0); laShowItem(uil,c,This,buf)->Expand=1;
if(i%2){ laEndRow(uil,b); }
}
b1=laOnConditionToggle(uil,c,0,0,0,0,0); strSafeSet(&b1->ExtraInstructions,"text=More axes..."); b1->Flags|=LA_TEXT_ALIGN_LEFT;
for(int i=8;iExpand=1;
if(i%2){ laEndRow(uil,b); }
}
laEndCondition(uil,b1);
laShowSeparator(uil,c);
laShowLabel(uil,c,"Buttons",0,0);
for(int i=0;i<16;i++){
if(!(i%2)){ b=laBeginRow(uil,c,0,0); }
sprintf(buf,"b%d",i);
laShowLabel(uil,c,buf,0,0); laShowItem(uil,c,This,buf)->Expand=1;
if(i%2){ laEndRow(uil,b); }
}
b1=laOnConditionToggle(uil,c,0,0,0,0,0); strSafeSet(&b1->ExtraInstructions,"text=More buttons..."); b1->Flags|=LA_TEXT_ALIGN_LEFT;
for(int i=8;iExpand=1;
if(i%2){ laEndRow(uil,b); }
}
laEndCondition(uil,b1);
}
void laui_X56Throttle(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
laColumn* c=laFirstColumn(uil),*cl, *cr, *crl,*crr, *rc, *vc, *rcl,*rcr;
laSplitColumn(uil,c,0.17); cl=laLeftColumn(c,0); cr=laRightColumn(c,0);
laSplitColumn(uil,cr,0.4); crl=laLeftColumn(cr,0); crr=laRightColumn(cr,0);
laSplitColumn(uil,crr,0.6); rc=laLeftColumn(crr,10); vc=laRightColumn(crr,0);
laSplitColumn(uil,rc,0.4); rcl=laLeftColumn(rc,2); rcr=laRightColumn(rc,0);
laUiItem* b,*ui,*g; laUiList*gu;
laUiItem* JB=laShowInvisibleItem(uil,c,This,"base");
laShowItem(uil,c,&JB->PP, "name")->Flags|=LA_TEXT_ALIGN_CENTER;
b=laBeginRow(uil,c,0,0);
laShowItem(uil,c,&JB->PP, "user_assigned_id");
laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(&JB->PP, "error"));{
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
}laElse(uil,b1);{
laShowItem(uil,c,&JB->PP, "path")->Expand=1;
laShowItem(uil,c,&JB->PP, "remove");
}laEndCondition(uil,b1);
laEndRow(uil,b);
laShowSeparator(uil,c);
laShowItem(uil,cl,This,"pinky_up");
laShowItem(uil,cl,This,"pinky_dn");
laShowSeparator(uil,cl);
laShowItem(uil,cl,This,"dial_fwd");
laShowItem(uil,cl,This,"dial_back");
b=laBeginRow(uil,crl,0,0);
ui=laShowItem(uil,crl,This,"bi");ui->Expand=1;
ui=laShowItem(uil,crl,This,"bh");ui->Expand=1;
laEndRow(uil,b);
b=laBeginRow(uil,crl,0,0);
ui=laShowItem(uil,crl,This,"thr1");ui->Expand=1;ui->Extra->HeightCoeff=10;ui->Flags|=LA_UI_FLAGS_TRANSPOSE;
laShowCompoundValue(ui,LA_SLOT_MARKER_1,This,"thr1_min");
laShowCompoundValue(ui,LA_SLOT_MARKER_2,This,"thr1_max");
ui=laShowItem(uil,crl,This,"thr2");ui->Expand=1;ui->Extra->HeightCoeff=10;ui->Flags|=LA_UI_FLAGS_TRANSPOSE;
laShowCompoundValue(ui,LA_SLOT_MARKER_1,This,"thr2_min");
laShowCompoundValue(ui,LA_SLOT_MARKER_2,This,"thr2_max");
laEndRow(uil,b);
b=laBeginRow(uil,crl,1,1);
laShowItem(uil,crl,This,"thr1_min")->Flags|=LA_UI_FLAGS_KNOB; laShowItem(uil,crl,This,"thr1_max")->Flags|=LA_UI_FLAGS_KNOB;
//laShowSeparator(uil,crl)->Expand=1;
laShowItem(uil,crl,This,"thr2_min")->Flags|=LA_UI_FLAGS_KNOB; laShowItem(uil,crl,This,"thr2_max")->Flags|=LA_UI_FLAGS_KNOB;
laEndRow(uil,b);
laShowItem(uil,rcl,This,"bf");
laShowItem(uil,rcr,This,"wf");
laShowItem(uil,rcl,This,"bg");
laShowItem(uil,rcr,This,"wg");
laShowSeparator(uil,cl);
laShowItem(uil,rcl,This,"slider");
laShowSeparator(uil,rcl);
laShowItem(uil,rcl,This,"be");
laShowItem(uil,rcl,This,"bball");
laShowItem(uil,rcr,This,"ball");
laShowItem(uil,rc,This,"h3")->Flags|=LA_UI_FLAGS_TRANSPOSE;
laShowItem(uil,rc,This,"h4")->Flags|=LA_UI_FLAGS_TRANSPOSE;
laShowItem(uil,vc,This,"t4_up");
laShowItem(uil,vc,This,"t4_dn"); laShowSeparator(uil,vc);
laShowItem(uil,vc,This,"t3_up");
laShowItem(uil,vc,This,"t3_dn"); laShowSeparator(uil,vc);
laShowItem(uil,vc,This,"t2_up");
laShowItem(uil,vc,This,"t2_dn"); laShowSeparator(uil,vc);
laShowItem(uil,vc,This,"t1_up");
laShowItem(uil,vc,This,"t1_dn"); laShowSeparator(uil,vc);
laShowItem(uil,vc,This,"r3");
laShowItem(uil,vc,This,"r4");
laShowSeparator(uil,c);
laShowLabel(uil,cl,"Mode",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
laShowItem(uil,cl,This,"mode");
laShowLabel(uil,cr,"Switches",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
b=laBeginRow(uil,cr,0,0);
laShowItem(uil,cr,This,"sw1")->Expand=1;
laShowItem(uil,cr,This,"sw3")->Expand=1;
laShowItem(uil,cr,This,"sw5")->Expand=1;
laEndRow(uil,b);
b=laBeginRow(uil,cr,0,0);
laShowItem(uil,cr,This,"sw2")->Expand=1;
laShowItem(uil,cr,This,"sw4")->Expand=1;
laShowItem(uil,cr,This,"sw6")->Expand=1;
laEndRow(uil,b);
}
void laui_X56Stick(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
laColumn* c=laFirstColumn(uil),*cl, *cc, *cr;
laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,10); cr=laRightColumn(c,0);
laSplitColumn(uil,cr,0.8); cc=laLeftColumn(cr,0); cr=laRightColumn(cr,10);
laUiItem* b;
laUiItem* JB=laShowInvisibleItem(uil,c,This,"base");
laShowItem(uil,c,&JB->PP, "name")->Flags|=LA_TEXT_ALIGN_CENTER;
b=laBeginRow(uil,c,0,0);
laShowItem(uil,c,&JB->PP, "user_assigned_id");
laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(&JB->PP, "error"));{
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
}laElse(uil,b1);{
laShowItem(uil,c,&JB->PP, "path")->Expand=1;
laShowItem(uil,c,&JB->PP, "remove");
}laEndCondition(uil,b1);
laEndRow(uil,b);
laShowSeparator(uil,c);
laShowItem(uil,cl,This,"ba");
laShowItem(uil,cl,This,"pov");
laShowSeparator(uil,cl);
laShowLabel(uil,cl,"Thumb",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
laShowItem(uil,cl,This,"bc");
laShowItem(uil,cl,This,"ball");
laShowSeparator(uil,cl);
laShowLabel(uil,cl,"Pinky",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
laShowItem(uil,cl,This,"pinkyl");
laShowItem(uil,cl,This,"pinky");
laShowItem(uil,cr,This,"bb");
laShowSeparator(uil,cr);
laShowItem(uil,cc,This,"trigger");
laShowItem(uil,cc,This,"stick");
laShowItem(uil,cc,This,"rudder");
laShowLabel(uil,cr,"H1",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
laShowItem(uil,cr,This,"h1");
laShowSeparator(uil,cr);
laShowLabel(uil,cr,"H2",0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
laShowItem(uil,cr,This,"h2");
}