File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,7 +108,10 @@ void release(HidControllerKeys btn)
108108 hiddbgSetHdlsState (controllerHandle , & controllerState );
109109}
110110
111- void joystickstate ( char * side , char * dx , char * dy )
111+ void setStickState ( int side , int dxVal , int dyVal )
112112{
113-
113+ initController ();
114+ controllerState .joysticks [side ].dx = dxVal ;
115+ controllerState .joysticks [side ].dy = dyVal ;
116+ hiddbgSetHdlsState (controllerHandle , & controllerState );
114117}
Original file line number Diff line number Diff line change @@ -14,4 +14,4 @@ void peek(u64 addr, u64 size);
1414void click (HidControllerKeys btn );
1515void press (HidControllerKeys btn );
1616void release (HidControllerKeys btn );
17- void joystickstate ( char * side , char * dx , char * dy );
17+ void setStickState ( int side , int dxVal , int dyVal );
Original file line number Diff line number Diff line change @@ -133,6 +133,31 @@ int argmain(int argc, char **argv)
133133 release (key );
134134 }
135135
136+ //setStick <left or right stick> <x value> <y value>
137+ if (!strcmp (argv [0 ], "setStick" ))
138+ {
139+ if (argc != 4 )
140+ return 0 ;
141+
142+ int side = 0 ;
143+ if (!strcmp (argv [1 ], "LEFT" )){
144+ side = JOYSTICK_LEFT ;
145+ }else if (!strcmp (argv [1 ], "RIGHT" )){
146+ side = JOYSTICK_RIGHT ;
147+ }else {
148+ return 0 ;
149+ }
150+
151+ int dxVal = strtol (argv [2 ], NULL , 0 );
152+ if (dxVal > JOYSTICK_MAX ) dxVal = JOYSTICK_MAX ; //0x7FFF
153+ if (dxVal < JOYSTICK_MIN ) dxVal = JOYSTICK_MIN ; //-0x8000
154+ int dyVal = strtol (argv [3 ], NULL , 0 );
155+ if (dxVal > JOYSTICK_MAX ) dxVal = JOYSTICK_MAX ;
156+ if (dxVal < JOYSTICK_MIN ) dxVal = JOYSTICK_MIN ;
157+
158+ setStickState (side , dxVal , dyVal );
159+ }
160+
136161 return 0 ;
137162}
138163
You can’t perform that action at this time.
0 commit comments