| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | // Copyright 2013 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2013-06-13 23:09:55 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2013-06-13 23:09:55 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "InputCommon/ControllerInterface/Device.h"
 | 
					
						
							| 
									
										
										
										
											2013-06-13 23:09:55 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace ciface | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | namespace ExpressionParser | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ControlQualifier | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	bool has_device; | 
					
						
							|  |  |  | 	Core::DeviceQualifier device_qualifier; | 
					
						
							|  |  |  | 	std::string control_name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ControlQualifier() : has_device(false) {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	operator std::string() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (has_device) | 
					
						
							|  |  |  | 			return device_qualifier.ToString() + ":" + control_name; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return control_name; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ControlFinder | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	ControlFinder(const Core::DeviceContainer &container_, const Core::DeviceQualifier &default_, const bool is_input_) : container(container_), default_device(default_), is_input(is_input_) {} | 
					
						
							|  |  |  | 	Core::Device::Control *FindControl(ControlQualifier qualifier); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	Core::Device *FindDevice(ControlQualifier qualifier); | 
					
						
							|  |  |  | 	const Core::DeviceContainer &container; | 
					
						
							|  |  |  | 	const Core::DeviceQualifier &default_device; | 
					
						
							|  |  |  | 	bool is_input; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ExpressionNode; | 
					
						
							|  |  |  | class Expression | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-03-09 21:14:26 +01:00
										 |  |  | 	Expression() : node(nullptr) {} | 
					
						
							| 
									
										
										
										
											2013-06-26 20:19:23 -04:00
										 |  |  | 	Expression(ExpressionNode *node); | 
					
						
							| 
									
										
										
										
											2013-06-13 23:09:55 -04:00
										 |  |  | 	~Expression(); | 
					
						
							|  |  |  | 	ControlState GetValue(); | 
					
						
							|  |  |  | 	void SetValue (ControlState state); | 
					
						
							|  |  |  | 	int num_controls; | 
					
						
							| 
									
										
										
										
											2013-06-26 20:19:23 -04:00
										 |  |  | 	ExpressionNode *node; | 
					
						
							| 
									
										
										
										
											2013-06-13 23:09:55 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum ExpressionParseStatus | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	EXPRESSION_PARSE_SUCCESS = 0, | 
					
						
							|  |  |  | 	EXPRESSION_PARSE_SYNTAX_ERROR, | 
					
						
							|  |  |  | 	EXPRESSION_PARSE_NO_DEVICE, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ExpressionParseStatus ParseExpression(std::string expr, ControlFinder &finder, Expression **expr_out); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | } |