ObjFW  Diff

Differences From Artifact [542208ba0a]:

To Artifact [64229ea449]:


20
21
22
23
24
25
26


27
28
29
30
31
32
33











34
35

36
37





38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#import "OFObject.h"
#import "OFString.h"

OF_ASSUME_NONNULL_BEGIN

/** @file */



@class OFSet OF_GENERIC(ObjectType);

/**
 * @brief A class for reading state from a game controller.
 */
OF_SUBCLASSING_RESTRICTED
@interface OFGameController: OFObject











#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic) size_t numControllers;

#endif






/**
 * @brief The buttons the controller has.
 */
@property (readonly, nonatomic) OFSet OF_GENERIC(OFString *) *buttons;

/**
 * @brief The currently pressed buttons on the controller.
 */
@property (readonly, nonatomic) OFSet OF_GENERIC(OFString *) *pressedButtons;


/**
 * @brief The number of analog sticks the controller has.
 */
@property (readonly, nonatomic) size_t numAnalogSticks;

/**
 * @brief Returns the number of available controllers.
 *
 * @return The number of available controllers
 */
+ (size_t)numControllers;

/**
 * @brief Returns the specified controller.
 *
 * @param index The index of the controller to return
 * @return The specified controller
 */
+ (OFGameController *)controllerWithIndex: (size_t)index;

- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Returns the current position of the specified analog stick.
 *
 * The range is from (-1, -1) to (1, 1).







>
>







>
>
>
>
>
>
>
>
>
>
>

|
>


>
>
>
>
>



|




|
>







|

|

<
|
<
<
<
<
<
<
<







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

78







79
80
81
82
83
84
85
#import "OFObject.h"
#import "OFString.h"

OF_ASSUME_NONNULL_BEGIN

/** @file */

@class OFArray OF_GENERIC(ObjectType);
@class OFMutableSet OF_GENERIC(ObjectType);
@class OFSet OF_GENERIC(ObjectType);

/**
 * @brief A class for reading state from a game controller.
 */
OF_SUBCLASSING_RESTRICTED
@interface OFGameController: OFObject
{
#ifdef OF_LINUX
	OFString *_path;
	int _fd;
	OFString *_name;
	OFMutableSet *_buttons, *_pressedButtons;
	size_t _numAnalogSticks;
	OFPoint _analogStickPositions[2];
#endif
}

#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
    OFArray <OFGameController *> *controllers;
#endif

/**
 * @brief The name of the controller.
 */
@property (readonly, nonatomic, copy) OFString *name;

/**
 * @brief The buttons the controller has.
 */
@property (readonly, nonatomic, copy) OFSet OF_GENERIC(OFString *) *buttons;

/**
 * @brief The currently pressed buttons on the controller.
 */
@property (readonly, nonatomic, copy)
    OFSet OF_GENERIC(OFString *) *pressedButtons;

/**
 * @brief The number of analog sticks the controller has.
 */
@property (readonly, nonatomic) size_t numAnalogSticks;

/**
 * @brief Returns the available controllers.
 *
 * @return The available controllers
 */

+ (OFArray OF_GENERIC(OFGameController *) *)controllers;








- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Returns the current position of the specified analog stick.
 *
 * The range is from (-1, -1) to (1, 1).