lsnes rr0-β23
[lsnes.git] / include / core / controller.hpp
blob5ab719a9d956a03e61f5661ead5b9e3a1629fdbd
1 #ifndef _controller__hpp__included__
2 #define _controller__hpp__included__
4 #include "controllerdata.hpp"
6 /**
7 * Look up physcial controller ID by logical controller ID.
9 * parameter lid: Logical ID (0-7).
10 * returns: Physical ID. -1 if there is no such logical controller.
12 int controller_index_by_logical(unsigned lid) throw();
13 /**
14 * Look up physcial controller ID by analog controller ID.
16 * parameter aid: Analog ID (0-2).
17 * returns: Physical ID. -1 if there is no such controller.
19 int controller_index_by_analog(unsigned aid) throw();
20 /**
21 * Look up if controller is mouse by analog controller ID.
23 * parameter aid: Analog ID (0-2).
24 * returns: True if ID points to mouse, otherwise false.
26 bool controller_ismouse_by_analog(unsigned aid) throw();
27 /**
28 * Look up type of controller by logical controller ID.
30 * parameter lid: Logical ID (0-7).
31 * returns: The type of controller (not port!).
33 devicetype_t controller_type_by_logical(unsigned lid) throw();
34 /**
35 * Set port type.
37 * Parameter port: The port to set.
38 * Parameter ptype: New port type.
39 * Parameter set_core: If true, set port type in bsnes core, otherwise skip this step.
41 void controller_set_port_type(unsigned port, porttype_t ptype, bool set_core = true) throw();
43 /**
44 * Get current controls, assuming given frame.
46 * Parameter frame: Current frame number.
47 * Returns: Current controls, taking autohold and autofire into account.
49 controls_t get_current_controls(uint64_t frame);
51 /**
52 * Send analog input.
54 * Parameter x: X position of click.
55 * Parameter y: Y position of click.
56 * Parameter index: Index of button (0-2).
58 void send_analog_input(int32_t x, int32_t y, unsigned index);
60 /**
61 * Manipulate the reset flag in current controls.
63 * Parameter delay: Delay for reset (-1 for no reset)
65 void set_curcontrols_reset(int32_t delay);
67 /**
68 * Change the state of autohold.
70 * Parameter pid: The physical ID of controller.
71 * Parameter idx: The physical Index of the control.
72 * Parameter newstate: New state for autohold.
74 void change_autohold(unsigned pid, unsigned idx, bool newstate);
76 /**
77 * Read the state of autohold.
79 * Parameter pid: The physical ID of controller.
80 * Parameter idx: The physical Index of the control.
81 * Returns: True if autohold is in progress, false otherwise.
83 bool get_autohold(unsigned pid, unsigned idx);
85 /**
86 * Get the name of button.
88 * Parameter lidx: The logical index of the controller.
89 * Returns:
91 std::string get_button_name(unsigned lidx);
93 /**
94 * Logical to physical control ID transition.
96 * Parameter dtype: The device type.
97 * Parameter lidx: The logical index.
98 * Returns: The physical index or -1 if the logical index is invalid for type.
100 int get_physcial_id_for_control(devicetype_t dtype, unsigned lidx);
102 #endif