mirror of
				https://github.com/glfw/glfw.git
				synced 2025-10-30 20:22:30 +00:00 
			
		
		
		
	Added joystick API error checks for shared and Linux code.
This commit is contained in:
		
							parent
							
								
									c28fb4ca0c
								
							
						
					
					
						commit
						1839c1c73d
					
				| @ -47,6 +47,12 @@ GLFWAPI int glfwGetJoystickParam(int joy, int param) | |||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (joy < 0 || joy > GLFW_JOYSTICK_LAST) | ||||||
|  |     { | ||||||
|  |         _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     return _glfwPlatformGetJoystickParam(joy, param); |     return _glfwPlatformGetJoystickParam(joy, param); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -65,6 +71,18 @@ GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes) | |||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (joy < 0 || joy > GLFW_JOYSTICK_LAST) | ||||||
|  |     { | ||||||
|  |         _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (pos == NULL || numaxes < 0) | ||||||
|  |     { | ||||||
|  |         _glfwSetError(GLFW_INVALID_VALUE, NULL); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // Clear positions
 |     // Clear positions
 | ||||||
|     for (i = 0;  i < numaxes;  i++) |     for (i = 0;  i < numaxes;  i++) | ||||||
|         pos[i] = 0.0f; |         pos[i] = 0.0f; | ||||||
| @ -89,6 +107,18 @@ GLFWAPI int glfwGetJoystickButtons(int joy, | |||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (joy < 0 || joy > GLFW_JOYSTICK_LAST) | ||||||
|  |     { | ||||||
|  |         _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (buttons == NULL || numbuttons < 0) | ||||||
|  |     { | ||||||
|  |         _glfwSetError(GLFW_INVALID_VALUE, NULL); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // Clear button states
 |     // Clear button states
 | ||||||
|     for (i = 0;  i < numbuttons;  i++) |     for (i = 0;  i < numbuttons;  i++) | ||||||
|         buttons[i] = GLFW_RELEASE; |         buttons[i] = GLFW_RELEASE; | ||||||
|  | |||||||
| @ -236,7 +236,7 @@ int _glfwPlatformGetJoystickParam(int joy, int param) | |||||||
|             return _glfwLibrary.X11.joystick[joy].numButtons; |             return _glfwLibrary.X11.joystick[joy].numButtons; | ||||||
| 
 | 
 | ||||||
|         default: |         default: | ||||||
|             break; |             _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user