*/}}
Browse Source

Fix joystick range and int get etc

YimingWu 9 months ago
parent
commit
a3dfbc9430
2 changed files with 5 additions and 3 deletions
  1. 3 1
      la_controllers.c
  2. 2 2
      la_data.c

+ 3 - 1
la_controllers.c

@@ -193,7 +193,9 @@ void la_UpdateControllerStatus(){
             }
             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->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];
                     MAIN.LastControllerAxis=idx; MAIN.LastControllerAxisDevice=c->UserAssignedID; MAIN.ControllerHasNewAxis = 1; laRetriggerOperators();
                 }

+ 2 - 2
la_data.c

@@ -1469,8 +1469,8 @@ int laGetIntArray(laPropPack *pp, int *result){
                 int *src = (pp->LastPs->p->OffsetIsPointer) ? ((int **)((BYTE *)pp->LastPs->UseInstance + pp->LastPs->p->Offset)) : ((int *)((BYTE *)pp->LastPs->UseInstance + pp->LastPs->p->Offset));
                 switch(pp->LastPs->p->ElementBytes){
                     default: case 4: memcpy(result, src, len * sizeof(int)); break;
-                    case 2: for(int i=0;i<len;i++){ result[i]=((short*)src)[i]; }
-                    case 1: for(int i=0;i<len;i++){ result[i]=((char*)src)[i]; }
+                    case 2: for(int i=0;i<len;i++){ result[i]=((short*)src)[i]; } break;
+                    case 1: for(int i=0;i<len;i++){ result[i]=((char*)src)[i]; } break;
                 }
             }else{ *result=0; }
             return 1;