summaryrefslogtreecommitdiff
path: root/camlibs/pentax/pslr_enum.c
blob: f3a529fddcf4ef8771502148924a9ca049cb56c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
    pkTriggerCord
    Copyright (C) 2011-2017 Andras Salamon <andras.salamon@melda.info>
    Remote control of Pentax DSLR cameras.

    Support for K200D added by Jens Dreyer <jens.dreyer@udo.edu> 04/2011
    Support for K-r added by Vincenc Podobnik <vincenc.podobnik@gmail.com> 06/2011
    Support for K-30 added by Camilo Polymeris <cpolymeris@gmail.com> 09/2012
    Support for K-01 added by Ethan Queen <ethanqueen@gmail.com> 01/2013
    Support for K-3 added by Tao Wang <twang2218@gmail.com> 01/2016

    based on:

    PK-Remote
    Remote control of Pentax DSLR cameras.
    Copyright (C) 2008 Pontus Lidman <pontus@lysator.liu.se>

    PK-Remote for Windows
    Copyright (C) 2010 Tomasz Kos

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU General Public License
    and GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "pslr_enum.h"

#include <string.h>
#include <ctype.h>
#include <stdio.h>

const char* pslr_color_space_str[PSLR_COLOR_SPACE_MAX] = {
    "sRGB",
    "AdobeRGB"
};

const char* pslr_af_mode_str[PSLR_AF_MODE_MAX] = {
    "MF",
    "AF.S",
    "AF.C",
    "AF.A"
};

const char* pslr_ae_metering_str[PSLR_AE_METERING_MAX] = {
    "Multi",
    "Center",
    "Spot"
};

const char* pslr_flash_mode_str[PSLR_FLASH_MODE_MAX] = {
    "Manual",
    "Manual-RedEye",
    "Slow",
    "Slow-RedEye",
    "TrailingCurtain",
    "Auto",
    "Auto-RedEye",
    "TrailingCurtain", // maybe in manual mode??
    "Wireless"
};

const char* pslr_drive_mode_str[PSLR_DRIVE_MODE_MAX] = {
    "Single", // Bracketing also returns Single
    "Continuous-HI",
    "SelfTimer-12",
    "SelfTimer-2",
    "Remote",
    "Remote-3",
    "Continuous-LO"
};

const char*  pslr_af_point_sel_str[PSLR_AF_POINT_SEL_MAX] = {
    "Auto-5",
    "Select",
    "Spot",
    "Auto-11"
};

const char* pslr_jpeg_image_tone_str[PSLR_JPEG_IMAGE_TONE_MAX] = {
    "Natural",
    "Bright",
    "Portrait",
    "Landscape",
    "Vibrant",
    "Monochrome",
    "Muted",
    "ReversalFilm",
    "BleachBypass",
    "Radiant"
};

const char* pslr_white_balance_mode_str[PSLR_WHITE_BALANCE_MODE_MAX] = {
    "Auto",
    "Daylight",
    "Shade",
    "Cloudy",
    "Fluorescent_D",
    "Fluorescent_N",
    "Fluorescent_W",
    "Tungsten",
    "Flash",
    "Manual",
    "0x0A", // ??
    "0x0B", // ??
    "0x0C", // ?? exif: set color temp1
    "0x0D", // ?? exif: set color temp2
    "0xOE", // ?? exif: set color temp3
    "Fluorescent_L",
    "CTE"
};

const char* pslr_custom_ev_steps_str[PSLR_CUSTOM_EV_STEPS_MAX] = {
    "1/2",
    "1/3"
};

const char* pslr_image_format_str[PSLR_IMAGE_FORMAT_MAX] = {
    "JPEG",
    "RAW",
    "RAW+"
};

const char* pslr_raw_format_str[PSLR_RAW_FORMAT_MAX] = {
    "PEF",
    "DNG"
};

const char* pslr_exposure_submode_str[PSLR_EXPOSURE_SUBMODE_MAX] = {
    "NONE",
    "HISPEED",
    "DOF",
    "MTF",
    "STANDARD",
    "PORTRAIT",
    "LANDSCAPE",
    "MACRO",
    "SPORT",
    "NIGHTSCENEPORTRAIT",
    "NOFLASH",
    "NIGHTSCENE",
    "SURFANDSNOW",
    "TEXT",
    "SUNSET",
    "KIDS",
    "PET",
    "CANDLELIGHT",
    "MUSEUM",
    "FOOD",
    "STAGE",
    "NIGHTSNAP",
    "SWALLOWDOF"
};


// case insenstive comparison
// strnicmp
int str_comparison_i (const char *s1, const char *s2, int n) {
    if ( s1 == NULL ) {
        return s2 == NULL ? 0 : -(*s2);
    }
    if (s2 == NULL) {
        return *s1;
    }

    char c1='\0', c2='\0';
    int length=0;
    while ( length<n && (c1 = tolower (*s1)) == (c2 = tolower (*s2))) {
        if (*s1 == '\0') {
            break;
        }
        ++s1;
        ++s2;
        ++length;
    }
    return c1 - c2;
}

int find_in_array( const char** array, int length, char* str ) {
    int i;
    int found_index=-1;
    size_t found_index_length=0;
    size_t string_length;
    for ( i = 0; i<length; ++i ) {
        string_length = strlen(array[i]);
        if ( (str_comparison_i( array[i], str, string_length ) == 0) && (string_length > found_index_length) ) {
            found_index_length = string_length;
            found_index = i;
        }
    }
    return found_index;
}

pslr_color_space_t get_pslr_color_space( char *str ) {
    return find_in_array( pslr_color_space_str, sizeof(pslr_color_space_str)/sizeof(pslr_color_space_str[0]),str);
}

const char *get_pslr_color_space_str( pslr_color_space_t value ) {
    return pslr_color_space_str[value];
}

pslr_af_mode_t get_pslr_af_mode( char *str ) {
    return find_in_array( pslr_af_mode_str, sizeof(pslr_af_mode_str)/sizeof(pslr_af_mode_str[0]),str);
}

const char *get_pslr_af_mode_str( pslr_af_mode_t value ) {
    return pslr_af_mode_str[value];
}

pslr_ae_metering_t get_pslr_ae_metering( char *str ) {
    return find_in_array( pslr_ae_metering_str, sizeof(pslr_ae_metering_str)/sizeof(pslr_ae_metering_str[0]),str);
}

const char *get_pslr_ae_metering_str( pslr_ae_metering_t value ) {
    return pslr_ae_metering_str[value];
}

pslr_flash_mode_t get_pslr_flash_mode( char *str ) {
    return find_in_array( pslr_flash_mode_str, sizeof(pslr_flash_mode_str)/sizeof(pslr_flash_mode_str[0]),str);
}

const char *get_pslr_flash_mode_str( pslr_flash_mode_t value ) {
    return pslr_flash_mode_str[value];
}

pslr_drive_mode_t get_pslr_drive_mode( char *str ) {
    return find_in_array( pslr_drive_mode_str, sizeof(pslr_drive_mode_str)/sizeof(pslr_drive_mode_str[0]),str);
}

const char *get_pslr_drive_mode_str( pslr_drive_mode_t value ) {
    return pslr_drive_mode_str[value];
}

pslr_af_point_sel_t get_pslr_af_point_sel( char *str ) {
    return find_in_array( pslr_af_point_sel_str, sizeof(pslr_af_point_sel_str)/sizeof(pslr_af_point_sel_str[0]),str);
}

const char *get_pslr_af_point_sel_str( pslr_af_point_sel_t value ) {
    return pslr_af_point_sel_str[value];
}

pslr_jpeg_image_tone_t get_pslr_jpeg_image_tone( char *str ) {
    return find_in_array( pslr_jpeg_image_tone_str, sizeof(pslr_jpeg_image_tone_str)/sizeof(pslr_jpeg_image_tone_str[0]),str);
}

const char *get_pslr_jpeg_image_tone_str( pslr_jpeg_image_tone_t value ) {
    return pslr_jpeg_image_tone_str[value];
}

pslr_white_balance_mode_t get_pslr_white_balance_mode( char *str ) {
    return find_in_array( pslr_white_balance_mode_str, sizeof(pslr_white_balance_mode_str)/sizeof(pslr_white_balance_mode_str[0]),str);
}

const char *get_pslr_white_balance_mode_str( pslr_white_balance_mode_t value ) {
    return pslr_white_balance_mode_str[value];
}

const char *get_pslr_custom_ev_steps_str( pslr_custom_ev_steps_t value ) {
    return pslr_custom_ev_steps_str[value];
}

const char *get_pslr_image_format_str( pslr_image_format_t value ) {
    return pslr_image_format_str[value];
}

const char *get_pslr_raw_format_str( pslr_raw_format_t value ) {
    return pslr_raw_format_str[value];
}

const char *get_pslr_exposure_submode_str( pslr_exposure_submode_t value ) {
    return pslr_exposure_submode_str[value];
}