|
@@ -950,6 +950,14 @@ int OPINV_RemoveInputMappingEntry(laOperator *a, laEvent *e){
|
|
|
laEnableYesNoPanel(0, 0, "Confirm?", "Will remove this key map entry", e->x, e->y, 200, e);
|
|
|
return LA_RUNNING;
|
|
|
}
|
|
|
+int OPINV_ClearInputMappingFields(laOperator *a, laEvent *e){
|
|
|
+ if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
|
|
|
+ strSafeDestroy(&ime->Operator);strSafeDestroy(&ime->OperatorName);strSafeDestroy(&ime->OperatorArguments);
|
|
|
+ strSafeDestroy(&ime->Key); strSafeDestroy(&ime->Signal);
|
|
|
+ ime->OperatorBase=ime->OperatorType=0; ime->KeyValue=ime->SpecialKeyBits=0; ime->SignalValue=0;
|
|
|
+ ime->JoystickDevice=ime->Axis=ime->Button=0; ime->DeviceType=0; ime->Disabled=0;
|
|
|
+ return LA_FINISHED;
|
|
|
+}
|
|
|
|
|
|
int OPMOD_RemoveInputMapping(laOperator *a, laEvent *e){
|
|
|
if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMapping* im=a->This->EndInstance;
|
|
@@ -1012,6 +1020,7 @@ int OPMOD_InputMappingEntrySelectOperator(laOperator *a, laEvent *e){
|
|
|
laOperatorType* at=a->ConfirmData->PointerData;
|
|
|
strSafeSet(&ime->Operator,at->Identifier);
|
|
|
strSafeSet(&ime->OperatorName,at->Name);
|
|
|
+ ime->OperatorType = at;
|
|
|
laNotifyUsers("la.input_mapping");
|
|
|
}
|
|
|
return LA_FINISHED;
|
|
@@ -1031,7 +1040,7 @@ void laui_InputMappingEntryOperatorSelector(laUiList *uil, laPropPack *Base, laP
|
|
|
|
|
|
STRUCTURE(laKeyDetectorData){
|
|
|
int pad;
|
|
|
- int IsController;
|
|
|
+ int DeviceType;
|
|
|
int Key;
|
|
|
int SpecialKeyBit;
|
|
|
int Button, Axis, Device;
|
|
@@ -1045,7 +1054,7 @@ int OPEXT_InputMappingEntrySelectKey(laOperator* a,int exitmode){
|
|
|
int OPINV_InputMappingEntrySelectKey(laOperator *a, laEvent *e){
|
|
|
if(!a->This || !a->This->EndInstance) return LA_CANCELED; laInputMappingEntry* ime=a->This->EndInstance;
|
|
|
a->CustomData = memAcquire(sizeof(laKeyDetectorData));
|
|
|
- laEnableOperatorPanel(a,a->This,e->x-LA_RH*5,e->y-LA_RH,LA_RH*10,LA_RH*10,LA_RH*20,LA_RH*20,LA_RH*20,0,0,0,0,0,e);
|
|
|
+ laEnableOperatorPanel(a,a->This,e->x-LA_RH*5,e->y-LA_RH,LA_RH*10,LA_RH*10,LA_RH*20,LA_RH*20,LA_RH*10,0,0,0,0,0,e);
|
|
|
laOperatorModalOver(a);
|
|
|
return LA_RUNNING;
|
|
|
}
|
|
@@ -1054,30 +1063,31 @@ int OPMOD_InputMappingEntrySelectKey(laOperator *a, laEvent *e){
|
|
|
laKeyDetectorData* kdd=a->CustomData; if(!kdd){ return LA_FINISHED; }
|
|
|
char buf[64],*_next=buf;
|
|
|
if(e->type == LA_KEY_DOWN){
|
|
|
- kdd->Key = e->key; la_InputMappingGetKeyName(kdd->Key,e->SpecialKeyBit,buf); strSafeSet(&kdd->Str,buf); kdd->IsController=0;
|
|
|
+ kdd->Key = e->key; la_InputMappingGetKeyName(kdd->Key,e->SpecialKeyBit,buf); strSafeSet(&kdd->Str,buf); kdd->DeviceType=LA_INPUT_DEVICE_KEYBOARD;
|
|
|
laNotifyInstanceUsers(kdd); kdd->SpecialKeyBit=e->SpecialKeyBit;
|
|
|
return LA_RUNNING;
|
|
|
}elif(e->type == LA_EMPTY){
|
|
|
if(MAIN.ControllerHasNewAxis){
|
|
|
- kdd->Axis = MAIN.LastControllerAxis; kdd->Device = MAIN.LastControllerAxisDevice; kdd->Button =-1; kdd->IsController=1;
|
|
|
+ kdd->Axis = MAIN.LastControllerAxis; kdd->Device = MAIN.LastControllerAxisDevice; kdd->Button =-1; kdd->DeviceType=LA_INPUT_DEVICE_JOYSTICK;
|
|
|
strSafeSet(&kdd->Str,laControllerIDGetAxisName(kdd->Device,kdd->Axis)); laNotifyInstanceUsers(kdd);
|
|
|
}elif(MAIN.ControllerHasNewKey){
|
|
|
- kdd->Button = MAIN.LastControllerKey; kdd->Device = MAIN.LastControllerKeyDevice; kdd->Axis = -1; kdd->IsController=1;
|
|
|
+ kdd->Button = MAIN.LastControllerKey; kdd->Device = MAIN.LastControllerKeyDevice; kdd->Axis = -1; kdd->DeviceType=LA_INPUT_DEVICE_JOYSTICK;
|
|
|
strSafeSet(&kdd->Str,laControllerIDGetButtonName(kdd->Device,kdd->Button)); laNotifyInstanceUsers(kdd);
|
|
|
}
|
|
|
}
|
|
|
if(a->ConfirmData){
|
|
|
- if(a->ConfirmData->Mode == laConfirmString){
|
|
|
- a->ConfirmData->StrData;
|
|
|
- strSafeSet(&ime->Key,SSTR(kdd->Str));
|
|
|
- if(kdd->IsController){ ime->DeviceType = LA_INPUT_DEVICE_JOYSTICK; ime->Axis=kdd->Axis; ime->Button=kdd->Button; ime->JoystickDevice = kdd->Device; }
|
|
|
- else{ ime->DeviceType = LA_INPUT_DEVICE_KEYBOARD; ime->KeyValue = kdd->Key; ime->SpecialKeyBits=kdd->SpecialKeyBit; }
|
|
|
- laNotifyInstanceUsers(ime);
|
|
|
+ if(a->ConfirmData->Mode == LA_CONFIRM_CUSTOM_STRING){
|
|
|
+ char* ReportedEvent=a->ConfirmData->StrData;
|
|
|
+ strSafeSet(&kdd->Str,ReportedEvent);
|
|
|
+ kdd->DeviceType = LA_INPUT_DEVICE_MOUSE;
|
|
|
+ kdd->Key = la_InputMappingGetKeyFromName(ReportedEvent,&kdd->SpecialKeyBit);
|
|
|
+ laNotifyInstanceUsers(kdd);
|
|
|
return LA_RUNNING_PASS;
|
|
|
}
|
|
|
if(a->ConfirmData->Mode == LA_CONFIRM_OK){
|
|
|
strSafeSet(&ime->Key,SSTR(kdd->Str));
|
|
|
- if(kdd->IsController){ ime->DeviceType = LA_INPUT_DEVICE_JOYSTICK; ime->Axis=kdd->Axis; ime->Button=kdd->Button; ime->JoystickDevice = kdd->Device; }
|
|
|
+ if(kdd->DeviceType==LA_INPUT_DEVICE_JOYSTICK){ ime->DeviceType = LA_INPUT_DEVICE_JOYSTICK; ime->Axis=kdd->Axis; ime->Button=kdd->Button; ime->JoystickDevice = kdd->Device; }
|
|
|
+ elif(kdd->DeviceType==LA_INPUT_DEVICE_MOUSE){ ime->DeviceType = LA_INPUT_DEVICE_MOUSE; ime->KeyValue = kdd->Key; ime->SpecialKeyBits=kdd->SpecialKeyBit; }
|
|
|
else{ ime->DeviceType = LA_INPUT_DEVICE_KEYBOARD; ime->KeyValue = kdd->Key; ime->SpecialKeyBits=kdd->SpecialKeyBit; }
|
|
|
laNotifyInstanceUsers(ime);
|
|
|
}
|
|
@@ -1087,19 +1097,25 @@ int OPMOD_InputMappingEntrySelectKey(laOperator *a, laEvent *e){
|
|
|
}
|
|
|
void laui_InputMappingEntryKeySelector(laUiList *uil, laPropPack *Base, laPropPack *OperatorInst, laColumn *ExtraColumns, int context){
|
|
|
laColumn* c=laFirstColumn(uil);
|
|
|
+ laUiItem* b;
|
|
|
|
|
|
- laShowLabel(uil,c,"Press a key:",0,0);
|
|
|
+ laShowLabel(uil,c,"Press a key:",0,0)->Flags|=LA_UI_FLAGS_DISABLED;
|
|
|
laShowItem(uil,c,OperatorInst,"pressed_string")->Flags|=LA_UI_FLAGS_PLAIN;
|
|
|
|
|
|
- laUiItem* b=laBeginRow(uil,c,0,0);
|
|
|
+ laShowLabel(uil,c,"Or click mouse button in:",0,0)->Flags|=LA_UI_FLAGS_DISABLED;
|
|
|
+ laShowMouseActionReporter(uil,c,3,0,0)->Flags|=LA_TEXT_ALIGN_CENTER;
|
|
|
+
|
|
|
+ b=laBeginRow(uil,c,0,0);
|
|
|
laShowSeparator(uil,c)->Expand=1;
|
|
|
laShowItem(uil,c,0,"LA_confirm");
|
|
|
laEndRow(uil,b);
|
|
|
}
|
|
|
void laget_KeyDetectorPressedString(laKeyDetectorData* kdd, char* out, char** pivot){
|
|
|
- if(kdd->IsController){
|
|
|
+ if(kdd->DeviceType==LA_INPUT_DEVICE_JOYSTICK){
|
|
|
if(kdd->Axis>=0){ sprintf(out, "Controller %d axis \"%s\" (0x%0x)", kdd->Device, SSTR(kdd->Str), kdd->Axis); }
|
|
|
else{ sprintf(out, "Controller %d button \"%s\" (0x%0x)", kdd->Device, SSTR(kdd->Str), kdd->Button); }
|
|
|
+ }elif(kdd->DeviceType==LA_INPUT_DEVICE_MOUSE){
|
|
|
+ sprintf(out, "Mouse \"%s\" (0x%0x)", SSTR(kdd->Str), kdd->Key);
|
|
|
}else{
|
|
|
sprintf(out, "Keyboard \"%s\" (0x%0x)", SSTR(kdd->Str), kdd->Key);
|
|
|
}
|
|
@@ -2619,6 +2635,7 @@ void la_RegisterBuiltinOperators(){
|
|
|
laCreateOperatorType("LA_new_input_mapping_entry", "New Entry", "New input mapping entry", 0, 0, 0, OPINV_NewInputMappingEntry, 0, '+', LA_ACTUATOR_SYSTEM);
|
|
|
laCreateOperatorType("LA_remove_input_mapping", "Remove Mapping", "Remove input mapping", 0, 0, 0, OPINV_RemoveInputMapping, OPMOD_RemoveInputMapping, U'🞫', LA_ACTUATOR_SYSTEM);
|
|
|
laCreateOperatorType("LA_remove_input_mapping_entry", "Remove Entry", "Remove input mapping entry", 0, 0, 0, OPINV_RemoveInputMappingEntry, OPMOD_RemoveInputMappingEntry, U'🞫', LA_ACTUATOR_SYSTEM);
|
|
|
+ laCreateOperatorType("LA_reset_input_mapping_fields", "Reset Entry", "Reset mapping entry", 0, 0, 0, OPINV_ClearInputMappingFields, 0, U'⮌', LA_ACTUATOR_SYSTEM);
|
|
|
at = laCreateOperatorType("LA_input_mapping_entry_select_signal", "Select Signal", "Select signal for this entry", 0, 0, 0, OPINV_InputMappingEntrySelectSignal, OPMOD_InputMappingEntrySelectSignal, U'⯆', LA_ACTUATOR_SYSTEM);
|
|
|
at->UiDefine = laui_InputMappingEntrySignalSelector;
|
|
|
at = laCreateOperatorType("LA_input_mapping_entry_select_operator", "Select Operator", "Select operator for this entry", 0, 0, 0, OPINV_InputMappingEntrySelectOperator, OPMOD_InputMappingEntrySelectOperator, U'⯆', LA_ACTUATOR_SYSTEM);
|