File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 63
63
CONFIG_STATE cfg_state;
64
64
ALLEGRO_JOYSTICK_STATE state;
65
65
IOHIDDeviceRef ident;
66
+ char * name;
66
67
} ALLEGRO_JOYSTICK_OSX;
67
68
68
69
static IOHIDManagerRef hidManagerRef;
@@ -757,10 +758,25 @@ static bool reconfigure_joysticks(void)
757
758
return ret;
758
759
}
759
760
760
- // FIXME!
761
761
static const char *get_joystick_name (ALLEGRO_JOYSTICK *joy_)
762
762
{
763
- (void )joy_;
763
+ ALLEGRO_JOYSTICK_OSX *joy = (ALLEGRO_JOYSTICK_OSX *)joy_;
764
+ CFStringRef str;
765
+
766
+ str = IOHIDDeviceGetProperty (joy->ident , CFSTR (kIOHIDProductKey ));
767
+ if (str) {
768
+ CFIndex length = CFStringGetLength (str);
769
+ CFIndex maxSize = CFStringGetMaximumSizeForEncoding (length, kCFStringEncodingUTF8 ) + 1 ;
770
+ if (joy->name ) {
771
+ free (joy->name );
772
+ }
773
+ joy->name = (char *)malloc (maxSize);
774
+ if (joy->name ) {
775
+ if (CFStringGetCString (str, joy->name , maxSize, kCFStringEncodingUTF8 )) {
776
+ return joy->name ;
777
+ }
778
+ }
779
+ }
764
780
return " Joystick" ;
765
781
}
766
782
You can’t perform that action at this time.
0 commit comments