ObjFW  Diff

Differences From Artifact [1d9492427b]:

To Artifact [eefaf93827]:


18
19
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
 */

#include "config.h"

#import "OHGameControllerEmulatedButton.h"
#import "OHGameControllerAxis.h"

@implementation OHGameControllerEmulatedButton: OHGameControllerButton
- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
		    positive: (bool)positive
{
	void *pool = objc_autoreleasePoolPush();
	OFString *name;

	@try {
		name = [OFString stringWithFormat:
		    @"%@ %@ as emulated button",
		    (positive ? @"Positive" : @"Negative"), axis.name];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [super initWithName: name];








|













<
|







18
19
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
 */

#include "config.h"

#import "OHGameControllerEmulatedButton.h"
#import "OHGameControllerAxis.h"

@implementation OHGameControllerEmulatedButton
- (instancetype)initWithName: (OFString *)name
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithAxis: (OHGameControllerAxis *)axis
		    positive: (bool)positive
{
	void *pool = objc_autoreleasePoolPush();
	OFString *name;

	@try {
		name = [OFString stringWithFormat:

		    @"%@%c", axis.name, (positive ? '+' : '-')];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	self = [super initWithName: name];

63
64
65
66
67
68
69





70
- (bool)isPressed
{
	if (_positive)
		return (_axis.value > 0);
	else
		return (_axis.value < 0);
}





@end







>
>
>
>
>

62
63
64
65
66
67
68
69
70
71
72
73
74
- (bool)isPressed
{
	if (_positive)
		return (_axis.value > 0);
	else
		return (_axis.value < 0);
}

- (float)value
{
	return (self.isPressed ? 1 : 0);
}
@end