|
@@ -43,8 +43,15 @@ extern LA MAIN;
|
|
#define LA_JS_TYPE_X56_THROTTLE 1
|
|
#define LA_JS_TYPE_X56_THROTTLE 1
|
|
#define LA_JS_TYPE_X56_STICK 2
|
|
#define LA_JS_TYPE_X56_STICK 2
|
|
|
|
|
|
-char LA_JS_BTN_NAMES[LA_JS_MAX_BUTTONS][10];
|
|
|
|
-char LA_JS_AXIS_NAMES[LA_JS_MAX_AXES][10];
|
|
|
|
|
|
+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){
|
|
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, "Throttle")){ return LA_JS_TYPE_X56_THROTTLE; }
|
|
@@ -52,15 +59,7 @@ int la_IdentifyControllerInternalType(char* name){
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-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);
|
|
|
|
- lstAppendItem(&MAIN.Controllers,c);
|
|
|
|
- c->UserAssignedID=MAIN.NextControllerID; MAIN.NextControllerID++;
|
|
|
|
-
|
|
|
|
|
|
+void la_EnsureControllerNames(laController* c){
|
|
laPropContainer*pc=la_EnsureSubTarget(LA_PROP_CONTROLLER,c);
|
|
laPropContainer*pc=la_EnsureSubTarget(LA_PROP_CONTROLLER,c);
|
|
if(!pc){ return c; }
|
|
if(!pc){ return c; }
|
|
for(laProp* p=pc->Props.pFirst;p;p=p->Item.pNext){
|
|
for(laProp* p=pc->Props.pFirst;p;p=p->Item.pNext){
|
|
@@ -78,12 +77,24 @@ laController* la_NewController(char* name, char* path, int device, int NumAxes,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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;
|
|
return c;
|
|
}
|
|
}
|
|
void la_DestroyController(laController* c){
|
|
void la_DestroyController(laController* c){
|
|
- strSafeDestroy(&c->Name); strSafeDestroy(&c->Path);
|
|
|
|
- memFree(c); laNotifyUsers("la.controllers");
|
|
|
|
|
|
+ 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){
|
|
laController* la_FindControllerWithID(int id){
|
|
@@ -185,6 +196,7 @@ void la_UpdateControllerStatus(){
|
|
#ifdef __linux__
|
|
#ifdef __linux__
|
|
struct input_event event; int HasEvent=0;
|
|
struct input_event event; int HasEvent=0;
|
|
for(laController* c=MAIN.Controllers.pFirst;c;c=c->Item.pNext){ if(c->Error) continue;
|
|
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){
|
|
int bytes; while((bytes=read(c->fd, &event, sizeof(struct input_event)))>0){
|
|
if(event.type == EV_KEY){
|
|
if(event.type == EV_KEY){
|
|
int idx = la_ControllerButtonToIndex(c,event.code); if(idx<0) continue;
|
|
int idx = la_ControllerButtonToIndex(c,event.code); if(idx<0) continue;
|
|
@@ -194,8 +206,6 @@ void la_UpdateControllerStatus(){
|
|
else if(event.type == EV_ABS){
|
|
else if(event.type == EV_ABS){
|
|
int idx = la_ControllerAxisToIndex(c,event.code); if(idx<0) continue; HasEvent=1;
|
|
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]))));
|
|
c->AxisValues[idx]=rint(tnsLinearItp(-32768.0f,32767.0f,(((real)event.value-c->AxisMins[idx])/(c->AxisMaxes[idx]-c->AxisMins[idx]))));
|
|
- if(idx>4)
|
|
|
|
- printf("%d %d\n",event.value,idx);
|
|
|
|
if(abs(c->AxisValues[idx]-c->SaveAxisValues[idx])>10000){ c->SaveAxisValues[idx]=c->AxisValues[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();
|
|
MAIN.LastControllerAxis=idx; MAIN.LastControllerAxisDevice=c->UserAssignedID; MAIN.ControllerHasNewAxis = 1; laRetriggerOperators();
|
|
}
|
|
}
|
|
@@ -207,11 +217,38 @@ void la_UpdateControllerStatus(){
|
|
#endif
|
|
#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(){
|
|
void la_RefreshControllers(){
|
|
- laController* c; while(c=lstPopItem(&MAIN.Controllers)){ la_DestroyController(c); } MAIN.NextControllerID=0;
|
|
|
|
la_InitControllers();
|
|
la_InitControllers();
|
|
|
|
+ la_RemoveDuplicatedControllers();
|
|
}
|
|
}
|
|
-int OPINV_RefreshControllers(){
|
|
|
|
|
|
+int OPINV_RefreshControllers(laOperator* a, laEvent* e){
|
|
la_RefreshControllers();
|
|
la_RefreshControllers();
|
|
#ifdef __linux__
|
|
#ifdef __linux__
|
|
la_ScanWacomDevices(MAIN.dpy,XIAllDevices);
|
|
la_ScanWacomDevices(MAIN.dpy,XIAllDevices);
|
|
@@ -220,20 +257,68 @@ int OPINV_RefreshControllers(){
|
|
MAIN.WinTabOpened = 0;
|
|
MAIN.WinTabOpened = 0;
|
|
if(MAIN.CurrentWindow){ la_OpenWacomWinTab(MAIN.CurrentWindow->win); }
|
|
if(MAIN.CurrentWindow){ la_OpenWacomWinTab(MAIN.CurrentWindow->win); }
|
|
#endif
|
|
#endif
|
|
|
|
+ laNotifyUsers("la.controllers");
|
|
return LA_FINISHED;
|
|
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));
|
|
|
|
+ c->fd=open(SSTR(c->Path),O_RDWR | O_NONBLOCK); if(c->fd<0){ c->Error=1; }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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;
|
|
|
|
+ //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* name, char* desc, int i, int array_len, char* array_prefix){
|
|
|
|
|
|
+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,
|
|
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);
|
|
|
|
|
|
+ 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,"IDLE", "Idle", "Button is not pressed", 0, 0);
|
|
laAddEnumItemAs(p,"ACTIVE", "Active", "Button is pressed", 1, 0);
|
|
laAddEnumItemAs(p,"ACTIVE", "Active", "Button is pressed", 1, 0);
|
|
p->ElementBytes=1;
|
|
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* desc, int i, int array_len, char* array_prefix){
|
|
|
|
|
|
+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,
|
|
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)->ElementBytes = 2;
|
|
|
|
|
|
+ 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,
|
|
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;
|
|
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,
|
|
if(id_max) laAddIntProperty(pc,id_max,id_max,desc,0,
|
|
@@ -243,14 +328,20 @@ void la_AddAxisProp(laPropContainer* pc, char* id, char* name, char* id_min, cha
|
|
if(id_cmax) laAddIntProperty(pc,id_cmin,id_cmin,desc,0,
|
|
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;
|
|
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){
|
|
void la_AddGenericButtonProps(laPropContainer* pc){
|
|
- 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); }
|
|
|
|
|
|
+ for(int i=0;i<LA_JS_MAX_BUTTONS;i++){ char* name=LA_JS_BTN_NAMES[i]; la_AddButtonProp(pc,name,LA_JS_BTN_MAP_NAMES[i],name,name,i,0,0); }
|
|
}
|
|
}
|
|
void la_AddGenericAxisProps(laPropContainer* pc){
|
|
void la_AddGenericAxisProps(laPropContainer* pc){
|
|
- for(int i=0;i<LA_JS_MAX_AXES;i++){ char* name=LA_JS_AXIS_NAMES[i]; la_AddAxisProp(pc,name,name,0,0,0,0,name,i,0,0); }
|
|
|
|
|
|
+ for(int i=0;i<LA_JS_MAX_AXES;i++){ char* name=LA_JS_BTN_NAMES[i]; la_AddAxisProp(pc,name, name, LA_JS_AXIS_LMIN_NAMES[i], LA_JS_AXIS_LMAX_NAMES[i],
|
|
|
|
+ LA_JS_AXIS_CMIN_NAMES[i],LA_JS_AXIS_CMAX_NAMES[i], LA_JS_AXIS_MAP_NAMES[i], name,i,0,0); }
|
|
}
|
|
}
|
|
-#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",desc,i,array_len,array_prefix)
|
|
|
|
|
|
|
|
void laui_GenericJoystick(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context);
|
|
void laui_GenericJoystick(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context);
|
|
void laui_X56Throttle(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context);
|
|
void laui_X56Throttle(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context);
|
|
@@ -269,19 +360,27 @@ laPropContainer* laget_ControllerType(laController* c){
|
|
}
|
|
}
|
|
|
|
|
|
void la_RegisterControllerProps(){
|
|
void la_RegisterControllerProps(){
|
|
- for(int i=0;i<LA_JS_MAX_AXES;i++){ sprintf(LA_JS_AXIS_NAMES[i],"a%d",i); }
|
|
|
|
- for(int i=0;i<LA_JS_MAX_BUTTONS;i++){ sprintf(LA_JS_BTN_NAMES[i],"b%d",i); }
|
|
|
|
|
|
+ for(int i=0;i<LA_JS_MAX_AXES;i++){ sprintf(LA_JS_AXIS_NAMES[i],"a%d",i);
|
|
|
|
+ sprintf(LA_JS_AXIS_MAP_NAMES[i],"a%d_map",i);
|
|
|
|
+ sprintf(LA_JS_AXIS_CMAX_NAMES[i],"a%d_cmax",i);
|
|
|
|
+ sprintf(LA_JS_AXIS_CMIN_NAMES[i],"a%d_cmin",i);
|
|
|
|
+ sprintf(LA_JS_AXIS_LMAX_NAMES[i],"a%d_max",i);
|
|
|
|
+ sprintf(LA_JS_AXIS_LMIN_NAMES[i],"a%d_min",i);
|
|
|
|
+ }
|
|
|
|
+ for(int i=0;i<LA_JS_MAX_BUTTONS;i++){ sprintf(LA_JS_BTN_NAMES[i],"b%d",i); sprintf(LA_JS_BTN_MAP_NAMES[i],"b%d_map",i); }
|
|
|
|
|
|
laCreateOperatorType("LA_refresh_controllers", "Refresh Controllers", "Look for connected controllers",0,0,0,OPINV_RefreshControllers,0,U'🗘',0);
|
|
laCreateOperatorType("LA_refresh_controllers", "Refresh Controllers", "Look for connected controllers",0,0,0,OPINV_RefreshControllers,0,U'🗘',0);
|
|
|
|
+ laCreateOperatorType("LA_remove_controller", "Remove Controller", "Remove controller config",0,0,0,OPINV_RemoveController,OPMOD_RemoveController,U'🞫',0);
|
|
|
|
|
|
laPropContainer* pc; laProp* p;
|
|
laPropContainer* pc; laProp* p;
|
|
|
|
|
|
- pc=laAddPropertyContainer("la_controller", "Controller", "A joystick/gamepad controller", U'🕹', laui_GenericJoystick, sizeof(laController), 0,0,1);
|
|
|
|
|
|
+ pc=laAddPropertyContainer("la_controller", "Controller", "A joystick/gamepad controller", U'🕹', laui_GenericJoystick, sizeof(laController), lapost_Controller,0,1);
|
|
LA_PC_JS_GENERIC = pc;
|
|
LA_PC_JS_GENERIC = pc;
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
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,0);
|
|
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,0);
|
|
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);
|
|
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);
|
|
|
|
+ laAddOperatorProperty(pc,"remove","Remove","Remove this controller config","LA_remove_controller",0,0);
|
|
la_AddGenericButtonProps(pc);
|
|
la_AddGenericButtonProps(pc);
|
|
la_AddGenericAxisProps(pc);
|
|
la_AddGenericAxisProps(pc);
|
|
|
|
|
|
@@ -296,34 +395,34 @@ void la_RegisterControllerProps(){
|
|
ADD_AXIS_PROP(pc,"wg","WG","Wheel G (smaller wheel)",5,0,0);
|
|
ADD_AXIS_PROP(pc,"wg","WG","Wheel G (smaller wheel)",5,0,0);
|
|
ADD_AXIS_PROP(pc,"r4","RTY4","Rotary 4",6,0,0);
|
|
ADD_AXIS_PROP(pc,"r4","RTY4","Rotary 4",6,0,0);
|
|
ADD_AXIS_PROP(pc,"r3","RTY3","Rotary 3",7,0,0);
|
|
ADD_AXIS_PROP(pc,"r3","RTY3","Rotary 3",7,0,0);
|
|
- la_AddButtonProp(pc,"be","E","Button E (thumb flat switch)", 0,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bf","F","Button F (big push down switch)", 1,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bg","G","Button G (smaller up-side-down switch)", 2,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bi","I","Button I (left reverser)", 3,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bh","H","Button H (right reverser)", 4,0,0);
|
|
|
|
- la_AddButtonProp(pc,"sw1","SW1","Switch 1", 5,0,0);
|
|
|
|
- la_AddButtonProp(pc,"sw2","SW2","Switch 2", 6,0,0);
|
|
|
|
- la_AddButtonProp(pc,"sw3","SW3","Switch 3", 7,0,0);
|
|
|
|
- la_AddButtonProp(pc,"sw4","SW4","Switch 4", 8,0,0);
|
|
|
|
- la_AddButtonProp(pc,"sw5","SW5","Switch 5", 9,0,0);
|
|
|
|
- la_AddButtonProp(pc,"sw6","SW6","Switch 6", 10,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t1_up","T1+","Toggle 1+", 11,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t1_dn","T1-","Toggle 1-", 12,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t2_up","T2+","Toggle 2+", 13,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t2_dn","T2-","Toggle 2-", 14,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t3_up","T3+","Toggle 3+", 15,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t3_dn","T3-","Toggle 3-", 16,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t4_up","T4+","Toggle 4+", 17,0,0);
|
|
|
|
- la_AddButtonProp(pc,"t4_dn","T4-","Toggle 4-", 18,0,0);
|
|
|
|
- la_AddButtonProp(pc,"h3","H3","Hat 3 (Upper round hat)", 19,4,"N,E,S,W");
|
|
|
|
- la_AddButtonProp(pc,"h4","H4","Hat 4 (lower jagged hat)", 23,4,"N,E,S,W");
|
|
|
|
- la_AddButtonProp(pc,"pinky_up","P+","Pinky up", 27,0,0);
|
|
|
|
- la_AddButtonProp(pc,"pinky_dn","P-","Pinky down", 28,0,0);
|
|
|
|
- la_AddButtonProp(pc,"dial_fwd","D+","Dial forward", 29,0,0);
|
|
|
|
- la_AddButtonProp(pc,"dial_back","D-","Dial backward", 30,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bball","BP","Ball push", 31,0,0);
|
|
|
|
- la_AddButtonProp(pc,"slider","SLD","Slider", 32,0,0);
|
|
|
|
- la_AddButtonProp(pc,"mode","Mode","Mode switch", 33,3,"M1,M2,S1");
|
|
|
|
|
|
+ ADD_BUTTON_PROP(pc,"be","E","Button E (thumb flat switch)", 0,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bf","F","Button F (big push down switch)", 1,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bg","G","Button G (smaller up-side-down switch)", 2,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bi","I","Button I (left reverser)", 3,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bh","H","Button H (right reverser)", 4,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"sw1","SW1","Switch 1", 5,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"sw2","SW2","Switch 2", 6,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"sw3","SW3","Switch 3", 7,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"sw4","SW4","Switch 4", 8,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"sw5","SW5","Switch 5", 9,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"sw6","SW6","Switch 6", 10,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t1_up","T1+","Toggle 1+", 11,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t1_dn","T1-","Toggle 1-", 12,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t2_up","T2+","Toggle 2+", 13,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t2_dn","T2-","Toggle 2-", 14,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t3_up","T3+","Toggle 3+", 15,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t3_dn","T3-","Toggle 3-", 16,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t4_up","T4+","Toggle 4+", 17,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"t4_dn","T4-","Toggle 4-", 18,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"h3","H3","Hat 3 (Upper round hat)", 19,4,"N,E,S,W");
|
|
|
|
+ ADD_BUTTON_PROP(pc,"h4","H4","Hat 4 (lower jagged hat)", 23,4,"N,E,S,W");
|
|
|
|
+ ADD_BUTTON_PROP(pc,"pinky_up","P+","Pinky up", 27,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"pinky_dn","P-","Pinky down", 28,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"dial_fwd","D+","Dial forward", 29,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"dial_back","D-","Dial backward", 30,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bball","BP","Ball push", 31,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"slider","SLD","Slider", 32,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"mode","Mode","Mode switch", 33,3,"M1,M2,S1");
|
|
|
|
|
|
|
|
|
|
pc=laAddPropertyContainer("la_controller_x56_stick", "X56 Stick", "X56 Stick", 0,laui_X56Stick,sizeof(laController),0,0,1);
|
|
pc=laAddPropertyContainer("la_controller_x56_stick", "X56 Stick", "X56 Stick", 0,laui_X56Stick,sizeof(laController),0,0,1);
|
|
@@ -334,14 +433,14 @@ void la_RegisterControllerProps(){
|
|
ADD_AXIS_PROP(pc,"ball","Ball","Ball stick",2,2,"Left/Right,Up/Down");
|
|
ADD_AXIS_PROP(pc,"ball","Ball","Ball stick",2,2,"Left/Right,Up/Down");
|
|
ADD_AXIS_PROP(pc,"rudder","Rudder","Ruder twist",4,0,0);
|
|
ADD_AXIS_PROP(pc,"rudder","Rudder","Ruder twist",4,0,0);
|
|
ADD_AXIS_PROP(pc,"pov","POV","POV hat",5,2,"Left/Right,Up/Down");
|
|
ADD_AXIS_PROP(pc,"pov","POV","POV hat",5,2,"Left/Right,Up/Down");
|
|
- la_AddButtonProp(pc,"trigger","Trigger","Trigger", 0,0,0);
|
|
|
|
- la_AddButtonProp(pc,"ba","A","Button A", 1,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bb","B","Button B (Side of stick)", 2,0,0);
|
|
|
|
- la_AddButtonProp(pc,"bball","BP","Ball push", 3,0,0); la_AddButtonProp(pc,"bc","BC","Button C (ball push)", 3,0,0);
|
|
|
|
- la_AddButtonProp(pc,"pinky","PK","Pinky small button", 4,0,0); la_AddButtonProp(pc,"bd","BD","Button D pinky small button", 4,0,0);
|
|
|
|
- la_AddButtonProp(pc,"pinkyl","PKL","Pinky lever", 5,0,0);
|
|
|
|
- la_AddButtonProp(pc,"h1","H1","Hat 1 (Upper round hat)", 6,4,"N,E,S,W");
|
|
|
|
- la_AddButtonProp(pc,"h2","H2","Hat 2 (lower jagged hat)", 10,4,"N,E,S,W");
|
|
|
|
|
|
+ ADD_BUTTON_PROP(pc,"trigger","Trigger","Trigger", 0,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"ba","A","Button A", 1,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bb","B","Button B (Side of stick)", 2,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"bball","BP","Ball push", 3,0,0); ADD_BUTTON_PROP(pc,"bc","BC","Button C (ball push)", 3,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"pinky","PK","Pinky small button", 4,0,0); ADD_BUTTON_PROP(pc,"bd","BD","Button D pinky small button", 4,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"pinkyl","PKL","Pinky lever", 5,0,0);
|
|
|
|
+ ADD_BUTTON_PROP(pc,"h1","H1","Hat 1 (Upper round hat)", 6,4,"N,E,S,W");
|
|
|
|
+ ADD_BUTTON_PROP(pc,"h2","H2","Hat 2 (lower jagged hat)", 10,4,"N,E,S,W");
|
|
//button 14-16 not sure where it is....
|
|
//button 14-16 not sure where it is....
|
|
}
|
|
}
|
|
|
|
|
|
@@ -356,6 +455,7 @@ void laui_GenericJoystick(laUiList *uil, laPropPack *This, laPropPack *Extra, la
|
|
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
|
|
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
|
|
}laElse(uil,b1);{
|
|
}laElse(uil,b1);{
|
|
laShowItem(uil,c,This,"path")->Expand=1;
|
|
laShowItem(uil,c,This,"path")->Expand=1;
|
|
|
|
+ laShowItem(uil,c,This,"remove");
|
|
}laEndCondition(uil,b1);
|
|
}laEndCondition(uil,b1);
|
|
laEndRow(uil,b);
|
|
laEndRow(uil,b);
|
|
laShowSeparator(uil,c);
|
|
laShowSeparator(uil,c);
|
|
@@ -403,13 +503,16 @@ void laui_X56Throttle(laUiList *uil, laPropPack *This, laPropPack *Extra, laColu
|
|
laSplitColumn(uil,rc,0.4); rcl=laLeftColumn(rc,2); rcr=laRightColumn(rc,0);
|
|
laSplitColumn(uil,rc,0.4); rcl=laLeftColumn(rc,2); rcr=laRightColumn(rc,0);
|
|
laUiItem* b,*ui,*g; laUiList*gu;
|
|
laUiItem* b,*ui,*g; laUiList*gu;
|
|
|
|
|
|
- laShowItem(uil,c,This,"base.name")->Flags|=LA_TEXT_ALIGN_CENTER;
|
|
|
|
|
|
+ laUiItem* JB=laShowInvisibleItem(uil,c,This,"base");
|
|
|
|
+
|
|
|
|
+ laShowItem(uil,c,&JB->PP, "name")->Flags|=LA_TEXT_ALIGN_CENTER;
|
|
b=laBeginRow(uil,c,0,0);
|
|
b=laBeginRow(uil,c,0,0);
|
|
- laShowItem(uil,c,This,"base.user_assigned_id");
|
|
|
|
- laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(This,"base.error"));{
|
|
|
|
|
|
+ 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;
|
|
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
|
|
}laElse(uil,b1);{
|
|
}laElse(uil,b1);{
|
|
- laShowItem(uil,c,This,"base.path")->Expand=1;
|
|
|
|
|
|
+ laShowItem(uil,c,&JB->PP, "path")->Expand=1;
|
|
|
|
+ laShowItem(uil,c,&JB->PP, "remove");
|
|
}laEndCondition(uil,b1);
|
|
}laEndCondition(uil,b1);
|
|
laEndRow(uil,b);
|
|
laEndRow(uil,b);
|
|
laShowSeparator(uil,c);
|
|
laShowSeparator(uil,c);
|
|
@@ -490,13 +593,16 @@ void laui_X56Stick(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn
|
|
laSplitColumn(uil,cr,0.8); cc=laLeftColumn(cr,0); cr=laRightColumn(cr,10);
|
|
laSplitColumn(uil,cr,0.8); cc=laLeftColumn(cr,0); cr=laRightColumn(cr,10);
|
|
laUiItem* b;
|
|
laUiItem* b;
|
|
|
|
|
|
- laShowItem(uil,c,This,"base.name")->Flags|=LA_TEXT_ALIGN_CENTER;
|
|
|
|
|
|
+ laUiItem* JB=laShowInvisibleItem(uil,c,This,"base");
|
|
|
|
+
|
|
|
|
+ laShowItem(uil,c,&JB->PP, "name")->Flags|=LA_TEXT_ALIGN_CENTER;
|
|
b=laBeginRow(uil,c,0,0);
|
|
b=laBeginRow(uil,c,0,0);
|
|
- laShowItem(uil,c,This,"base.user_assigned_id");
|
|
|
|
- laUiItem* b1=laOnConditionThat(uil,c,laPropExpression(This,"base.error"));{
|
|
|
|
|
|
+ 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;
|
|
laShowLabel(uil,c,"Device error.",0,0)->Expand=1;
|
|
}laElse(uil,b1);{
|
|
}laElse(uil,b1);{
|
|
- laShowItem(uil,c,This,"base.path")->Expand=1;
|
|
|
|
|
|
+ laShowItem(uil,c,&JB->PP, "path")->Expand=1;
|
|
|
|
+ laShowItem(uil,c,&JB->PP, "remove");
|
|
}laEndCondition(uil,b1);
|
|
}laEndCondition(uil,b1);
|
|
laEndRow(uil,b);
|
|
laEndRow(uil,b);
|
|
laShowSeparator(uil,c);
|
|
laShowSeparator(uil,c);
|